DEPEND Clause

Parallel Directive Clause: Enforces additional constraints on the scheduling of a task by enabling dependences between sibling tasks in the task region.

It takes one of the following forms:

In Synchronization Directive !$OMP ORDERED

DEPEND (SOURCE) -or-

DEPEND (SINK:vec)

In all other directives:

DEPEND (dependence-type : list)

dependence-type

Can be any one of the following clauses: IN, OUT, or INOUT, MUTEXINOUTSET, or INOUTSET.

If one or more of the list items specified in an IN dependence-type is the same as a list item appearing in a DEPEND clause with an OUT, INOUT, MUTEXINOUTSET or INOUTSET dependence-type on a construct that previously generated a sibling task, the generated task is a dependent task of the sibling task.

If one or more of the list items specified in an OUT or INOUT dependence-type is the same as a list item appearing in a DEPEND clause with an IN, OUT, INOUT, MUTEXINOUTSET, or INOUTSET dependence-type on a construct that previously generated a sibling task, the generated task is a dependent task of the sibling task.

If one or more of the list items specified in an MUTEXINOUTSET dependence-type is the same as a list item appearing in a DEPEND clause with an IN, OUT, INOUT, or INOUTSET dependence-type on a construct that previously generated a sibling task, the generated task is a dependent task of the sibling task.

If a list item specified in a MUTEXINOUTSET dependence-type is the same as a list item appearing in a DEPEND clause with a MUTEXINOUTSET dependence-type on a different task generating construct and both constructs generate sibling tasks, the sibling tasks are mutually exclusive.

If one or more of the list items specified in an INOUTSET dependence-type is the same as a list item appearing in a DEPEND clause with an IN, OUT, INOUT, or MUTEXINOUTSET dependence-type on a construct that previously generated a sibling task, the generated task is a dependent task of the sibling task.

list

Is one or more variables or non-zero length array sections. Any list items used in a DEPEND clause of the same task or sibling tasks must indicate identical storage or disjoint storage. The list items that appear in the DEPEND clause may include array sections. Zero-sized arrays and common block names are not permitted as list items.

The behavior is undefined in these cases:

  • If a list item has the POINTER attribute and its association status is disassociated or undefined

  • If a list item has the ALLOCATABLE attribute and its allocation status is unallocated

Note that this enforced task dependence establishes a synchronization of accesses to each list item performed by a dependent task, with respect to accesses to the same list item performed by any previous tasks. You must properly synchronize access with respect to other concurrent accesses to each list item.

SOURCE

Specifies the satisfaction of cross-iteration dependences that arise from the current iteration.

SINK

Specifies a cross-iteration dependence, where the iteration vector vec indicates the iteration that satisfies the dependence.

vec

Is the iteration vector. It has the form:

where n is the value specified by the ORDERED clause in the DO loop directive, xi denotes the loop iteration variable of the i-th nested loop associated with the loop directive, and di is a non-negative integer scalar constant.

If vec does not occur in the iteration space, the DEPEND clause is ignored. Note that if vec does not indicate a lexicographically earlier iteration, it can cause a deadlock.

For a vec element form of xi + di or xi - di, the expression xi + di or xi - di for any value of the integer loop iteration variable xi that can encounter the ordered construct must be computable in the loop iteration variable's type without overflow.

If a DEPEND clause appears in a TARGET or TARGET UPDATE directive, it is treated as if it had appeared on the implicit task construct that encloses the TARGET construct.