I am calling the CUFFT library in a dll, and I would create a plan in my code, I just want to know is it possible to share the FFT plan between successive calls to the dll? I want this functionality since creating the plan can cost sometime comparable to the FFT transform time, so I want to make the plan reside in memory and reuse it each time I call my function in the dll file.
So long as your DLL does not get unloaded and reloaded between invocations, then yes, this is absolutely possible. In fact, I know of a several software packages that use CUFFT under the hood that essentially do exactly this.
So long as your DLL does not get unloaded and reloaded between invocations, then yes, this is absolutely possible. In fact, I know of a several software packages that use CUFFT under the hood that essentially do exactly this.
The DLL will get unloaded at the end of my application, but I just wonder how I can pass the plan information between successive DLL calls, by passing the ‘plan’ as an arguement? Hope you can provide some clues for this, thanks.
The DLL will get unloaded at the end of my application, but I just wonder how I can pass the plan information between successive DLL calls, by passing the ‘plan’ as an arguement? Hope you can provide some clues for this, thanks.
There’s probably no need to pass the cufft plans back and forth through your library’s API. Just store them in one of your library’s data structures the way you would any other object and refer to them when necessary.
Maybe if you could give us a bit more information about what you’re trying to do then we could be more specific…
There’s probably no need to pass the cufft plans back and forth through your library’s API. Just store them in one of your library’s data structures the way you would any other object and refer to them when necessary.
Maybe if you could give us a bit more information about what you’re trying to do then we could be more specific…
Yes, I am calling the CUFFT library using LabVIEW, I worked out a DLL which can perform the 1D FFT, and the code contains one cufftPlan1d() plus one cufftDestroy().
Now I want to execute the FFT of the same length for e.g. 1000 times, then the cufftPlan1d() and cufftDestroy() will be executed 1000 times for each, what I am trying to implement is call the cufftPlan1d() and cufftDestroy() once.
Since I don’t know exactly the structure for the plan variable, so it seems difficult to me to allocate a proper memory for the ‘plan’. Thanks.
Yes, I am calling the CUFFT library using LabVIEW, I worked out a DLL which can perform the 1D FFT, and the code contains one cufftPlan1d() plus one cufftDestroy().
Now I want to execute the FFT of the same length for e.g. 1000 times, then the cufftPlan1d() and cufftDestroy() will be executed 1000 times for each, what I am trying to implement is call the cufftPlan1d() and cufftDestroy() once.
Since I don’t know exactly the structure for the plan variable, so it seems difficult to me to allocate a proper memory for the ‘plan’. Thanks.
You don’t have to allocate memory for the plan – just the handle to the plan. (Sorry if I used the terms a bit loosely in my earlier post.) CUFFT takes care of allocating and freeing the memory for the plan itself. So just store the cufftHandle somewhere – like as a member variable of a class that persists across calls into your library, for example – that’s all you need for CUFFT to be able to locate the appropriate plan structure in memory.
You don’t have to allocate memory for the plan – just the handle to the plan. (Sorry if I used the terms a bit loosely in my earlier post.) CUFFT takes care of allocating and freeing the memory for the plan itself. So just store the cufftHandle somewhere – like as a member variable of a class that persists across calls into your library, for example – that’s all you need for CUFFT to be able to locate the appropriate plan structure in memory.
I have another question: can I get the length information from the plan variable, for example, if I have a plan, is there any API that can get the nx, type and batch from a former call such as:
cufftPlan1d( cufftHandle *plan, int nx, cufftType type, int batch );
I have another question: can I get the length information from the plan variable, for example, if I have a plan, is there any API that can get the nx, type and batch from a former call such as:
cufftPlan1d( cufftHandle *plan, int nx, cufftType type, int batch );
No, there’s no API for this. If you need to refer to it after the fact (for example, to check if you have already created a matching plan), you’ll have to store the plan parameters in a structure of your own. You could then store it in a hash table with the cufftHandle as the hash key, for example.
No, there’s no API for this. If you need to refer to it after the fact (for example, to check if you have already created a matching plan), you’ll have to store the plan parameters in a structure of your own. You could then store it in a hash table with the cufftHandle as the hash key, for example.
It’s wonderful that you answer this question which is important to me~~~ :rolleyes:
I have another question which puzzles me for a long time, in fact, I have posted it before in the forum but didn’t get any satisfactory answer…
In my LabVIEW application, once I call any CUDA function, the affinity of my LabVIEW will be set to 1, which means the LabVIEW application can only run on one core of my dual core machine, I always have to call the Windows API ‘SetProcessAffinityMask’ to put my LabVIEW back onto two cores… Do you have any idea about why this could even happen? Thanks.
It’s wonderful that you answer this question which is important to me~~~ :rolleyes:
I have another question which puzzles me for a long time, in fact, I have posted it before in the forum but didn’t get any satisfactory answer…
In my LabVIEW application, once I call any CUDA function, the affinity of my LabVIEW will be set to 1, which means the LabVIEW application can only run on one core of my dual core machine, I always have to call the Windows API ‘SetProcessAffinityMask’ to put my LabVIEW back onto two cores… Do you have any idea about why this could even happen? Thanks.