Reductions

DPCE provides a series of reduction operators. A reduction operator takes a whole parallel variable and returns one scalar value that represents some aspect of the parallel variable, such as the sum of all the elements. (The parallel variable is "reduced" to a scalar value.) These operators perform the same type of operations as their Standard C counterparts but on parallel variables:

 +=, -=, *=, /=, &=, ^=, |=, ?=

   int:S pvar;
   sum += pvar;   /* summation of pvar */
   bit_and &= pvar;  /* bitwise and all elements of pvar */
   printf(" product %d \n", *=pvar );  /* print product of pvar */

   min_val ?= pvar;   /* find maximum value of all elements in pvar */
Note that when these operators are used with parallel variables on both left and right hand sides, the operation applies to all elements, and is then not a reduction:
   pvar1 += pvar2;   /* for each element, add pvar1 and pvar2 and store into
                        pvar1 */
When the left side is a scalar, then the operator is a reduction:
   s += pvar;  /* sum pvar into scalar s */
   pvar = s;   /* set all elements of pvar to scalar s */

Options:

©1995 Pacific-Sierra Research Corporation. All rights reserved.

Send comments or suggestions to dpce2 at crescentbaysoftware.com.