cuFFT with Regent

Hi, I am trying to implement a FFT transform in Regent, a language for implicit task-based parallelism, by relying on cuFFT. However, I’ve been running into some issues with my output.

We’ve managed to successfully implement a CPU version using FFTW, but have been having some issues with the GPU version that is relying on cuFFT.

In short, our output when calling cuFFT seems to be incorrect. For example, with an input of

[3.000000 + 3.000000j,
3.000000 + 3.000000j,
3.000000 + 3.000000j,]

We receive an output of:

[14336.000000 + 0.000000j,
0.000000 + 0.000000j,
0.000000 + 0.000000j,]

But the correct output (which is also what the CPU version outputs). should be

[9.000000 + 9.000000j,
0.000000 + 0.000000j,
0.000000 + 0.000000j,]

At a high level, our code works as follows:

  1. We create a plan using cufftPlan1d and then store the created plan cufft_p
    (var ok = cufft_c.cufftPlan1d(&cufft_p, transform_dimension, cufft_c.CUFFT_C2C, 1);
  2. We execute said plan using cufftExecC2Cvar
    ok = cufft_c.cufftExecC2C(p.cufft_p, [&cufft_c.cufftComplex](input_base), [&cufft_c.cufftComplex](output_base), cufft_c.CUFFT_FORWARD)

where input_base and output_base are pointers to our input and output.

3 Lastly, we destroy the plan using cufftDestroy.

We were wondering if we might be using cuFFT wrongly, or there are additional steps we might need to take. One thing that perhaps might be causing issues is that input_base and output_base are actually set up as complex64 data structures – I wasn’t sure if this is interoperable with cufftComplex.

The full code can also be found here. Would be more than happy to chat further in case there are any other details that might be helpful!


if I see correctly, you use fftw_complex in your code for CPU version. FFTW uses 64-bit floats by default, however cuFFT uses 32-bit floats. You should change cufftComplex to cufftDoubleComplex and CUFFT_C2C to CUFFT_Z2Z and the code should work fine.


1 Like

Wow, I think this did the trick – thank you so much!!!

We will update our documentation to make this clearer. Thanks for getting in touch with this issue. Glad the support here worked out.

1 Like