本文介绍了如何测量NVIDIA CUDA的内核时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想测量GPU的内核时间,如何在NVIDIA CUDA中测量它?
eg
I want to measure time inner kernel of GPU, how how to measure it in NVIDIA CUDA?e.g.
__global__ void kernelSample()
{
some code here
get start time
some code here
get stop time
some code here
}
推荐答案
尝试这样,它会以毫秒为单位测量两个事件之间的时间。
Try this, it measures time between 2 events in milliseconds.
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);
这篇关于如何测量NVIDIA CUDA的内核时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!