我正在尝试使用 gettimeofday 或 cudaEventRecord 来计时循环。然而,他们报告了非常不同的结果。这是伪代码:
// get time here (start)
while (..)
{
. ..
}
// get time here (stop)
// calculate time
// time = (stop.tv_usec-start.tv_usec)*1.0e-3 + (stop.tv_sec - start.tv_sec); or
// cudaEventElapsedTime(&time,start,stop);
我没有同时使用它们,而是分别使用它们,结果不一样。在使用 cudaEvent 时,我还调用了 cudaEventSynchrosize(stop)。谢谢。