On plans reuse in cuFFT

こ雲淡風輕ζ 提交于 2019-12-11 11:03:49

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/18986639/on-plans-reuse-in-cufft

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!