Next: Irregular Collective Communications
Up: Collective Communications
Previous: Regular Collective Communications
Contents
Reduction operations take one or more distributed arrays as input. They combine
the elements to produce one or more scalar values, or arrays of lower rank.
Adlib provides a large set of reduction operations, supporting the many
kinds of reduction available as ``intrinsic functions'' in Fortran.
Here we mention only a few of the simplest reductions.
One difference between reduction operations and other collective
operations is reduction operations do not support Java Object type.
The maxval() operation simply returns the maximum of all elements of
an array. It has prototypes
where
now runs over all Java numeric types--that is, all Java primitive
types except boolean.
The result is broadcast to the active process group, and returned by the
function. Other reduction operations with similar interfaces are
minval(), sum() and product(). Of these minval() is
minimum value, sum() adds the elements of a in an unspecified
order, and product() multiplies them.
The boolean reductions:
behave in a similar way. The method any() returns true if any element of
a is true. The method all() returns true if all elements of
a are true. The method count() returns a count of the number of
true elements in a.
The method dotProduct() is also logically a reduction, but it takes
two one-dimensional arrays as arguments and returns their scalar product--the
sum of pairwise products of elements. The situation with element types is
complicated because the types of the two arguments needn't be identical.
If they are different, standard Java binary numeric promotions are
applied--for example if the dot product of an int array with a
float array is a float value. The prototypes are
and
If either of
or
is a floating point type (float or double) the
result type,
, is double). Otherwise the result type
is long.
The argument multiarrays must have the same shape and must be aligned.
The result is broadcast to all members of the active process group.
The second form takes boolean as the arguments
and returns the logical ``or'' of all the pairwise logical ``ands'' of
elements.
The methods maxloc() and minloc() return respectively the maximum
and minimum values of all elements of an array--similar to maxval()
and minval()--but also output the index tuple in the array at
which the extreme value was found. The prototypical forms are:
where loc is an ordinary Java array of length
, the rank
of a. On exit
it contains the (broadcast) global subscripts of the extreme value.
For each of the simple reductions that combine all elements of an array
into a single value, there is a corresponding ``dimensional reduction'',
which just reduces along a selected dimension of the input array, and
outputs an array of values of rank one less than the input.
The method maxvalDim(), for example, has the form:
The dimension argument takes a value,
, in the range
where
is the rank of a. The result array, res,
must have rank
.
It must be aligned with the input array a,
with replicated alignment in the
th dimension of a.
In other words, the distribution groups of a and res must
be the same, and
for
, and
for
.
The reductions minvalDim(), sumDim(), productDim(),
anyDim(), allDim(), countDim() are defined in a similar way.
The maxloc() and minloc() reductions have ``dimensional'' forms:
where the array loc has the same rank and alignment as res
(since the reduction is in a single dimension, only one index value--for
the specified dimension--needs to be returned per extreme value).
Currently there is no ``Dim'' form of dotProduct().
Finally all the numeric simple reductions and dimensional reductions
all have ``masked'' variants. These take an extra boolean array
aligned with the source array. For example
ignores all elements of a for which the corresponding element of
mask is false.
One omission in the current version of the library is a facility
for user-defined reduction operations. It also omits various arithmetic
reductions that might seem natural in Java, such as bitwise, and, or,
and xor. There is no fundamental reason for these omissions, and this
might change in future releases.
Next: Irregular Collective Communications
Up: Collective Communications
Previous: Regular Collective Communications
Contents
Bryan Carpenter
2004-06-09