Collective Communication I

2.3.5 All to All
Purpose:
  • Extension to ALLGATHER
  • Each process sends distinct data to each receiver
  • Process i sends its jth block of data to process j
  • Process j stores data from process i in ith block
  • Varying data version (like GATHERV) called ALLTOALLV
Fortran Binding:
MPI_ALLTOALL (sbuf, scount, stype, rbuf, rcount, rtype, comm, ierr)
C Binding:
int MPI_Alltoall (void* sbuf, int scount, MPI_Datatype stype, void* rbuf, int rcount, MPI_Datatype rtype, MPI_Comm comm)


Effect:

All to All

In applications like matrix transpose and FFT, an MPI_ALLTOALL call is very helpful. This is an extension to ALLGATHER where each process sends distinct data to each receiver. The jth block from process i is received by process j and stored in ith block. A graphic representation of the MPI_ALLTOALL is shown below:

 

Image2

The syntax of MPI_ALLTOALL is:

C
int MPI_Alltoall (void* sbuf, int scount, MPI_Datatype stype, void* rbuf, int rcount, MPI_Datatype rtype, MPI_Comm comm )
FORTRAN
MPI_ALLTOALL (sbuf, scount, stype, rbuf, rcount, rtype, comm, ierr)

The variables for Alltoall are:
sbuf is the starting address of send buffer,
scount is the number of elements sent to each process,
stype is the data type of send buffer elements,
rbuf is the address of receive buffer,
rcount is the number of elements received from any process,
rtype is the data type of receive buffer elements,
comm is the group communicator.

Note: Same specification as ALLGATHER, except sbuf must contain scount*NPROC elements.