Reduction operations in parallelized loops
The compiler can recognize and properly handle most reduction operations in a loop during both automatic and explicit parallelization. In particular, it can handle reduction statements that have either of the following forms:
>>-variable--=--variable--+-+--+--expression------------------->< +- --+ +-*--+ +-^--+ +-|--+ '-&--'
>>-variable--+-+=--+--expression------------------------------->< +- -=-+ +-*=--+ +-^=--+ +-|=--+ '-&=--'
where:
- variable
- is an identifier designating an automatic or register variable
that does not have its address taken and is not referenced anywhere
else in the loop, including all loops that are nested. For example,
in the following code, only S in the nested loop
is recognized as a reduction:
int i,j, S=0; for (i= 0 ;i < N; i++) { S = S+ i; for (j=0;j< M; j++) { S = S + j; } }
- expression
- is any valid expression.
OpenMP directives provide you with mechanisms to specify reduction variables explictly.