HOME
| OPENMP API Specification: Version 5.1 November 2020

2.19.11  depend Clause

Summary The 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 
inoutset 
depobj  

where depend-modifier is one of the following:  

 
iterator(iterators-definition)  

or  

 
depend(dependence-type)  

where dependence-type is:  

 
source  

or  

 
depend(dependence-type : vec)  

where dependence-type is:  

 
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.

Description Task dependences are derived from the dependence-type of a depend clause and its list items when dependence-type is in, out, inout, mutexinoutset or inoutset. 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.

The storage location of a list item matches the storage location of another list item if they have the same storage location, or if any of the list items is omp_all_memory.

For the independence-type, if the storage location of at least one of the list items matches the storage location of a list item appearing in a depend clause with an out, inout, mutexinoutset, or inoutsetdependence-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 matches the storage location of a list item appearing in a depend clause with an in, out, inout, mutexinoutset, or inoutsetdependence-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 matches the storage location of a list item appearing in a depend clause with an in, out, inout, or inoutset 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 matches 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.

For the inoutsetdependence-type, if the storage location of at least one of the list items matches 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.

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 or the omp_all_memory reserved locator.

SVG-Viewer needed.

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.

SVG-Viewer needed.

SVG-Viewer needed.

The list items that appear in a depend clause may use shape-operators.

SVG-Viewer needed.

SVG-Viewer needed.

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.

SVG-Viewer needed.

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.

SVG-Viewer needed.

Note – An iteration vector vec that does not indicate a lexicographically earlier iteration may cause a deadlock.

SVG-Viewer needed.

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-init 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.

Restrictions Restrictions to the depend clause are as follows:

Cross References