Next: Irregular collective communications
Up: A Distributed Array Communication
Previous: Regular collective communications
Contents
Index
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 fairly large set of reduction
operations, mimicking the reductions available as
``intrinsic functions'' in Fortran.
As a first example, 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 discovered
result is broadcast
to the active process group, and returned as the
result of the maxval() method.
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 together.
The boolean reductions:
behave in a similar way: any returns true iff any element of
a is true, all returns true iff all elements of a
are true, and count returns a count of the number of true elements
in a.
The function dotProduct used in some earlier examples is also
logically a reduction, but it takes two
aligned 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 before multiplying elements. The prototype is
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. There is also a boolean form of dotProduct():
This 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.
A notable omission in the current version of the library is any 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: A Distributed Array Communication
Previous: Regular collective communications
Contents
Index
Bryan Carpenter
2003-04-15