Timer&Event

What is the difference between Event and Timer? I need a timere to know execution time of my kernel.

This is how I time my kernels

unsigned int timer = 0;

cutilCheckError(cutCreateTimer(&timer));

cutilCheckError(cutStartTimer(timer));

// Your kernel

//Syncronizing threads

cudaThreadSynchronize();

// stop and destroy timer

cutilCheckError(cutStopTimer(timer));

printf("Processing time: %f (ms) \n", cutGetTimerValue(timer));

cutilCheckError(cutDeleteTimer(timer));

Do not forget the cudaThreadSynchronize since CUBLAS and CUFFT calls are asyncronous of the host code.

This is the wrong way to time kernels. The right way is by using cudaEvents in an appropriate stream because then you avoid any overhead or timing irregularities from the OS or driver.

(using cutil for anything is absolutely the wrong way to do anything–it’s intended for use only by SDK applications and should not be relied upon by anyone else for any reason whatsoever)

Thanks for the clarification! I was advised to do that a while back and saw it throughout the samples so I though it was good enough. I will look into CudaEvents.