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:

Read syntax diagramSkip visual syntax diagram
>>-variable--=--variable--+-+--+--expression-------------------><
                          +- --+               
                          +-*--+               
                          +-^--+               
                          +-|--+               
                          '-&--'               

Read syntax diagramSkip visual syntax diagram
>>-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.



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us