how to generate a complex double array output in cuda kernel

nvcc doesn’t support complex double type. But now I need the output data structure to be a complex double array. Convertion in host function is fine but the performance is really unbearable. Is there a way to solve it?

Hello,

You can use the double2 type and define your own structure with your operations. Also the cufft types support the complex double.

I would suggest using the complex data types and operations (single and double precision) exported by cuComplex.h. This header file is installed together with all the other CUDA header files. The layout of the complex data types in CUDA is compatible with the layout of the corresponding types in Fortran and C++, so simple hostdevice copies suffice, and there is no need for any re-formatting. NOTE: I do not have first-hand experience but I believe Matlab stores complex data differently, as separate vectors of the real and imaginary parts.

Thanks. From my test, the cuDoubleComplex in cuComplex.h is compatible with complex double, so it’s safe to copy cuDoubleComplex into complex double array.