What is the difference between float2 and cuComplex to use?

I am trying to figure out how to use complex numbers in both my host and device code. I stumbled upon cuComplex(but can't find the documentation!) And float2, which is at least mentioned in the CUDA programming guide.

What should i use? In the header file for cuComplexthis, it looks like functions are declared using __host__ __device__, so I assume that it will be normal to use them anywhere.

My source data is read from a file in std::complex<float>, so I really don't want to mess with this. I think in order to use complex values ​​on the GPU, do I have to copy the source complex<float>to cuComplex?

+3
source share
3 answers

cuComplexdefined in /usr/local/cuda/include/cuComplex.h(modulo your installation directory). Relevant fragments:

typedef float2 cuFloatComplex;
typedef cuFloatComplex cuComplex;
typedef double2 cuDoubleComplex;

There are also convenient functions for working with complex numbers - their multiplication, construction, etc.

As for using float2or cuComplex, should you use what is semantically suitable - is it a vector or a complex number? Also, if it is a complex number, you may want to use it cuFloatComplexor cuDoubleComplexjust to be completely explicit.

+5
source

cuBLAS cuFFT, cuComplex. , , .

+2

IIRC, float2 - an array of two numbers. cuComplex (on behalf of) sounds like a complex CUDA format.

This post seems to point out where you can find more on cuComplex: http://forums.nvidia.com/index.php?showtopic=81514

0
source

Source: https://habr.com/ru/post/1788079/


All Articles