Question

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...

Was it helpful?

Solution 2

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.

OTHER TIPS

As a minor follow-up to Robert's answer, it could be useful to quote that the possibility of reusing cuFFT plans is pointed out in the CUFFT guide:

CUFFT provides a simple configuration mechanism called a plan that pre-configures internal building blocks such that the execution time of the transform is as low as possible for the given configuration and the particular GPU hardware selected. Then, when the execution function is called, the actual transform takes place following the plan of execution. The advantage of this approach is that once the user creates a plan, the library retains whatever state is needed to execute the plan multiple times without recalculation of the configuration.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top