next up previous contents
Next: Reduce-Scatter Up: Collective Communication Previous: All-to-All Scatter/Gather   Contents

Global Reduction Operations

void Intracomm.reduce(Object sendbuf, int sendoffset,
                      Object recvbuf, int recvoffset,
                      int count, Datatype datatype,
                      Op op, int root)
sendbuf send buffer array
sendoffset initial offset in send buffer
recvbuf receive buffer array
recvoffset initial offset in receive buffer
count number of items in send buffer
datatype data type of each item in send buffer
op reduce operation
dest rank of root process



Combine elements in input buffer of each process using the reduce operation, and return the combined value in the output buffer of the root process. Java binding of the MPI operation MPI_REDUCE.

The predefined operations are available in Java as MPI.MAX, MPI.MIN, MPI.SUM, MPI.PROD, MPI.LAND, MPI.BAND, MPI.LOR, MPI.BOR, MPI.LXOR, MPI.BXOR, MPI.MINLOC and MPI.MAXLOC.

The handling of MINLOC and MAXLOC is modelled on the Fortran binding. The extra predefined types MPI.SHORT2, MPI.INT2, MPI.LONG2, MPI.FLOAT2, MPI.DOUBLE2 describe pairs of Java numeric primitive types.

Op.Op(UserFunction function, boolean commute)
function user defined function
commute true if commutative, false otherwise



Bind a user-defined global reduction operation to an Op object. Java binding of the MPI operation MPI_OP_CREATE. The abstract base class UserFunction is defined by
  class UserFunction {
    public abstract void call(Object invec, Object inoutvec,
                              Datatype datatype) ;
  }
To define a new operation, the programmer should define a concrete subclass of UserFunction, implementing the call method, then pass an object from this class to the Op constructor. The UserFunction.call method plays exactly the same role as the function argument in the standard bindings of MPI. The actual arguments invec and outvec passed to call will be equal-length arrays with elements of the type specified in the datatype argument. The user-defined call method combines these in the way specified in the MPI standard.

void Op.finalize()
Destructor. Java binding of the MPI operation MPI_OP_FREE.

void Intracomm.allreduce(Object sendbuf, int sendoffset,
                         Object recvbuf, int recvoffset,
                         int count, Datatype datatype,
                         Op op)
sendbuf send buffer array
sendoffset initial offset in send buffer
recvbuf receive buffer array
recvoffset initial offset in receive buffer
count number of items in send buffer
datatype data type of each item in send buffer
op reduce operation



Same as reduce except that the result appears in receive buffer of all process in the group. Java binding of the MPI operation MPI_ALLREDUCE.


next up previous contents
Next: Reduce-Scatter Up: Collective Communication Previous: All-to-All Scatter/Gather   Contents
Bryan Carpenter 2002-07-12