HOME
| OPENMP API Specification: Version 5.1 November 2020

2.14.2  target data Construct

Summary The target data construct maps variables to a device data environment for the extent of the region.

Syntax

SVG-Viewer needed.

The syntax of the target data construct is as follows:  

 
#pragma omp target data clause[ [ [,] clause] ... ] new-line 
    structured-block  

where clause is one of the following:  

 
if([ target data :] scalar-expression) 
device(integer-expression) 
map([[map-type-modifier[,] [map-type-modifier[,] ...]] map-type: ] locator-list) 
use_device_ptr(list) 
use_device_addr(list)  

SVG-Viewer needed.

SVG-Viewer needed.

The syntax of the target data construct is as follows:  

 
!$omp target data clause[ [ [,] clause] ... ] 
    loosely-structured-block 
!$omp end target data  

or  

 
!$omp target data clause[ [ [,] clause] ... ] 
    strictly-structured-block 
[!$omp end target data]  

where clause is one of the following:  

 
if([ target data :] scalar-logical-expression) 
device(scalar-integer-expression) 
map([[map-type-modifier[,] [map-type-modifier[,] ...]] map-type: ] locator-list) 
use_device_ptr(list) 
use_device_addr(list)  

SVG-Viewer needed.

Binding The binding task set for a target data region is the generating task. The target data region binds to the region of the generating task.

Description When a target data construct is encountered, the encountering task executes the region. If no device clause is present, the behavior is as if the device clause appeared with an expression equal to the value of the default-device-var ICV. When an if clause is present and the if clause expression evaluates to false, the target device is the host. Variables are mapped for the extent of the region, according to any data-mapping attribute clauses, from the data environment of the encountering task to the device data environment.

If a list item that appears in a use_device_addr clause has corresponding storage in the device data environment, references to the list item in the associated structured block are converted into references to the corresponding list item. If the list item is not a mapped list item, it is assumed to be accessible on the target device. Inside the structured block, the list item has a device address and its storage may not be accessible from the host device. The list items that appear in a use_device_addr clause may include array sections.

SVG-Viewer needed.

If a list item in a use_device_addr clause is an array section that has a base pointer, the effect of the clause is to convert the base pointer to a pointer that is local to the structured block and that contains the device address. This conversion may be elided if the list item was not already mapped.

If a list item that appears in a use_device_ptr clause is a pointer to an object that is mapped to the device data environment, references to the list item in the associated structured block are converted into references to a device pointer that is local to the structured block and that refers to the device address of the corresponding object. If the list item does not point to a mapped object, it must contain a valid device address for the target device, and the list item references are instead converted to references to a local device pointer that refers to this device address.

SVG-Viewer needed.

SVG-Viewer needed.

If a list item that appears in a use_device_ptr clause is of type C_PTR and points to a data entity that is mapped to the device data environment, references to the list item in the associated structured block are converted into references to a device pointer that is local to the structured block and that refers to the device address of the corresponding entity. If a list item of type C_PTR does not point to a mapped object, it must contain a valid device address for the target device, and the list item references are instead converted to references to a local device pointer that refers to this device address.

If a list item in a use_device_ptr clause is not of type C_PTR, the behavior is as if the list item appeared in a use_device_addr clause. Support for such list items in a use_device_ptr clause is deprecated.

SVG-Viewer needed.

If one or more map clauses are present, the list item conversions that are performed for any use_device_ptr or use_device_addr clause occur after all variables are mapped on entry to the region according to those map clauses.

Execution Model Events The events associated with entering a target data region are the same events as associated with a target enter data construct, as described in Section 2.14.3.

The events associated with exiting a target data region are the same events as associated with a target exit data construct, as described in Section 2.14.4.

Tool Callbacks The tool callbacks dispatched when entering a target data region are the same as the tool callbacks dispatched when encountering a target enter data construct, as described in Section 2.14.3.

The tool callbacks dispatched when exiting a target data region are the same as the tool callbacks dispatched when encountering a target exit data construct, as described in Section 2.14.4.

Restrictions Restrictions to the target data construct are as follows:

Cross References