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:
var = var op expr;var assign_op expr;
where:
var |
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; #pragma ibm parallel_loop for (i= 0 ;i < N; i++) { S = S+ i; #pragma ibm parallel_loop for (j=0;j< M; j++) { S = S + j; } } |
op |
Is one of the following operators: + - * ^ | & |
assign_op |
Is one of the following operators: += -= *= ^= |= &= |
expr |
Is any valid expression. |
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 explictily.
Program Parallelization
Countable Loops
Shared and Private Variables in a Parallel Environment
Control Parallel Processing with Pragmas
#pragma Preprocessor Directives for Parallel Processing
#pragma ibm critical Preprocessor Directive
info Compiler Option