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

13.8  target Construct

Name: target

Association: block

Category: executable

Properties: parallelism-generating, thread-limiting, exception-aborting, task-generating, device, device-affecting, data-mapping, map-entering, map-exiting, context-matching

Clauses

allocate, defaultmap, depend, device, firstprivate, has_device_addr, if, in_reduction, is_device_ptr, map, nowait, private, thread_limit, uses_allocators

Binding

The binding task set for a target region is the generating task, which is the target task generated by the target construct. The target region binds to the corresponding target task region.

Semantics

The target construct provides a superset of the functionality provided by the target data directive, except for the use_device_ptr and use_device_addr clauses. The functionality added to the target directive is the inclusion of an executable region to be executed on a device. The target construct generates a target task. The generated task region encloses the target region. If a depend clause is present, it is associated with the target task. The device clause determines the device on which the target region executes. If the nowait clause is present, execution of the target task may be deferred. If the nowait clause is not present, the target task is an included task.

All clauses are evaluated when the target construct is encountered. The data environment of the target task is created according to the data-sharing and data-mapping attribute clauses on the target construct, per-data environment ICVs, and any default data-sharing attribute rules that apply to the target construct. If a variable or part of a variable is mapped by the target construct and does not appear as a list item in an in_reduction clause on the construct, the variable has a default data-sharing attribute of shared in the data environment of the target task. Assignment operations associated with mapping a variable (see Section 5.8.3) occur when the target task executes.

If the device clause is specified with the ancestor device-modifier, the encountering thread waits for completion of the target region on the parent device before resuming. For any list item that appears in a map clause on the same construct, if the corresponding list item exists in the device data environment of the parent device, it is treated as if it has a reference count of positive infinity.

When an if clause is present and the if clause expression evaluates to false, the effect is as if a device clause that specifies omp_initial_device as the device number is present, regardless of any other device clause on the directive.

If a procedure is explicitly or implicitly referenced in a target construct that does not specify a device clause in which the ancestor device-modifier appears then that procedure is treated as if its name had appeared in an enter clause on a declare target directive.

If a variable with static storage duration is declared in a target construct that does not specify a device clause in which the ancestor device-modifier appears then the named variable is treated as if it had appeared in a enter clause on a declare target directive.

If a list item in a map clause has a base pointer and it is a scalar variable with a predetermined data-sharing attribute of firstprivate (see Section 5.1.1), then on entry to the target region:
When an internal procedure is called in a target region, any references to variables that are host associated in the procedure have unspecified behavior.

Execution Model Events

Events associated with a target task are the same as for the task construct defined in Section 12.5.

Events associated with the initial task that executes the target region are defined in Section 12.8.

The target-submit-begin event occurs prior to initiating creation of an initial task on a target device for a target region.

The target-submit-end event occurs after initiating creation of an initial task on a target device for a target region.

The target-begin event occurs after creation of the target task and completion of all predecessor tasks that are not target tasks for the same device. The target-begin event is a target-task-begin event.

The target-end event occurs after all other events associated with the target construct.

Tool Callbacks

Callbacks associated with events for target tasks are the same as for the task construct defined in Section 12.5; (flags & ompt_task_target) always evaluates to true in the dispatched callback.

A thread dispatches a registered ompt_callback_target or ompt_callback_target_emi callback with ompt_scope_begin as its endpoint argument and ompt_target or ompt_target_nowait if the nowait clause is present as its kind argument for each occurrence of a target-begin event in that thread in the context of the target task on the host. Similarly, a thread dispatches a registered ompt_callback_target or ompt_callback_target_emi callback with ompt_scope_end as its endpoint argument and ompt_target or ompt_target_nowait if the nowait clause is present as its kind argument for each occurrence of a target-end event in that thread in the context of the target task on the host. These callbacks have type signature ompt_callback_target_t or ompt_callback_target_emi_t, respectively.

A thread dispatches a registered ompt_callback_target_submit_emi callback with ompt_scope_begin as its endpoint argument for each occurrence of a target-submit-begin event in that thread. Similarly, a thread dispatches a registered ompt_callback_target_submit_emi callback with ompt_scope_end as its endpoint argument for each occurrence of a target-submit-end event in that thread. These callbacks have type signature ompt_callback_target_submit_emi_t.

A thread dispatches a registered ompt_callback_target_submit callback for each occurrence of a target-submit-begin event in that thread. The callback occurs in the context of the target task and has type signature ompt_callback_target_submit_t.

Restrictions

Restrictions to the target construct are as follows:

Cross References