HOME
| OPENMP API Specification: Version 5.1 November 2020

2.17  Clauses on Combined and Composite Constructs

This section specifies the handling of clauses on combined or composite constructs and the handling of implicit clauses from variables with predetermined data sharing if they are not predetermined only on a particular construct. Some clauses are permitted only on a single leaf construct of the combined or composite construct, in which case the effect is as if the clause is applied to that specific construct. As detailed in this section, other clauses have the effect as if they are applied to one or more leaf constructs.

The collapse clause is applied once to the combined or composite construct.

The effect of the private clause is as if it is applied only to the innermost leaf construct that permits it.

The effect of the firstprivate clause is as if it is applied to one or more leaf constructs as follows:

If the parallel construct is among the constituent constructs and the effect is not as if the firstprivate clause is applied to it by the above rules, then the effect is as if the shared clause with the same list item is applied to the parallel construct. If the teams construct is among the constituent constructs and the effect is not as if the firstprivate clause is applied to it by the above rules, then the effect is as if the shared clause with the same list item is applied to the teams construct.

The effect of the lastprivate clause is as if it is applied to all leaf constructs that permit the clause. If the parallel construct is among the constituent constructs and the list item is not also specified in the firstprivate clause, then the effect of the lastprivate clause is as if the shared clause with the same list item is applied to the parallel construct. If the teams construct is among the constituent constructs and the list item is not also specified in the firstprivate clause, then the effect of the lastprivate clause is as if the shared clause with the same list item is applied to the teams construct. If the target construct is among the constituent constructs and the list item is not specified in a map clause, the effect of the lastprivate clause is as if the same list item appears in a map clause with a map-type of tofrom.

The effect of the shared, default, order, or allocate clause is as if it is applied to all leaf constructs that permit the clause.

The effect of the reduction clause is as if it is applied to all leaf constructs that permit the clause, except for the following constructs:

For the parallel and teams constructs above, the effect of the reduction clause instead is as if each list item or, for any list item that is an array item, its corresponding base array or base pointer appears in a shared clause for the construct. If the taskreduction-modifier is specified, the effect is as if it only modifies the behavior of the reduction clause on the innermost leaf construct that accepts the modifier (see Section 2.21.5.4). If the inscanreduction-modifier is specified, the effect is as if it modifies the behavior of the reduction clause on all constructs of the combined construct to which the clause is applied and that accept the modifier. If the target construct is among the constituent constructs and the list item is not specified in a map clause, the effect of the reduction clause is as if the same list item appears in a map clause with a map-type of tofrom.

The in_reduction clause applies to the single leaf construct on which it is permitted. If that construct is a target construct, the effect is as if the same list item also appears in a map clause with a map-type of tofrom and a map-type-modifier of always.

The effect of the if clause is described in Section 2.18.

The effect of the linear clause is as if it is applied to the innermost leaf construct. Additionally, if the list item is not the iteration variable of a simd or worksharing-loop SIMD construct, the effect on the outer leaf constructs is as if the list item was specified in firstprivate and lastprivate clauses on the combined or composite construct, with the rules specified above applied. If a list item of the linear clause is the iteration variable of a simd or worksharing-loop SIMD construct and it is not declared in the construct, the effect on the outer leaf constructs is as if the list item was specified in a lastprivate clause on the combined or composite construct with the rules specified above applied.

The effect of the nowait clause is as if it is applied to the outermost leaf construct that permits it.

If the clauses have expressions on them, such as for various clauses where the argument of the clause is an expression, or lower-bound, length, or stride expressions inside array sections (or subscript and stride expressions in subscript-triplet for Fortran), or linear-step or alignment expressions, the expressions are evaluated immediately before the construct to which the clause has been split or duplicated per the above rules (therefore inside of the outer leaf constructs). However, the expressions inside the num_teams and thread_limit clauses are always evaluated before the outermost leaf construct.

The restriction that a list item may not appear in more than one data sharing clause with the exception of specifying a variable in both firstprivate and lastprivate clauses applies after the clauses are split or duplicated per the above rules.