CUDA cmath support question

I have windows 10, vscode.
My python version is : 3.9.13
numba version : 0.55.1
My device:
‘NVIDIA GeForce RTX 2080’ [SUPPORTED]
Compute Capability: 7.5

I tried to use cmath functions in the cuda kernel. But I got an error. See code and error message below:

from numba import cuda
import cmath
@cuda.jit
def cmathtest():
    print(cmath.exp(3.14))
cmathtest[1,1]()

Exception has occurred: LoweringError
Failed in cuda mode pipeline (step: native lowering)
e[1me[1mprinting unimplemented for values of type complex128
e[1m
File “…..\python\numba_cuda_cmath_test.py”, line 5:e[0m
e[1mdef cmathtest():
e[1m print(cmath.exp(3.14))
e[0m e[1m^e[0me[0m
e[0m
e[0me[1mDuring: lowering “print($10call_method.4)” at
\python\numba_cuda_cmath_test.py (5)e[0m

During handling of the above exception, another exception occurred:

File “\python\numba_cuda_cmath_test.py”, line 6, in
cmathtest1,1

As the error message says, printing complex values is unsupported. You need to print the real and imaginary components separately, for example:

from numba import cuda
import cmath


@cuda.jit
def cmathtest():
    r = cmath.exp(3.14 + 2j)
    print(r.real, r.imag)


cmathtest[1,1]()

gives

$ python repro.py
-9.614601 21.008287
1 Like

It makes sense.
Thanks!