Search code examples
cudafftdouble-precisioncufft

CUFFT with double precision


I am experiencing some problems with CUDAs FFT library.

I declared the inputs as cuDoubleComplex, but the compiler returns the error that this type is incompatible with parameters of type cufftComplex. After some search through the Internet, I found the file cufft.h, in which there is the line typedef cuComplex cufftComplex;. My problem is that in the library cuComplex.h it is clear that cuComplex has a single floating point precision (typedef cuFloatComplex cuComplex;), but I would like a double precision.

Is this possible?

In particular, I obtain the following:

error: argument of type "cufftDoubleComplex *" is incompatible with parameter of type "cufftComplex *"

at this line:

cufftExecC2C(plan, data1, data2, CUFFT_FORWARD);

Solution

  • The double precision complex data type is defined as cufftDoubleComplex in CUFFT.

    Double precision versions of fft in CUFFT are:

    cufftExecD2Z() //Real To Complex
    
    cufftExecZ2D() //Complex To Real
    
    cufftExecZ2Z() //Complex To Complex
    

    cufftExecC2C is the single precision version of fft, and expects the input and output pointers to be of type cufftComplex,whereas you are passing it a pointer of type cufftDoubleComplex.

    For cufftDoubleComplex data type, you have to use the function cufftExecZ2Z instead, which is for double precision data.