-2

The code snippet

   cudaEventRecord(start, 0);

   /* creates 1D FFT plan */
   cufftPlan1d(&plan, NX, CUFFT_C2C, BATCH);
   /* executes FFT processes */
   cufftExecC2C(plan, devPtr, devPtr, CUFFT_FORWARD);

   cudaEventRecord(stop, 0);
   cudaEventSynchronize(stop);

measures both the time required by the cuFFT to create a plan and the execution time.

How to measure only the execution time without including also the time needed for the creation of the plan?

Robert Crovella
  • 143,785
  • 11
  • 213
  • 257
Sreehari
  • 11
  • 2
  • 3
    put `cudaEventRecord(start, 0)` after `cufftPlan1d()`? Also I think you need `cudaDeviceSynchronize()` after `cufftExecC2C()` – Sagar Masuti Nov 22 '13 at 16:59
  • 1
    @SagarMasuti Perhaps you should post your comment as an answer. I have anyway downvoted this question since it does not show any effort in the understanding of the problem. – Vitality Nov 23 '13 at 21:36

1 Answers1

1

The time needed to calculate the execution time without the plan creation time can be measured with the following snippet. Its just the rearranging your lines in the question.

cufftResult     cuRet ;

/* creates 1D FFT plan */
cuRet = cufftPlan1d(&plan, NX, CUFFT_C2C, BATCH);
if (CUFFT_SUCCESS != cuRet)
{
    printf ("Failed in plan creation\n") ;
    return ;
}

cudaEventRecord(start, 0);
/* executes FFT processes */
cuRet = cufftExecC2C(plan, devPtr, devPtr, CUFFT_FORWARD);
if (CUFFT_SUCCESS != cuRet)
{
    printf ("Failed in FFT execution\n") ;
    return ;
}
if (cudaThreadSynchronize() != cudaSuccess)
{
    printf("Failed to synchronize\n");
    return;
}

cudaEventRecord(stop, 0);
cudaEventSynchronize(stop);

Do remember to check the return values of the cudaEventRecord and cudaEventSynchronize for errors which I have not shown but you can find the proper way to check the errors here.

Community
  • 1
  • 1
Sagar Masuti
  • 1,271
  • 2
  • 11
  • 30