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

7.8  Declare Target Directives

Declare target directives apply to procedures and/or variables to ensure that they can be executed or accessed on a device. Variables are mapped for all device executions, or for specific device executions through a link clause. An implementation may generate different versions of a procedure to be used for target regions that execute on different devices. Whether the same version is generated for different devices, or whether a version that is called in a target region differs from the version that is called outside a target region, is implementation defined.

To facilitate device usage, OpenMP defines rules that implicitly specify declare target directives for procedures and variables. The remainder of this section defines those rules as well as restrictions that apply to all declare target directives.

If a variable with static storage duration is declared in a device routine then the named variable is treated as if it had appeared in an enter clause on a declare target directive.

In the following, a non-host declare target directive is one that does not specify a device_type clause with host. Further, a reverse-offload region is a region that is associated with a target construct that specifies a device clause with the ancestor device-modifier.

If a function is referenced outside of any reverse-offload region in a function that appears as a list item in an enter clause on a non-host declare target directive then the name of the referenced function is treated as if it had appeared in an enter clause on a declare target directive.

If a variable with static storage duration or a function (except lambda for C++) is referenced in the initializer expression list of a variable with static storage duration that appears as a list item in an enter clause on a declare target directive then the name of the referenced variable or function is treated as if it had appeared in an enter clause on a declare target directive.

If a procedure is referenced outside of any reverse-offload region in a procedure that appears as a list item in an enter clause on a non-host declare target directive then the name of the referenced procedure is treated as if it had appeared in an enter clause on a declare target directive.

If a declare target directive has a device_type clause then any enclosed internal procedures cannot contain any declare target directives. The enclosing device_type clause implicitly applies to internal procedures.

Execution Model Events

The target-global-data-op event occurs when an original variable is associated with a corresponding variable on a device as a result of a declare target directive; the event occurs before the first access to the corresponding variable.

Tool Callbacks

A thread dispatches a registered ompt_callback_target_data_op callback, or a registered ompt_callback_target_data_op_emi callback with ompt_scope_beginend as its endpoint argument for each occurrence of a target-global-data-op event in that thread. These callbacks have type signature ompt_callback_target_data_op_t or ompt_callback_target_data_op_emi_t, respectively.

Restrictions

Restrictions to any declare target directive are as follows:

Cross References

  8.2.1  requirement Clauses