CUDA學習筆記4:CUDA(英偉達顯卡統一計算架構)代碼運行時間測試


CUDA內核運行時間的測量函數

cudaEvent_t start1;
cudaEventCreate(&start1);
cudaEvent_t stop1;
cudaEventCreate(&stop1);
cudaEventRecord(start1, NULL);
// 需要測時間的內核函數kernel;
cudaEventRecord(stop1, NULL);
cudaEventSynchronize(stop1);
float msecTotal1 = 0.0f;
cudaEventElapsedTime(&msecTotal1, start1, stop1);

CPU運行時間的測量函數

long start_time = GetTickCount();//記錄程序運行時間
//需要測試時間的代碼
long end_time = GetTickCount();//記錄程序運行時間
cout << "程序段運行時間:" << (end_time - start_time) << "ms!" << endl;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM