0
votes

I'm writing a piece of code that uses FFTW3 library and wish to port it to GPU using CUDA. The easiest way to do this is to use cuFFTW compatibility library, but, as the documentation states, it's meant to completely replace the CPU version of FFTW with its GPU equivalent. After adding cufftw.h header it replaces all the CPU functions and the code runs on GPU.

But is there a way to have both CPU and GPU versions of FFTW in my code so I can switch between them during runtime, e.g. via a checkbox in a user interface? Or is the only way to to this is to use native cuFFT API?

1

1 Answers

4
votes

Even without looking at the library headers: Yes.

A simplistic solution would be having different compilation units each include just one of the libraries, and only exposing your own custom functions/classes/etc. to the rest of the application. This way the two libraries' headers will not interfere with each other.

However, it's quite possible that there's a better solution. I would look at cufftw.h to see what exactly nVIDIA is doing in there and how exactly it "replaces" CPU functions.