reduction Clause

LabWindows/CVI 2017 Help

Edition Date: May 2017

Part Number: 370051AG-01

»View Product Info

DOWNLOAD (Windows Only)
LabWindows/CVI 2010 Help
LabWindows/CVI 2012 Help
LabWindows/CVI 2013 Help
LabWindows/CVI 2015 Help
LabWindows/CVI 2017 Help

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];
   }
}

WAS THIS ARTICLE HELPFUL?

Not Helpful