Python-for-HPC / numbaWithOpenmp

BSD 2-Clause "Simplified" License
2 stars 4 forks source link

Calling runtime calls in GPU target device region fails #4

Closed ggeorgakoudis closed 1 year ago

ggeorgakoudis commented 1 year ago

Reporting a bug

We import OpenMP runtime calls using CFFI. This works for host code where the OpenMP runtime library is dynamically loaded. However, on GPU device the OpenMP runtime library is a statically linked bitcode. Using the same import mechanism fails with:

.egg/numba/core/base.py", line 1114, in add_dynamic_addr
    assert self.allow_dynamic_globals, "dyn globals disabled in this target"
AssertionError: Failed in nopython mode pipeline (step: Handle with contexts)

If we don't import, it fails with a typing error:

.egg/numba/core/dispatcher.py", line 423, in error_rewrite
    raise e.with_traceback(None)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: Handle with contexts)

I'm attaching examples for both cases: target-runtime-call.py.txt target-runtime-call-noimport.py.txt

ggeorgakoudis commented 1 year ago

I believe this is easily solvable by removing the FFI function definitions and just use an ExternalFunction. I'm testing this and will prepare a PR.