码迷,mamicode.com
首页 > 其他好文 > 详细

CUDA编程->CUDA入门了解(一)

时间:2014-09-18 22:22:20      阅读:420      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   os   ar   for   文件   数据   2014   

      安装好CUDA6.5+VS2012,操作系统为Win8.1版本,首先下个GPU-Z检测了一下:

      bubuko.com,布布扣

     看出本显卡属于中低端配置,关键看两个:

     Shaders=384,也称作SM,或者说core/流处理器数量,数量越大,执行并行线程越多,单位时间计算量也就越大。

     BusWidth=64Bit,这个越大,数据的处理速度也就越快


     接下来看看CUDA的布局:

    bubuko.com,布布扣

       看到这个布局,也就知道了如何配置到VS2012中去,跟OpenCV差不多,只是中文资料较少,所以需要关注下一个文件夹里的东东。

      bubuko.com,布布扣

看到这个,就Happy了。

自学靠个人,本人的想法是先学CUDA_Runtime_API,CUDA_Driver_API,CUFFT_Library,Thrust库。

贴一段代码:

#include "stdafx.h"
#include <iostream>
#include <stdio.h> 
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "device_functions.h"
#include "cuda.h"

#include "thrust/host_vector.h"
#include "thrust/device_vector.h"
#include "thrust/copy.h"
#include "thrust/fill.h"
#include "thrust/sequence.h"

#define  mask_width  3
#define  mask_height 3
#define width 16


using namespace std;


void test2()
{
	//////test1/////
	thrust::host_vector<int> v(4);
	v[0]=12;
	v[1]=15;
	v[2]=34;
	v[3]=45;
	cout<<"v size is :"<<endl;
	cout<<v.size()<<endl;
	for(int i=0;i<v.size();i++)
		cout<<v[i]<<endl;

	/////test2//////
	thrust::device_vector<int> D(10,1);
	thrust::device_vector<int> E(20,1);
	thrust::device_vector<int> H(D.begin(),D.end());

	//设置 7个元素的值为9
	thrust::fill(D.begin(),D.begin()+7,9);
	//设置H中元素分别为0,1,2,3,4,5......
	thrust::sequence(H.begin(),H.end());
	//将H复制到E中
	//thrust::copy(H.begin(),H.end(),E.begin);
	for(int i=0;i<H.size();i++)
		cout<<H[i]<<endl;


}


int main()
{

	test2();
	system("pause");
	return 0;
}
调试窗口如下:
bubuko.com,布布扣


CUDA的具体学习在后续补充。。。。。。




       

CUDA编程->CUDA入门了解(一)

标签:blog   http   io   os   ar   for   文件   数据   2014   

原文地址:http://blog.csdn.net/sunboyiris/article/details/39378155

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!