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