Matan Marciano
Matan Marciano

Reputation: 333

How to do inverse fft symmetric with CUFFT

I need to convert this line (MATLAB) to CUDA:

picTimeFiltered = ifft((picFFT_filt), size(I,3), 3 ,'symmetric');

My current implementation is for this line (without 'symmetric' flag):

picTimeFiltered = ifft((picFFT_filt), size(I,3), 3);

This is my CUDA implementation:

void ifftDouble_many(cuDoubleComplex*& input, cuDoubleComplex*& outputMatrixAfterIFFT, const int width, const int height, const int depth)
{
    const int NX = depth;
    const int NY = width * height;

    // Allocate and set the CUDA Input 
    cuDoubleComplex *d_input;
    cudaMalloc(&d_input, NX*NY * sizeof(cuDoubleComplex));
    cudaMemcpy(d_input, input, NX * NY * sizeof(cuDoubleComplex), cudaMemcpyHostToDevice);

    // Allocate the CUDA output
    cufftDoubleComplex* d_output = nullptr;
    cudaMalloc((void**)&d_output, sizeof(cuDoubleComplex)*NX*NY);

    // CUDA FFT
    cufftHandle plan;
    int n[1] = { NX };
    int inembed[] = { NY, NX };
    int onembed[] = { NY, NX };
    cufftPlanMany(&plan, 1, n, inembed, 1, NX, onembed, 1, NX, CUFFT_Z2Z, NY);
    cufftExecZ2Z(plan, d_input, d_output, CUFFT_INVERSE);

    // Devide the results by depth
    devideCufftDoubleComplexArrayByScalar_CUDA(d_output, NX * NY, depth);

    cudaMemcpy(outputMatrixAfterIFFT, d_output, NY*NX * sizeof(cuDoubleComplex), cudaMemcpyDeviceToHost);

    /* Destroy the CUFFT plan. */
    cufftDestroy(plan);
    cudaFree(d_input);
    cudaFree(d_output);
}

Please advise - how to do inverse fft symmetric via CUDA?

Upvotes: 0

Views: 540

Answers (1)

Daniel Klerman
Daniel Klerman

Reputation: 26

Use cufftExecC2R() or cufftExecZ2D() to compute inverse symmetric fft for single/double precision.

http://docs.nvidia.com/cuda/cufft/index.html#axzz4l0egR62U

Upvotes: 1

Related Questions