hi,
if I compute time on device ,can I do this as following? Firstly I get the GPU clock with clock() function,and then I divide the value that the clock() return by GPU runtime frequency.is the method right?and how can I get the GPU runtime frequency,is it the GPU speed clock of the SDK ?
If you want to find the time to complete some kernel use this lines:
float gputime;
cudaEvent_t start,stop;
cudaEventCreate(&start);
cudaEventCreate(&stop);
cudaEventRecord(start,0);
// kernel calls
cudaEventRecord(stop,0);
cudaEventSynchronize(stop);
cudaEventElapsedTime(&gputime,start,stop);
cudaEventDestroy(start);
cudaEventDestroy(stop) ;
printf(" \n");
printf("Time = %g \n", gputime/1000.0f);
printf(" \n");
But I think you can use cudaEvent_t only in the host code. Am I right?
If you want to compute different execution time inside the kernel, you may use clock(). Does clock compute CPU or GPU time?
You can get the clock frequency in kilohertz from the [font=“Courier New”]cudaDeviceProp.clockRate[/font] as returned by [font=“Courier New”]cudaGetDeviceProperties()[/font].
Yes. The code above it was only for calculating how much time does it take to compute the whole kernel and it was in host code.