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

5.5.8  reduction Clause

Name: reduction

Properties: data-environment attribute, data-sharing attribute, privatization, reduction scoping, reduction participating

Arguments

Name

Type

Properties

list

list of variable list item type

default

Modifiers

Name

Modifies

Type

Properties

reduction-identifier

list

An OpenMP reduction identifier

required, ultimate

reduction-modifier

list

Keyword: default, inscan, task

default

Directives

do, for, loop, parallel, scope, sections, simd, taskloop, teams

Semantics

The reduction clause is a reduction scoping clause and a reduction participating clause, as described in Section 5.5.6 and Section 5.5.7. For each list item, a private copy is created for each implicit task or SIMD lane and is initialized with the initializer value of the reduction-identifier. After the end of the region, the original list item is updated with the values of the private copies using the combiner associated with the reduction-identifier.

If reduction-modifier is not present or the default reduction-modifier is present, the behavior is as follows. For parallel and worksharing constructs, one or more private copies of each list item are created for each implicit task, as if the private clause had been used. For the simd construct, one or more private copies of each list item are created for each SIMD lane, as if the private clause had been used. For the taskloop construct, private copies are created according to the rules of the reduction scoping clauses. For the teams construct, one or more private copies of each list item are created for the initial task of each team in the league, as if the private clause had been used. For the loop construct, private copies are created and used in the construct according to the description and restrictions in Section 5.3. At the end of a region that corresponds to a construct for which the reduction clause was specified, the original list item is updated by combining its original value with the final value of each of the private copies, using the combiner of the specified reduction-identifier.

If the inscan reduction-modifier is present, a scan computation is performed over updates to the list item performed in each logical iteration of the loop associated with the worksharing-loop, worksharing-loop SIMD, or simd construct (see Section 5.6). The list items are privatized in the construct according to the description and restrictions in Section 5.3. At the end of the region, each original list item is assigned the value described in Section 5.6.

If the task reduction-modifier is present for a parallel or worksharing construct, then each list item is privatized according to the description and restrictions in Section 5.3, and an unspecified number of additional private copies may be created to support task reductions. Any copies associated with the reduction are initialized before they are accessed by the tasks that participate in the reduction, which include all implicit tasks in the corresponding region and all participating explicit tasks that specify an in_reduction clause (see Section 5.5.10). After the end of the region, the original list item contains the result of the reduction.

Restrictions

Restrictions to the reduction clause are as follows:

Cross References