All to All
In applications like matrix transposes or Fast Fourier Transforms (FFTs), an MPI_Alltoall call is very helpful. This is an extension to MPI_Allgather where each process sends distinct data to each receiver. The j-th block from process i is received by process j and stored in the i-th block. A graphic representation of the MPI_Alltoall is shown below:
Just as with Allgatherv, the MPI_Alltoallv extension allows these blocks of data to vary in size among different pairs of senders and receivers. The syntax of MPI_Alltoall and MPI_Alltoallv is as follows:
Alltoall and Alltoallv Syntax
int MPI_Alltoall(void *sbuf, int scount, \
MPI_Datatype stype, void *rbuf, int rcount, \
MPI_Datatype rtype, MPI_Comm comm)
int MPI_Alltoallv(void *sbuf, int *scounts, \
int *sdispls, MPI_Datatype stype, void *rbuf, \
int *rcounts, int *rdispls, MPI_Datatype rtype, \
MPI_Comm comm)
MPI_ALLTOALL(sbuf, scount, stype, rbuf, rcount, rtype, comm, ierr)
MPI_ALLTOALLV(sbuf, scounts, sdispls, stype, rbuf, rcounts,
rdispls, rtype, comm, ierr)
Alltoall[v] parameters:
sbuf
- is the starting address of the send buffer
scount[s]
- is the [array of the] number of elements to send to each process
[sdispls]
- is an array specifying the displacements of data relative to sbuf
stype
- is the data type of send buffer elements
rbuf
- is the address of the receive buffer
rcount[s]
- is [an array containing] the number of elements to be received from each process
[rdispls]
- is an array specifying the displacements of data relative to rbuf
rtype
- is the data type of the receive buffer elements
comm
- is the group communicator
Info: Alltoall vs. Allgather specifications
Alltoall has the same specification as Allgather, except sbuf must contain scount*NPROC elements.