-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Problem
The current MPI_Reduce_local operation (Section 6.9.7 of MPI-4.0) has severely restricted functionality: it "adds" an in-argument to an inout-argument in that order. It is thus not possible to directly "add" two different in-arguments with the result stored in an out-argument, neither is it possible to add two arguments in the order of inout-argument and then in-argument. This limits the effectiveness of MPI_Reduce_local for implementing own, collective reduction operations since it often makes it necessary to copy arguments around.
Proposal
It is proposed to add a 3-argument MPI_Reduce_locals to the standard which by permitting the use of MPI_IN_PLACE provides the full flexibility desirable for implementing own collective reduction operations.
Changes to the Text
MPI_REDUCE_LOCALS( inbuf, argbuf, inoutbuf, count, datatype, op)
IN inbuf input buffer (choice)
IN argbuf input buffer (choice)
INOUT inoutbuf combined input and output buffer (choice)
IN count number of elements in inbuf, argbuf and inoutbuf buf
fers (nonnegative integer)
IN datatype data type of elements of inbuf, argbuf and inoutb
uf buffers
(handle)
IN op operation (handle)
int MPI_Reduce_locals(const void* inbuf, const void argbuf,
void inoutbuf, int count,
MPI_Datatype datatype, MPI_Op op)
MPI_Reduce_locals(inbuf, argbuf, inoutbuf, count, datatype, op, ierror)
TYPE(), DIMENSION(..), INTENT(IN) :: inbuf
TYPE(), DIMENSION(..), INTENT(IN) :: argbuf
TYPE(), DIMENSION(..) :: inoutbuf
INTEGER, INTENT(IN) :: count
TYPE(MPI_Datatype), INTENT(IN) :: datatype
TYPE(MPI_Op), INTENT(IN) :: op
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
MPI_REDUCE_LOCALS(INBUF, ARGBUF, INOUTBUF, COUNT, DATATYPE, OP, IERROR)
INBUF(), INOUTBUF(*)
INTEGER COUNT, DATATYPE, OP, IERROR
The function applies the operation given by op element-wise to the
elements of inbuf and argbuf in that order with the result stored
element-wise in inoutbuf, as explained for user-defined operations in
Section 5.9.5. The inbuf, argbuf and inoutbuf (the two inputs as well
as the result) have the same number of elements given by count and the
same datatype given by datatype. If the MPI_IN_PLACE option is given
for either inbuf or argbuf (or both), the corresponding input is taken
from inoutbuf. The MPI_IN_PLACE is not allowed for the inoutbuf
argument. The inbuf and argbuf buffers are not required to be
distinct, but must be distinct from the inoutbuf argument.
Rationale: In applications (libraries, typically) applying local
reductions with MPI predefined operators, a specific order of the
arguments (for non-commutative, user-defined operators) may be
required, and some argument may not be placed in the required input or
output buffer, which with a restricted, two-argument local reduction
function entails extra, local copying of either or both arguments. The
three-argument function alleviates such extra copying. A call to
MPI_Reduce_local can always be replaced by a call to
MPI_Reduce_locals with MPI_IN_PLACE as the second input
argument.
Examples: Let A, X, Y be the buffers provided for inoutbuf, inbuf, and argbuf,
respectively. The following reduction-assignments can readily be implemented
with MPI_Reduce_locals:
- A = X op Y (with MPI_Reduce_local it would be required to first copy Y into A)
- A = A op Y (if X is MPI_IN_PLACE. With MPI_Reduce_local this would require
first reducing into Y destructively, and then copying the result Y into A) - A = X op A (if Y is MPI_IN_PLACE)
and even
- A = X op X (if Y is the same as X)
- A = A op A (if both X and Y are MPI_IN_PLACE)
Impact on Implementations
Implementation should be straightforward in MPI libraries.
Impact on Users
None for existing users. New users will be happy.
References and Pull Requests
Metadata
Metadata
Assignees
Labels
Type
Projects
Status