[Openmp-commits] [llvm] [openmp] [OMPT][OpenMP] Use omp_initial_device for host in callbacks (PR #192924)
Jan André Reuter via Openmp-commits
openmp-commits at lists.llvm.org
Mon Apr 20 02:22:16 PDT 2026
Thyre wrote:
CC @jplehr, @mhalk, @dhruvachak, @jprotze
---
This PR only tries to adapt the OpenMP Tools Interface to provide the tool with a consistent, OpenMP conformant, device number.
All "user" code still uses `omp_get_initial_device()`, which most often maps to `omp_get_num_devices()`.
Changing that unfortunately is a larger task, which should be handled separately.
For example, Clang & Flang cannot handle negative device numbers yet when known at compile-time, even though they should (OpenMP 6.0, p.7, l.11-13).
> A conforming device number is either a non-negative integer that is less than or equal to the value returned by omp_get_num_devices or equal to omp_initial_device or omp_invalid_device
I decided to not implement the constant `omp_initial_device` here, due to the reason above.
If the identifier would be exposed to users, they might be confused why Clang & Flang reject this with:
```
$ clang -fopenmp --offload-arch=gfx1101 test.c
test.c:3:32: error: argument to 'device' clause must be a non-negative integer value
```
https://github.com/llvm/llvm-project/pull/192924
More information about the Openmp-commits
mailing list