Learn R Programming

Rmpi (version 0.7-2.1)

mpi.reduce: MPI_Reduce and MPI_Allreduce APIs

Description

mpi.reduce and mpi.allreduce are global reduction operations. mpi.reduce combines each member's result, using the operation op, and returns the combined value(s) to the member specified by the argument dest. mpi.allreduce is the same as mpi.reduce except that all members receive the combined value(s).

Usage

mpi.reduce(x, type=2, op=c("sum","prod","max","min","maxloc","minloc"), 
	dest = 0, comm = 1) 

mpi.allreduce(x, type=2, op=c("sum","prod","max","min","maxloc","minloc"), comm = 1)

Value

mpi.reduce returns the combined value(s) to the member specified by dest. mpi.allreduce returns the combined values(s) to every member in a comm. The combined value(s) may be the summation, production, maximum, or minimum specified by the argument op. If the op is either "maxloc" or "minloc", then the maximum (minimum) value(s) along the maximum (minimum) rank(s) will be returned.

Arguments

x

data to be reduced. Must be the same dim and the same type for all members.

type

1 for integer and 2 for double. Others are not supported.

op

one of "sum", "prod", "max", "min", "maxloc", or "minloc".

dest

rank of destination

comm

a communicator number

Author

Hao Yu

Details

It is important that all members in a comm call either all mpi.reduce or all mpi.allreduce even though the master may not be in computation. They must provide exactly the same type and dim vectors to be reduced. If the operation "maxloc" or "minloc" is used, the combined vector is twice as long as the original one since the maximum or minimum ranks are included.

References

https://www.open-mpi.org/

See Also

mpi.gather.