MPI_REDUCE_SCATTER, MPI_Reduce_scatter Purpose Applies a reduction operation to the vector sendbuf over the set of tasks specified by comm and scatters the result according to the values in recvcounts. C synopsis #include int MPI_Reduce_scatter(void* sendbuf,void* recvbuf,int *recvcounts, MPI_Datatype datatype,MPI_Op op,MPI_Comm comm); C++ synopsis #include mpi.h void MPI::Comm::Reduce_scatter(const void* sendbuf, void* recvbuf, int recvcounts[], const MPI::Datatype& datatype, const MPI::Op& op) const; FORTRAN synopsis include 'mpif.h' or use mpi MPI_REDUCE_SCATTER(CHOICE SENDBUF,CHOICE RECVBUF,INTEGER RECVCOUNTS(*), INTEGER DATATYPE,INTEGER OP,INTEGER COMM,INTEGER IERROR) Description This subroutine first performs an element-wise reduction on a vector of count = the sum of i recvcounts[i] elements in the send buffer defined by sendbuf, count, and datatype. Next, the resulting vector is split into n disjoint segments, where n is the number of members in the group. Segment i contains recvcounts[i] elements. The ith segment is sent to task i and stored in the receive buffer defined by recvbuf, recvcounts[i], and datatype. MPI_REDUCE_SCATTER is functionally equivalent to MPI_REDUCE with count equal to the sum of recvcounts[i] followed by MPI_SCATTERV with sendcounts equal to recvcounts. The "in place" option for intracommunicators is specified by passing MPI_IN_PLACE in the sendbuf argument. 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. If comm is an intercommunicator, the result of the reduction of the data provided by tasks in group A is scattered among tasks in group B, and vice versa. Within each group, all tasks provide the same recvcounts argument, and the sum of the recvcounts entries should be the same for the two groups. MPI_IN_PLACE is not supported for intercommunicators. When you use this subroutine in a threads application, make sure all collective operations on a particular communicator occur in the same order at each task. See IBM Parallel Environment for AIX: MPI Programming Guide for more information on programming with MPI in a threads environment. Parameters sendbuf is the starting address of the send buffer (choice) (IN) recvbuf is the starting address of the receive buffer (choice) (OUT) recvcounts integer array specifying the number of elements in result distributed to each task. Must be identical on all calling tasks. (IN) datatype is the datatype of elements in the input buffer (handle) (IN) op is the reduction operation (handle) (IN) comm is the communicator (handle) (IN) IERROR is the FORTRAN return code. It is always the last argument. Notes See IBM Parallel Environment for AIX: MPI Programming Guide. The MPI standard urges MPI implementations to use the same evaluation order for reductions every time, even if this negatively affects performance. PE MPI adjusts its reduce algorithms for the optimal performance on a given task distribution. The MPI standard suggests, but does not mandate, this sacrifice of performance. PE MPI chooses to put performance ahead of the MPI standard's recommendation. This means that two runs with the same task count may produce results that differ in the least significant bits, due to rounding effects when evaluation order changes. Two runs that use the same task count and the same distribution across nodes will always give identical results. In the 64-bit library, this function uses a shared memory optimization among the tasks on a node. This optimization is discussed in the chapter "Using shared memory" of IBM Parallel Environment for AIX: MPI Programming Guide, and is enabled by default. This optimization is not available to 32-bit programs. Errors Fatal errors: Invalid recvcounts recvcounts[i] < 0 Invalid datatype Type not committed Invalid op Invalid communicator Unequal message lengths Invalid use of MPI_IN_PLACE MPI not initialized MPI already finalized Develop mode error if: Inconsistent op Inconsistent datatype Related information MPE_IREDUCE_SCATTER MPI_OP_CREATE MPI_REDUCE