[all-commits] [llvm/llvm-project] 0a4798: [OMPT][OpenMP] Use omp_initial_device for host in ...
Jan André Reuter via All-commits
all-commits at lists.llvm.org
Wed Apr 29 03:07:03 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 0a4798ad4b9612f9499f4c13104603a4c94a6144
https://github.com/llvm/llvm-project/commit/0a4798ad4b9612f9499f4c13104603a4c94a6144
Author: Jan André Reuter <j.reuter at fz-juelich.de>
Date: 2026-04-29 (Wed, 29 Apr 2026)
Changed paths:
M offload/libomptarget/OpenMP/OMPT/Callback.cpp
M offload/libomptarget/device.cpp
M offload/test/ompt/target_memcpy.c
M offload/test/ompt/target_memcpy_emi.c
M openmp/runtime/src/ompt-general.cpp
Log Message:
-----------
[OMPT][OpenMP] Use omp_initial_device for host in callbacks (#192924)
The OpenMP specification offers different ways for identifying the host
device. While users of the OpenMP API can use `omp_get_initial_device()`
or the constant `omp_initial_device` (available since OpenMP v5.2), a
tool needs to rely on the `initial_device_num` passed by the OpenMP
runtime during the `initialize` callback.
In #134451, it was discovered that the `initial_device_num` passed is
always `0`, regardless of any device are available for offload
execution. For host-only OpenMP code, this matches the result of
`omp_get_num_devices()`, and is a valid result. In the case of devices
being available though, this passed identifier is incorrect. While
`libomp` calls `omp_get_num_devices()`, `libomptarget` has not fully
initialized its PluginManager at that point, hence returning no
available devices. Tools relying on `initial_device_num` might therefore
incorrectly assume host-side execution when some code runs on a device.
Since the `ompt_get_num_devices()` entry point is also not fully
implemented, tools currently need to do on-the-fly handling for the host
device.
To make handling easier, consistently use the `omp_initial_device`
identifier as the `initial_device_num` and for all device callbacks.
This does not rely on knowing the number of available devices during
OMPT initialization in the runtime and ensures a consistent value for
tools to handle.
Closes #134451
Signed-off-by: Jan André Reuter <j.reuter at fz-juelich.de>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list