Skip to content

[BUG] Complex division cannot be compiled with cabi #789

@Jlisowskyy

Description

@Jlisowskyy

Describe the bug
Complex division cannot be compiled with cabi.

Steps/Code to reproduce bug

  1. Prepare a clean python environment
  2. Execute pip install numba-cuda
  3. The code below demonstrates the behaviour:
import numba.cuda

def div_by_2(x):
    return x / 2

def main():
    sig = numba.cuda.types.complex128(numba.cuda.types.complex128)
    func = numba.cuda.compile(div_by_2, sig, device=True, abi="c")
    print(func)

if __name__ == "__main__":
    main()

Expected behavior
Compilation will fail with error:

NotImplementedError: Python exceptions are unsupported in the CUDA C/C++ ABI

Environment details (please complete the following information):

  • Environment location: wsl local machine
  • Method of numba-cuda install: pip install
  • Python env:
numba-cuda==0.27.0
numba==0.63.1
Python 3.11.14

Additional context
The issue is caused by the complex_div implementation raising a ZeroDivisionError, which the C ABI calling convention does not support (and breaks compilation).

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions