Skip to content

Calling omp_get_num_devices segfaults or returns wrong number of devices #48

@ggeorgakoudis

Description

@ggeorgakoudis

Running the test program:

from numba.openmp import omp_get_num_devices

print("devices=", omp_get_num_devices())

causes a segfault. The culprit is missing initialization of the libomptarget runtime.

The error is different when we indirectly initialize libomptarget through a target region, for example:

from numba.openmp import omp_get_num_devices
from numba.openmp import njit
from numba.openmp import openmp_context as openmp

@njit
def test():
    with openmp("target"):
        print("Hello from the target region!")

print("devices=", omp_get_num_devices())

This does not crash but wrongfully prints devices= 0 because the implementation falls back to the libomp handling default value of 0.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions