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. OpenMP directives provide you with mechanisms to specify reduction variables explictly.