Search code examples
c++cudacomplex-numberscublas

Operations with cuDoubleComplex inside cuda-kernel


I have a question to my implementation of a cuda kernel.

I generated a cude kernel where i want to add elements of cuDoubleComplex Variables. Later on i also want to do some multiplication on elements.

I tried several ways but could not find a solution.

My function is:

 __global__ void process(double *fieldRange, double *fieldAzimut, double **recPosition, double **transPosition, double *TimeAxisPulse, double timeStep, cuDoubleComplex *rawData, int nmbrPulses, int nmbrSamples, double carrierFrequency, cuDoubleComplex *result)

where I try to do something like

result[tid]=result[tid]+newValue

where newValue is also a cuDoubleComplex. I tried to use the cublasZaxpy function, but I am told it is not allowed to call a host-function from a global function

What can i do to do a simple addition inside a kernel with cuDoubleComplex Variables?


Solution

  • You can call the function cuCadd, for example:

    result[tid]=cuCadd(result[tid],newValue);
    

    And also make sure you have #include "cuComplex.h" or #include <cuComplex.h> whichever works according to your path setup.