.\" -*- nroff -*- .\" Copyright 2013 Los Alamos National Security, LLC. All rights reserved. .\" Copyright 2010 Cisco Systems, Inc. All rights reserved. .\" Copyright 2006-2008 Sun Microsystems, Inc. .\" Copyright (c) 1996 Thinking Machines Corporation .\" $COPYRIGHT$ .TH MPI_Reduce_scatter_block 3 "Sep 30, 2023" "4.1.6" "Open MPI" .SH NAME \fBMPI_Reduce_scatter_block, MPI_Ireduce_scatter_block\fP \- Combines values and scatters the results in blocks. .SH SYNTAX .ft R .SH C Syntax .nf #include int MPI_Reduce_scatter_block(const void *\fIsendbuf\fP, void\fI *recvbuf\fP, int\fI recvcount\fP, MPI_Datatype\fI datatype\fP, MPI_Op\fI op\fP, MPI_Comm\fI comm\fP) int MPI_Ireduce_scatter_block(const void *\fIsendbuf\fP, void\fI *recvbuf\fP, int\fI recvcount\fP, MPI_Datatype\fI datatype\fP, MPI_Op\fI op\fP, MPI_Comm\fI comm\fP, MPI_Request \fI*request\fP) .fi .SH Fortran Syntax .nf USE MPI ! or the older form: INCLUDE 'mpif.h' MPI_REDUCE_SCATTER_BLOCK(\fISENDBUF, RECVBUF, RECVCOUNT, DATATYPE, OP, COMM, IERROR\fP) \fISENDBUF(*), RECVBUF(*)\fP INTEGER \fIRECVCOUNT, DATATYPE, OP, COMM, IERROR \fP MPI_IREDUCE_SCATTER_BLOCK(\fISENDBUF, RECVBUF, RECVCOUNT, DATATYPE, OP, COMM, REQUEST, IERROR\fP) \fISENDBUF(*), RECVBUF(*)\fP INTEGER \fIRECVCOUNT, DATATYPE, OP, COMM, REQUEST, IERROR \fP .fi .SH Fortran 2008 Syntax .nf USE mpi_f08 MPI_Ireduce_scatter_block(\fIsendbuf\fP, \fIrecvbuf\fP, \fIrecvcount\fP, \fIdatatype\fP, \fIop\fP, \fIcomm\fP, \fIierror\fP) TYPE(*), DIMENSION(..), INTENT(IN), ASYNCHRONOUS :: \fIsendbuf\fP TYPE(*), DIMENSION(..), ASYNCHRONOUS :: \fIrecvbuf\fP INTEGER, INTENT(IN) :: \fIrecvcount\fP TYPE(MPI_Datatype), INTENT(IN) :: \fIdatatype\fP TYPE(MPI_Op), INTENT(IN) :: \fIop\fP TYPE(MPI_Comm), INTENT(IN) :: \fIcomm\fP INTEGER, OPTIONAL, INTENT(OUT) :: \fIierror\fP MPI_Ireduce_scatter_block(\fIsendbuf\fP, \fIrecvbuf\fP, \fIrecvcount\fP, \fIdatatype\fP, \fIop\fP, \fIcomm\fP, \fIrequest\fP, \fIierror\fP) TYPE(*), DIMENSION(..), INTENT(IN), ASYNCHRONOUS :: \fIsendbuf\fP TYPE(*), DIMENSION(..), ASYNCHRONOUS :: \fIrecvbuf\fP INTEGER, INTENT(IN) :: \fIrecvcount\fP TYPE(MPI_Datatype), INTENT(IN) :: \fIdatatype\fP TYPE(MPI_Op), INTENT(IN) :: \fIop\fP TYPE(MPI_Comm), INTENT(IN) :: \fIcomm\fP TYPE(MPI_Request), INTENT(OUT) :: \fIrequest\fP INTEGER, OPTIONAL, INTENT(OUT) :: \fIierror\fP .fi .SH INPUT PARAMETERS .ft R .TP 1i sendbuf Starting address of send buffer (choice). .TP 1i recvcount lement count per block (non-negative integer). .TP 1i datatype Datatype of elements of input buffer (handle). .TP 1i op Operation (handle). .TP 1i comm Communicator (handle). .SH OUTPUT PARAMETERS .ft R .TP 1i recvbuf Starting address of receive buffer (choice). .TP 1i request Request (handle, non-blocking only). .ft R .TP 1i IERROR Fortran only: Error status (integer). .SH DESCRIPTION .ft R MPI_Reduce_scatter_block first does an element-wise reduction on vector of \fIcount\fP\ =\ n * \fIrecvcount\fP elements in the send buffer defined by \fIsendbuf\fP, \fIcount\fP, and \fIdatatype\fP, using the operation \fIop\fP, where n is the number of processes in the group of \fIcomm\fP. Next, the resulting vector of results is split into n disjoint segments, where n is the number of processes in the group. Each segments contains \fIrecvcount\fP elements. The ith segment is sent to process i and stored in the receive buffer defined by \fIrecvbuf\fP, \fIrecvcount\fP, and \fIdatatype\fP. .SH USE OF IN-PLACE OPTION When the communicator is an intracommunicator, you can perform a reduce-scatter operation in-place (the output buffer is used as the input buffer). Use the variable MPI_IN_PLACE as the value of the \fIsendbuf\fR. In this case, the input data is taken from the top of the receive buffer. The area occupied by the input data may be either longer or shorter than the data filled by the output data. .sp .SH WHEN COMMUNICATOR IS AN INTER-COMMUNICATOR .sp When the communicator is an inter-communicator, the reduce-scatter operation occurs in two phases. First, the result of the reduction performed on the data provided by the processes in the first group is scattered among the processes in the second group. Then the reverse occurs: the reduction performed on the data provided by the processes in the second group is scattered among the processes in the first group. For each group, all processes provide the same \fIrecvcounts\fR argument, and the sum of the \fIrecvcounts\fR values should be the same for both groups. .sp .SH NOTES ON COLLECTIVE OPERATIONS The reduction functions ( .I MPI_Op ) do not return an error value. As a result, if the functions detect an error, all they can do is either call .I MPI_Abort or silently skip the problem. Thus, if you change the error handler from .I MPI_ERRORS_ARE_FATAL to something else, for example, .I MPI_ERRORS_RETURN , then no error may be indicated. The reason for this is the performance problems in ensuring that all collective routines return the same error value. .SH ERRORS Almost all MPI routines return an error value; C routines as the value of the function and Fortran routines in the last argument. .sp Before the error value is returned, the current MPI error handler is called. By default, this error handler aborts the MPI job, except for I/O function errors. The error handler may be changed with MPI_Comm_set_errhandler; the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned. Note that MPI does not guarantee that an MPI program can continue past an error. .SH SEE ALSO MPI_Reduce_scatter