我想测量GPU内核的时间,如何在NVIDIA CUDA中测量它?例如:
__global__ void kernelSample()
{
some code here
get start time
some code here
get stop time
some code here
}
发布于 2012-05-14 23:17:42
试试这个,它以毫秒为单位测量两个事件之间的时间。
cudaEvent_t start, stop;
float elapsedTime;
cudaEventCreate(&start);
cudaEventRecord(start,0);
//Do kernel activity here
cudaEventCreate(&stop);
cudaEventRecord(stop,0);
cudaEventSynchronize(stop);
cudaEventElapsedTime(&elapsedTime, start,stop);
printf("Elapsed time : %f ms\n" ,elapsedTime);
https://stackoverflow.com/questions/10585990
复制相似问题