HOME
| OPENMP API Specification: "Version 5.2 -- GIT rev 95b2e3a44"

1.4.2  Device Data Environments

When an OpenMP program begins, an implicit target data region for each device surrounds the whole program. Each device has a device data environment that is defined by its implicit target data region. Any declare target directives and directives that accept data-mapping attribute clauses determine how an original variable in a data environment is mapped to a corresponding variable in a device data environment.

When an original variable is mapped to a device data environment and a corresponding variable is not present in the device data environment, a new corresponding variable (of the same type and size as the original variable) is created in the device data environment. Conversely, the original variable becomes the new variable’s corresponding variable in the device data environment of the device that performs a mapping operation.

The corresponding variable in the device data environment may share storage with the original variable. Writes to the corresponding variable may alter the value of the original variable. The impact of this possibility on memory consistency is discussed in Section 1.4.6. When a task executes in the context of a device data environment, references to the original variable refer to the corresponding variable in the device data environment. If an original variable is not currently mapped and a corresponding variable does not exist in the device data environment then accesses to the original variable result in unspecified behavior unless the unified_shared_memory clause is specified on a requires directive for the compilation unit.

The relationship between the value of the original variable and the initial or final value of the corresponding variable depends on the map-type. Details of this issue, as well as other issues with mapping a variable, are provided in Section 5.8.3.

The original variable in a data environment and a corresponding variable in a device data environment may share storage. Without intervening synchronization data races can occur.

If a variable has a corresponding variable with which it does not share storage, a write to a storage location designated by the variable causes the value at the corresponding storage location to become undefined.