Using cufftComplex type inside a kernel Does it work?

Hi, I’m looking to swap the real and imaginary arrays of a cufftComplex type inside a kernel, however, the code yields the following compile errors wherever I try to use the cufftComplex arrays:

      no operator "[]" matches these operands
      operand types are: cufftComplex [ int ]

My code:

global void
kernel( cufftComplex* d_signal, cufftComplex* dout )
{
const int idx = blockIdx.x * blockDim.x + threadIdx.x;

dout[idx][0]		= d_signal[idx][1];
dout[idx][1]		= d_signal[idx][0]*(-1.0);

}

Can you use the cufftComplex type inside a kernel, or am I missing something?

Thanks in advance.

cufftComplex changed between CUDA 1.0 and 1.1.

Try:
dout[idx].x = d_signal[idx].y;
dout[idx].y = -d_signal[idx].x;

Thank you for the help, mfatica, that fixed the compile errors inside the kernel, however the compiler now chokes on the call to the kernel itself:

: error: no suitable conversion function from
“cufftComplex” to “cufftComplex *” exists

The array definitions and my kernel call:

cufftComplex* d_signal, dout;
int mem_size = ary_sz * sizeof(cufftComplex);
CUDA_SAFE_CALL(cudaMalloc((void**)&d_signal, mem_size));
CUDA_SAFE_CALL(cudaMalloc((void**)&dout, mem_size));

kernel <<<blocks, threads>>> ( d_signal, dout );

And the kernel definition:

global void
kernel( cufftComplex* d_in, cufftComplex* d_out )

Any more ideas would be appreciated. Thanks.

Subtle C bug here. The * is not attached to the type, like most people expect. Instead, the * modifier is attached to the variable. You need to put a * on each variable for both to be recognized as pointers. (Not sure why this didn’t trigger a warning in your second cudaMalloc() call, but perhaps the void** casting confused the compiler.) Try this:

cufftComplex *d_signal, *dout;

Ahh! Thank you so much, Seibert. Rookie mistake!!! That fixed it.

Thanks again for the help guys. :)

I have a question here.

Can I access the real part of a cufftComplex variable by dout[idx].x ?

The cufft guide said cufftComplex consists of the real and imaginary part,but ,how can I get the real or the imaginary component?

Thanks in advance.