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(User_function 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 User_function is defined by
  class User_function {
    public abstract void Call(Object invec, int inoffset,
                              Object inoutvec, int inoutoffset,
                              int count, Datatype datatype) ;
  }
To define a new operation, the programmer should define a concrete subclass of User_function, implementing the Call method, then pass an object from this class to the Op constructor. The User_function.Call method plays exactly the same role as the function argument in the standard bindings of MPI. The actual arguments invec and inoutvec passed to call will be arrays containing count elements of the type specified in the datatype argument. Offsets in the arrays can be specified as for message buffers. The user-defined Call method should combine the arrays element by element, with results appearing in inoutvec.

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 processes 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