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

5.5.11  declare reduction Directive

Name: declare reduction

Association: none

Category: declarative

Properties: pure

Arguments

declare reduction(reduction-specifier)

Name

Type

Properties

reduction-specifier

OpenMP reduction specifier

default

Clauses

initializer

Semantics

The declare reduction directive declares a reduction-identifier that can be used in a reduction clause as a user-defined reduction. The directive argument reduction-specifier uses the following syntax:  

 
reduction-identifier : typename-list : combiner  

where reduction-identifier is a reduction identifier, typename-list is a type-name list, and combiner is an OpenMP combiner expression.

The reduction-identifier and the type identify the declare reduction directive. The reduction-identifier can later be used in a reduction clause that uses variables of the types specified in the declare reduction directive. If the directive specifies several types then the behavior is as if a declare reduction directive was specified for each type. The visibility and accessibility of a user-defined reduction are the same as those of a variable declared at the same location in the program.

The declare reduction directive can also appear at the locations in a program where a static data member could be declared. In this case, the visibility and accessibility of the declaration are the same as those of a static data member declared at the same location in the program.

The enclosing context of the combiner and of the initializer-expr that is specified by the initializer clause is that of the declare reduction directive. The combiner and the initializer-expr must be correct in the base language as if they were the body of a function defined at the same location in the program.

If a type with deferred or assumed length type parameter is specified in a declare reduction directive, the reduction-identifier of that directive can be used in a reduction clause with any variable of the same type and the same kind parameter, regardless of the length type parameters with which the variable is declared.

If the reduction-identifier is the same as the name of a user-defined operator or an extended operator, or the same as a generic name that is one of the allowed intrinsic procedures, and if the operator or procedure name appears in an accessibility statement in the same module, the accessibility of the corresponding declare reduction directive is determined by the accessibility attribute of the statement.

If the reduction-identifier is the same as a generic name that is one of the allowed intrinsic procedures and is accessible, and if it has the same name as a derived type in the same module, the accessibility of the corresponding declare reduction directive is determined by the accessibility of the generic name according to the base language.

Restrictions

Restrictions to the declare reduction directive are as follows:

Cross References