If a list item has the ALLOCATABLE attribute and its allocation status is unallocated, the behavior is unspecified. If a list item has the POINTER attribute and its association status is disassociated or undefined, the behavior is unspecified.
SummaryThe depend clause enforces additional constraints on the scheduling of tasks or loop iterations. These constraints establish dependences only between sibling tasks or between loop iterations.
Syntax
The syntax of the depend clause is as follows:
depend([depend-modifier,]dependence-type : locator-list)
where dependence-type is one of the following:
in
out
inout
mutexinoutset
depobj
where depend-modifier is one of the following:
iterator(iterators-definition)
depend(dependence-type)
source
depend(dependence-type : vec)
sink
and where vec is the iteration vector, which has the form:
x1 [± d1], x2 [± d2], …, xn [± dn]
where n is the value specified by the ordered clause in the worksharing-loop directive, xi denotes the loop iteration variable of the i-th nested loop associated with the worksharing-loop directive, and di is a constant non-negative integer.
DescriptionTask dependences are derived from the dependence-type of a depend clause and its list items when dependence-type is in, out, inout, or mutexinoutset. When the dependence-type is depobj, the task dependences are derived from the dependences represented by the depend objects specified in the depend clause as if the depend clauses of the depobj constructs were specified in the current construct. For the independence-type, if the storage location of at least one of the list items is the same as the storage location of a list item appearing in a depend clause with an out, inout, or mutexinoutset dependence-type on a construct from which a sibling task was previously generated, then the generated task will be a dependent task of that sibling task.
For the out and inoutdependence-types, if the storage location of at least one of the list items is the same as the storage location of a list item appearing in a depend clause with an in, out, inout, or mutexinoutsetdependence-type on a construct from which a sibling task was previously generated, then the generated task will be a dependent task of that sibling task.
For the mutexinoutsetdependence-type, if the storage location of at least one of the list items is the same as the storage location of a list item appearing in a depend clause with an in, out, or inout dependence-type on a construct from which a sibling task was previously generated, then the generated task will be a dependent task of that sibling task.
If a list item appearing in a depend clause with a mutexinoutsetdependence-type on a task-generating construct has the same storage location as a list item appearing in a depend clause with a mutexinoutsetdependence-type on a different task generating construct, and both constructs generate sibling tasks, the sibling tasks will be mutually exclusive tasks.
The list items that appear in the depend clause may reference iterators defined by an iterators-definition appearing on an iterator modifier.
The list items that appear in the depend clause may include array sections.
If a list item has the ALLOCATABLE attribute and its allocation status is unallocated, the behavior is unspecified. If a list item has the POINTER attribute and its association status is disassociated or undefined, the behavior is unspecified.
The list items that appear in a depend clause may use shape-operators.
Note – The enforced task dependence establishes a synchronization of memory accesses performed by a dependent task with respect to accesses performed by the predecessor tasks. However, it is the responsibility of the programmer to synchronize properly with respect to other concurrent accesses that occur outside of those tasks.
The sourcedependence-type specifies the satisfaction of cross-iteration dependences that arise from the current iteration.
The sinkdependence-type specifies a cross-iteration dependence, where the iteration vector vec indicates the iteration that satisfies the dependence.
If the iteration vector vec does not occur in the iteration space, the depend clause is ignored. If all depend clauses on an ordered construct are ignored then the construct is ignored.
Note – An iteration vector vec that does not indicate a lexicographically earlier iteration may cause a deadlock.
Execution Model Events The task-dependences event occurs in a thread that encounters a task generating construct or a taskwait construct with a depend clause immediately after the task-create event for the new task or the taskwait-begin event.
The task-dependence event indicates an unfulfilled dependence for the generated task. This event occurs in a thread that observes the unfulfilled dependence before it is satisfied.
Tool Callbacks A thread dispatches the ompt_callback_dependences callback for each occurrence of the task-dependences event to announce its dependences with respect to the list items in the depend clause. This callback has type signature ompt_callback_dependences_t.
A thread dispatches the ompt_callback_task_dependence callback for a task-dependence event to report a dependence between a predecessor task (src_task_data) and a dependent task (sink_task_data). This callback has type signature ompt_callback_task_dependence_t.
RestrictionsRestrictions to the depend clause are as follows:
∙ List items used in depend clauses with the depobj dependence type must be expressions of the omp_depend_t type. ∙ List items used in depend clauses with the in, out, inout or mutexinoutset dependence types cannot be expressions of the omp_depend_t type.
∙ A common block name cannot appear in a depend clause. ∙ List items used in depend clauses with the depobj dependence type must be integer expressions of the omp_depend_kindkind.
∙ For a vec element of sinkdependence-type of the form xi + di or xi - di if the loop iteration variable xi is of a random access iterator type other than pointer type, the expression ( xi - lbi ) + di or ( xi - lbi ) - di for any value of the loop iteration variable xi that can encounter the ordered construct must be computable without overflow in the type that would be used by std::distance applied to variables of the type of xi.
∙ A bit-field cannot appear in a depend clause.