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------------------------------->< +- -=-+ +-*=--+ +-^=--+ +-|=--+ '-&=--'
int i,j, S=0;
for (i= 0 ;i < N; i++) {
S = S+ i;
for (j=0;j< M; j++) {
S = S + j;
}
}
Recognized reductions are listed by the -qinfo=reduction option. When using IBM directives, use critical sections to synchronize access to all reduction variables not recognized by the compiler. OpenMP directives provide you with mechanisms to specify reduction variables explictly.