GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
libgomp

Libgomp fixes OpenMP target offload for nested ICVs

Libgomp now correctly handles nested environments for OpenMP target offloading with OMP_TARGET_OFFLOAD=mandatory.

This change corrects an issue in libgomp where the OMP_TARGET_OFFLOAD=mandatory setting did not properly initialize the default device ICV when encountering nested environment configurations. The fix ensures that the default device is correctly determined, whether it’s an offload device or an invalid one, even within nested ICVs, preventing potential misconfigurations in target offloading scenarios. New test cases have been added to verify this behavior.

In Details

The libgomp runtime needs to manage the default device ICV for OpenMP target offloading. When OMP_TARGET_OFFLOAD=mandatory is set, the default-device-icv is initialized to INT_MIN. This commit fixes a bug where, in the presence of nested ICVs, the initialization of this ICV via gomp_init_targets_once was not always performed correctly. The fix updates omp_get_default_device and gomp_get_default_device to handle uninitialized non-global ICVs, ensuring proper device resolution across nested scopes.

For Context
OMP_TARGET_OFFLOAD
An OpenMP environment variable that controls the behavior of target offloading. Setting it to 'mandatory' forces all offloadable regions to be executed on a target device.
ICV
Internal Control Variable. These are variables within OpenMP that control the behavior of runtime features, such as the default device for offloading.
default-device-icv
The specific Internal Control Variable in OpenMP that specifies which target device should be used by default for offloading regions.
INT_MIN
The smallest possible value for a signed integer type. In this context, it's used as an initial sentinel value for the default device ICV.
omp_invalid_device
A special device identifier in OpenMP indicating that no valid target device is available or selected.
Filed Under: libgompOpenMPoffloading