CUDA编程-gt;CUDA入门了解(一)
生活随笔
收集整理的這篇文章主要介紹了
CUDA编程-gt;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 16using 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個元素的值為9thrust::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的詳細學習在興許補充。
。
。
。
。。
? ? ? ?
轉載于:https://www.cnblogs.com/gcczhongduan/p/5269920.html
總結
以上是生活随笔為你收集整理的CUDA编程-gt;CUDA入门了解(一)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 40乘40瓷砖一平方用多少块?
- 下一篇: 3月13日 抽奖活动