HOME
| OPENMP API Specification: "Version 5.2 -- GIT rev 95b2e3a44"

17.2  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. Other clauses that are permitted on more than one leaf construct have the effect as if they are applied to a subset of those constructs, as detailed in this section.

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 the base variable or base pointer of a list item that appears 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, thread_limit, or order clause is as if it is applied to all leaf constructs that permit the clause.

The effect of the allocate clause is as if it is applied to all leaf constructs that permit the clause and to which a data-sharing attribute clause that may create a private copy of the same list item is applied.

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 task reduction-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 5.5.8). If the inscan reduction-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 a list item in a reduction clause on a combined target construct does not have the same base variable or base pointer as a list item in a map clause on the construct, then the effect is as if the list item in the reduction clause appears as a list item in a map clause with a map-type of tofrom.

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

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.

Restrictions

Restrictions to clauses on combined and composite constructs are as follows: