How to use fft in PGI Fortran Accelerator?

I am a new user of PGI Fortran. I need to do fft on GPU. I used fftw before, and I do not know what should I use if I want to run fft on GPU. Someone said I can use CUFFT but I do not know how to start. Any good articles, examples or suggestions about fft?

Hi hzhcapricorn,

While this article focuses on CUBLAS, CULA, and MAGMA, you should be able to apply similar methods to CUFFT.

Let me know if you have any questions!
Mat

Thanks. But I still want to know if I can use fftw in GPU?

Are you asking if you can call a fftw routine from within an accelerator region? Function calls are not yet supported on a GPU unless the routine can be in-lined. This a general restriction in GPU program since there isn’t a linker for device code nor hardware support. This may change in the future, though.

Of course, you could implement your own FFT within an Accelerator region. That would be fine.

  • Mat

Does that mean even if I used functions of cufft within an accelerator region, I can still not run that on GPU?

While the CUFFT library does utilize a GPU in solving ffts, it can only be called from host code. So, no it can not be called from any device code including device code generated from an Accelerator region.

Here’s an example of calling CUFFT from CUDA Fortran: http://cudamusing.blogspot.com/2010/05/calling-cufft-from-cuda-fortran.html


Can you please explain more about what you’re trying to do? Maybe we can find a solution. A small example code would help.

Thanks,
Mat

I cannot open your last link…

I am trying to simply use fft in calculation, but I do not know:

  1. how to call cufft in my code, like which module to use or which file to include? Here I need a example.

  2. how to compile, maybe use “pgfortran -I/opt/cuda2.3/include -L -L/opt/cuda2.3/lib64 source.c -lcufft”?

  3. If I use cufft, do I need to do other things to run it on GPU? (like use !$acc region?)

It’s OK. I opened the link. The Great Fire Wall does not allow me to open that in China, so I find help from US. Thanks a lot!