Search code examples
cudanvidiacufft

On plans reuse in cuFFT


This may seem like a simple question but cufft usage is not very clear to me.

My question is: which one of the following implementations is correct?

1)

// called in a loop
cufftPlan3d (plan1, x, y, z) ;
cufftexec (plan1, data1) ;
cufftexec (plan1, data2) ;
cufftexec (plan1, data3) ;
destroyplan(plan1)    

2)

init() //called only one time in application
{
    cufftPlan3d (plan1, x, y, z) ;
}
exec () //called many times with data changing size remains same
{
    cufftexec (plan1, data1) ;
    cufftexec (plan1, data2) ;
    cufftexec (plan1, data3) ;
}

deinit() //called only one time in application
{    
    destroyplan(plan1)    
}

3)

 cufftPlan3d (plan1, x, y, z) ;
 cufftexec (plan1, data1) ;
 destroyplan(plan1) 

 cufftPlan3d (plan2, x, y, z) ;
 cufftexec (plan2, data2) ;
 destroyplan(plan2) 

 ....
  ...

Assume all the data sizes of data1, data2 and data3 are same. Please ignore the correctness of the syntax. I just need a conceptual answer.

The third implementation doesn't look correct to me...


Solution

  • I think all 3 can be made to work. Method 2 will probably be fastest, as long as the plan fits the data for each of data1, data2, and data3.

    You can reuse a plan as many times as you want, as long as your transform intent doesn't change.