Shawn Tabrizi
Shawn Tabrizi

Reputation: 12434

Is there a method of FFT that will run inside CUDA Kernel?

I am currently converting a C++ program into CUDA code, and part of my program runs a fast Fourier transform. Originally I ran FFTW, but I saw that I couldn't call it in kernel, so I then rewrote that part using cufft but it tells me the same thing!

Are there any FFT that will run inside a CUDA kernel?

Can I just add __device__ to the fftw library?

I would like to avoid having to initialize or call the FFT in host. I want a completely on the gpu type function, if one exists.

Upvotes: 6

Views: 4005

Answers (4)

M. Steiner
M. Steiner

Reputation: 336

Since this thread still pops up if you search for this today, I just want to add that NVIDIA introduced cuFFTDx (cuFFT Device Extensions) as GA with CUDA 11.0 (There is also an older early access version). It is a header only library that allows for inline kernel calls of FFT functionalities. I guess this would have been exactly what you searched for 10 years ago.

I guess that NVIDIA wants to provide inline kernels for several other math fields. Hence, the downloaded archive is called mathDx.

Useful links:

Upvotes: 8

Leos313
Leos313

Reputation: 5627

there is NO way to call the APIs from the GPU kernel. You must call them from the host. If you want to run a FFT without passing from DEVICE -> HOST -> DEVICE to continue your elaboration I think that the only solution is to write a kernel that performs the FFT in a device function. Actually I'm doing this because I need to run more FFTs in parallel without passing again the datas to the HOST. If you find/have another solution let me know.

Upvotes: 0

hang
hang

Reputation: 51

Looks like you are trying to perform several FFTs at once if you are looking to incorporate it into a kernel. I would look into the batch processing features in cuFFT. What is your application? cufftPlanMany() works for batch FFTs in many different memory configurations.

Upvotes: 3

Mark Borgerding
Mark Borgerding

Reputation: 8476

Are you sure you need to avoid a launch from the host? Nvidia's cufft library is pretty good these days. Porting FFTW seems like a pretty hard task. You might have an easier time porting kissfft but it is still not going to be easy.

Upvotes: 2

Related Questions