Admin Production ni-theme
Current Publication

reduction

LabWindows/CVI

reduction Clause

Creates a private variable, for each thread, of one or more variables. Each variable is initialized for the appropriate operator. After the parallel region, LabWindows/CVI updates the original variable with the values of the private copies using the specified operator.

The following table displays valid operators and the initial value of each operator.

OperatorInitial Value
+0
*1
-0
&~0
|0
^0
&&1
||0

Format

reduction(operator:list)

Example

void a31_1(float *x, int *y, int n)
{
   int i, b;
   float a;

   a = 0.0;
   b = 0;

#pragma omp parallel for private(i) shared(x, y, n) \ reduction(+:a) reduction(^:b)
   for (i=0; i<n; i++)
   {
      a += x[i];
      b ^= y[i];
   }
}