Summary
The targetupdate directive makes the corresponding list items in the device data environment
consistent with their original list items, according to the specified motion clauses. The targetupdate
construct is a stand-alone directive.
Syntax
The syntax of the targetupdate construct is as follows:
Binding
The binding task set for a targetupdate region is the generating task, which is the target task
generated by the targetupdate construct. The targetupdate region binds to the corresponding
target task region.
Description
A corresponding list item and an original list item exist for each list item in a to or from clause. If the
corresponding list item is not present in the device data environment and the present modifier is not
specified in the clause then no assignment occurs to or from the original list item. Otherwise, each
corresponding list item in the device data environment has an original list item in the current task’s data
environment.
If the mappermotion-modifier is not present, the behavior is as if the mapper(default)
modifier was specified. The effect of a motion clause on a list item is modified by a visible
user-defined mapper (see Section 2.21.7.4) if the mapper has the same mapper-identifier as the
mappermotion-modifier and is specified for a type that matches the type of the list item. For a to
clause, each list item is replaced with the list items that the given mapper specifies are to be
mapped with a to or tofrom map type. For a from clause, each list item is replaced with
the list items that the given mapper specifies are to be mapped with a from or tofrom map
type.
If a list item is an array or array section of a type for which a user-defined mapper exists, each array element
is updated according to the mapper as if it appeared as a list item in the clause.
If a present modifier appears in the clause and the corresponding list item is not present in the device
data environment then an error occurs and the program terminates. For a list item that is replaced with a set
of list items as a result of a user-defined mapper, the present modifier only applies to those mapper list
items that share storage with the original list item.
The list items that appear in a to or from may reference iterators defined by an iterators-definition
appearing on an iterator modifier.
If a list item or a subobject of a list item in a motion clause has the ALLOCATABLE attribute, its
update is performed only if its allocation status is allocated and only with respect to the allocated
storage.
If a list item in a motion clause has the POINTER attribute and its association status is associated, the effect
is as if the update is performed with respect to the pointer target.
For each list item in a from or a to clause:
For
each
part
of
the
list
item
that
is
an
attached
pointer:
On
exit
from
the
region
that
part
of
the
original
list
item
will
have
the
value
it
had
on
entry
to
the
region;
On
exit
from
the
region
that
part
of
the
corresponding
list
item
will
have
the
value
it
had
on
entry
to
the
region;
On
exit
from
the
region
that
part
of
the
original
list
item,
if
associated,
will
be
associated
with
the
same
pointer
target
with
which
it
was
associated
on
entry
to
the
region;
On
exit
from
the
region
that
part
of
the
corresponding
list
item,
if
associated,
will
be
associated
with
the
same
pointer
target
with
which
it
was
associated
on
entry
to
the
region.
For each part of the list item that is not an attached pointer:
If
the
clause
is
from,
the
value
of
that
part
of
the
corresponding
list
item
is
assigned
to
that
part
of
the
original
list
item;
If
the
clause
is
to,
the
value
of
that
part
of
the
original
list
item
is
assigned
to
that
part
of
the
corresponding
list
item.
To avoid data races:
Concurrent
reads
or
updates
of
any
part
of
the
original
list
item
must
be
synchronized
with
the
update
of
the
original
list
item
that
occurs
as
a
result
of
the
from
clause;
Concurrent
reads
or
updates
of
any
part
of
the
corresponding
list
item
must
be
synchronized
with
the
update
of
the
corresponding
list
item
that
occurs
as
a
result
of
the
to
clause.
The list items that appear in the to or from clauses may use shape-operators.
The list items that appear in the to or from clauses may include array sections with stride
expressions.
The targetupdate construct is a task generating construct. The generated task is a target task. The
generated task region encloses the targetupdate region.
All clauses are evaluated when the targetupdate construct is encountered. The data environment of
the target task is created according to the motion clauses on the targetupdate construct, per-data
environment ICVs, and any default data-sharing attribute rules that apply to the targetupdate
construct. If a variable or part of a variable is a list item in a motion clause on the targetupdate
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 2.21.7.1) occur when the target
task 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.
If a depend clause is present, it is associated with the target task.
The device is specified in the device clause. If no device clause is present, the device is determined by
the default-device-var ICV. When an if clause is present and the if clause expression evaluates to false, no
assignments occur.
Execution Model Events
Events associated with a target task are the same as for the task construct defined in Section 2.12.1.
The target-update-begin event occurs when a thread enters a targetupdate region.
The target-update-end event occurs when a thread exits a targetupdate region.
Tool Callbacks
Callbacks associated with events for target tasks are the same as for the task construct defined in
Section 2.12.1; (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_update or
ompt_target_update_nowait if the nowait clause is present as its kind argument
for each occurrence of a target-update-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_update or ompt_target_update_nowait if the nowait clause is present as its
kind argument for each occurrence of a target-update-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.
Restrictions
Restrictions to the targetupdate construct are as follows:
A
program
must
not
depend
on
any
ordering
of
the
evaluations
of
the
clauses
of
the
targetupdate
directive,
or
on
any
side
effects
of
the
evaluations
of
the
clauses.
Each
of
the
motion-modifier
modifiers
can
appear
at
most
once
on
a
motion
clause.
At
least
one
motion-clause
must
be
specified.
A
list
item
can
only
appear
in
a
to
or
from
clause,
but
not
in
both.
A
list
item
in
a
to
or
from
clause
must
have
a
mappable
type.
At
most
one
device
clause
can
appear
on
the
directive.
The
device
clause
expression
must
evaluate
to
a
non-negative
integer
value
that
is
less
than
or
equal
to
the
value
of
omp_get_num_devices().
At
most
one
if
clause
can
appear
on
the
directive.
At
most
one
nowait
clause
can
appear
on
the
directive.