GrPPI  0.3.1
Generic and Reusable Parallel Pattern Interface
Reduce pattern

The reduce pattern is a data pattern that combines all the values in a data set using a binary combination operation.

The interface to the reduce pattern is provided by function grppi::reduce(). As all functions in GrPPI, this function takes as its first argument an execution policy.

grppi::reduce(exec, other_arguments...);

Reduction variants

There is a single variant of the reduction:

Key elements in a reduction

The key element of a reduction is the Combiner operation.

A Combiner is any C++ callable entity, that is able to combine two values into a single value. A Combiner cmb is any operation taking two values x and y of types T and U and returning a combined value of type T, making valid the following:

T x;
U y;
T res = cmb(x,y);

Details on reduction variants

Sequence reduction with identity

Performs a reduction of a sequence of values x1, x2, ..., xN by combining them with a Combiner cmb that has an identity value id. The first argument of a combination may be either the identity value or the result of another combination. The combinations assume that cmb is associative, but not commutative. Consequently, different associative orders may be used:

The only interface currently offered for this pattern is based in iterators (following the C++ standard library conventions):

Note: Reducing with identity value an empty sequence has a result the identity value.