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

5.5.2  OpenMP Reduction Expressions

A reduction expression is an OpenMP stylized expression that is relevant to reduction clauses. It is either a combiner expression or an initializer expression.

Restrictions

Restrictions to reduction expressions are as follows:

5.5.2.1 OpenMP Combiner Expressions

A combiner expression specifies how a reduction combines partial results into a single value.

A combiner expression is an assignment statement or a subroutine name followed by an argument list.

In the definition of a combiner expression, omp_in and omp_out correspond to two special variable identifiers that refer to storage of the type of the reduction list item to which the reduction applies. If the list item is an array or array section, the identifiers to which omp_in and omp_out correspond each refer to an array element. Each of the two special variable identifiers denotes one of the values to be combined before executing the combiner expression. The special omp_out identifier refers to the storage that holds the resulting combined value after executing the combiner expression. The number of times that the combiner expression is executed and the order of these executions for any reduction clause are unspecified.

If the combiner expression is a subroutine name with an argument list, the combiner expression is evaluated by calling the subroutine with the specified argument list. If the combiner expression is an assignment statement, the combiner expression is evaluated by executing the assignment statement.

If a generic name is used in a combiner expression and the list item in the corresponding reduction clause is an array or array section, it is resolved to the specific procedure that is elemental or only has scalar dummy arguments.

Restrictions

Restrictions to combiner expressions are as follows:

5.5.2.2 OpenMP Initializer Expressions

An initializer expression determines the initializer for the private copies of reduction list items. If the initialization of the copies is not determined a priori, the syntax of an initializer expression is as follows:

 
omp_priv = initializer  

or

 
omp_priv initializer  

or

 
function-name(argument-list)  

or

 
omp_priv = expression  

or  

 
subroutine-name(argument-list)  

In the definition of an initializer expression, the omp_priv special variable identifier refers to the storage to be initialized. The special variable identifier omp_orig can be used in an initializer expression to refer to the storage of the original variable to be reduced. The number of times that an initializer expression is evaluated and the order of these evaluations are unspecified.

If an initializer expression is a function name with an argument list, it is evaluated by calling the function with the specified argument list. Otherwise, an initializer expression specifies how omp_priv is declared and initialized.
If an initializer expression is a subroutine name with an argument list, the initializer-expr is evaluated by calling the subroutine with the specified argument list. If an initializer expression is an assignment statement, the initializer expression is evaluated by executing the assignment statement.
The a priori initialization of private copies that are created for reductions follows the rules for initialization of objects with static storage duration.
The a priori initialization of private copies that are created for reductions follows the rules for default-initialization.
The rules for a priori initialization of private copies that are created for reductions are as follows:

Restrictions

Restrictions to initializer expressions are as follows: