CUDA編程->CUDA入門瞭解(一)

來源:互聯網
上載者:User

標籤:blog   http   io   os   ar   for   檔案   資料   2014   

      安裝好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的具體學習在後續補充。。。。。。




       

CUDA編程->CUDA入門瞭解(一)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.