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

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

      

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

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

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


     接下来看看CUDA的布局:

    

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

      

看到这个,就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;
}
调试窗口如下:


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




       

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值