GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
openmp

OpenMP: Implement local clause for declare target

Adds 'local' clause support to OpenMP's 'declare target' directive for offloaded code.

This patch implements the ‘local’ clause for the OpenMP declare target directive. This new clause allows variables to have non-associated versions on the host and device, preventing them from being automatically managed by the offloading machinery. When a ‘local’ variable is modified on the GPU, omp target update will not work as expected, confirming its local scope. This feature is integrated by extending the existing declare target attribute handling in the front-ends.

In Details

This commit introduces the local clause to the omp declare target directive. This clause enables the creation of distinct, non-associated versions of variables on the host and target devices. Unlike variables implicitly managed by declare target (which are typically mapped or copied), local variables are independent. The front-ends represent this by adding a PRAGMA_OMP_CLAUSE_LOCAL to the clause parsing and attribute handling, setting a flag within TREE_VALUE(DECL_ATTRIBUTES(var)). This ensures that value_member() correctly identifies the 'local' attribute, while subsequent code…

For Context
OpenMP
A standardized API for shared-memory parallel programming. It uses compiler directives (pragmas) to specify parallel regions and tasks.
declare target
An OpenMP directive that specifies which variables and functions should be available on a target device for offloading computations.
offload
The process of transferring computation and data from the host CPU to a specialized accelerator device, such as a GPU.
host
The main CPU of a system, as opposed to an accelerator device.
target device
An accelerator device (e.g., GPU, Xeon Phi) where computations can be offloaded.
omp target update
An OpenMP directive used to synchronize data between the host and the target device after a target region has executed.
Filed Under: openmpoffloadinggpuparallelismdeclare target