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;
相关文章
相关标签/搜索