MPI_ALLTOALL(3)
π MPI_ALLTOALL(3) β Open MPI
ok so bestie, welcome to the Open MPI man page for MPI_Alltoall, MPI_Ialltoall, and MPI_Alltoall_init β it's giving β¨everyone talks to everyoneβ¨ and honestly it's iconic.
πΈ NAME
MPI_Alltoall, MPI_Ialltoall, MPI_Alltoall_init β the collective where all processes send data to all processes. no cap, that's the whole vibe.
π SYNTAX
π§ C Syntax
#include <mpi.h>
int MPI_Alltoall(const void *sendbuf, int sendcount,
MPI_Datatype sendtype, void *recvbuf, int recvcount,
MPI_Datatype recvtype, MPI_Comm comm)
int MPI_Ialltoall(const void *sendbuf, int sendcount,
MPI_Datatype sendtype, void *recvbuf, int recvcount,
MPI_Datatype recvtype, MPI_Comm comm, MPI_Request *request)
int MPI_Alltoall_init(const void *sendbuf, int sendcount,
MPI_Datatype sendtype, void *recvbuf, int recvcount,
MPI_Datatype recvtype, MPI_Comm comm, MPI_Info info, MPI_Request *request)
π§‘ Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_ALLTOALL(SENDBUF, SENDCOUNT, SENDTYPE, RECVBUF, RECVCOUNT,
RECVTYPE, COMM, IERROR)
<type> SENDBUF(*), RECVBUF(*)
INTEGER SENDCOUNT, SENDTYPE, RECVCOUNT, RECVTYPE
INTEGER COMM, IERROR
MPI_IALLTOALL(SENDBUF, SENDCOUNT, SENDTYPE, RECVBUF, RECVCOUNT,
RECVTYPE, COMM, REQUEST, IERROR)
<type> SENDBUF(*), RECVBUF(*)
INTEGER SENDCOUNT, SENDTYPE, RECVCOUNT, RECVTYPE
INTEGER COMM, REQUEST, IERROR
MPI_ALLTOALL_INIT(SENDBUF, SENDCOUNT, SENDTYPE, RECVBUF, RECVCOUNT,
RECVTYPE, COMM, INFO, REQUEST, IERROR)
<type> SENDBUF(*), RECVBUF(*)
INTEGER SENDCOUNT, SENDTYPE, RECVCOUNT, RECVTYPE
INTEGER COMM, INFO, REQUEST, IERROR
π©΅ Fortran 2008 Syntax
USE mpi_f08
MPI_Alltoall(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype,
comm, ierror)
TYPE(*), DIMENSION(..), INTENT(IN) :: sendbuf
TYPE(*), DIMENSION(..) :: recvbuf
INTEGER, INTENT(IN) :: sendcount, recvcount
TYPE(MPI_Datatype), INTENT(IN) :: sendtype, recvtype
TYPE(MPI_Comm), INTENT(IN) :: comm
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
MPI_Ialltoall(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype,
comm, request, ierror)
TYPE(*), DIMENSION(..), INTENT(IN), ASYNCHRONOUS :: sendbuf
TYPE(*), DIMENSION(..), ASYNCHRONOUS :: recvbuf
INTEGER, INTENT(IN) :: sendcount, recvcount
TYPE(MPI_Datatype), INTENT(IN) :: sendtype, recvtype
TYPE(MPI_Comm), INTENT(IN) :: comm
TYPE(MPI_Request), INTENT(OUT) :: request
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
MPI_Alltoall_init(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype,
comm, info, request, ierror)
TYPE(*), DIMENSION(..), INTENT(IN), ASYNCHRONOUS :: sendbuf
TYPE(*), DIMENSION(..), ASYNCHRONOUS :: recvbuf
INTEGER, INTENT(IN) :: sendcount, recvcount
TYPE(MPI_Datatype), INTENT(IN) :: sendtype, recvtype
TYPE(MPI_Comm), INTENT(IN) :: comm
TYPE(MPI_Info), INTENT(IN) :: info
TYPE(MPI_Request), INTENT(OUT) :: request
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
π INPUT PARAMETERS
sendbufβ starting address of the send buffer (choice). your outgoing mail pile πsendcountβ number of elements to send to each process (integer). yes, each β this number repeats for every single one of them, periodt.sendtypeβ datatype of the send buffer elements (handle).recvcountβ number of elements to receive from each process (integer).recvtypeβ datatype of the receive buffer elements (handle).commβ the communicator over which data is to be exchanged (handle). your group chat, essentially π¬infoβ Info (handle, persistent only). yeah β only the persistent one gets this.
π OUTPUT PARAMETERS
recvbufβ starting address of the receive buffer (choice). your inbox, main character energy π₯requestβ Request (handle, non-blocking only). the "i'll text you later" receipt π«Άierrorβ Fortran only: error status (integer).
π DESCRIPTION
ok so MPI_Alltoall is a collective operation where every process sends the same amount of data to every other process, and receives the same amount of data from every other process. it's literally symmetric. it's giving fairness. it's giving equity. π§
here's the whole thing written out β each process does 2n independent point-to-point communications (where n is the number of processes in communicator comm), and yes that includes talking to itself, which, relatable:
MPI_Comm_size(comm, &n);
for (i = 0, i < n; i++)
MPI_Send(sendbuf + i * sendcount * extent(sendtype),
sendcount, sendtype, i, ..., comm);
for (i = 0, i < n; i++)
MPI_Recv(recvbuf + i * recvcount * extent(recvtype),
recvcount, recvtype, i, ..., comm);
so each process breaks its local sendbuf into n blocks β each block holding sendcount elements of type sendtype β and divides its recvbuf the same way according to recvcount and recvtype. process j sends the k-th block of its local sendbuf to process k, and process k drops that data into the j-th block of its local recvbuf. π―
β οΈ big one bestie: the amount of data sent must equal the amount of data received, pairwise, between every pair of processes. no lopsided friendships here, that's a whole mess.
π¦ WHEN COMMUNICATOR IS AN INTER-COMMUNICATOR
when comm is an inter-communicator, the gather operation happens in two phases. first, data is gathered from all the members of the first group and received by all the members of the second group. then the data is gathered from all the members of the second group and received by all the members of the first group. the operation exhibits a symmetric, full-duplex behavior. slay, duplex. π
the first group defines the root process. here's the whole root situation:
- the root process uses
MPI_ROOTas the value of root. - all other processes in the first group use
MPI_PROC_NULLas the value of root. - all processes in the second group use the rank of the root process in the first group as the value of root.
when the communicator is an intra-communicator, these groups are the same, and the operation occurs in a single phase. one and done. β¨
π USE OF IN-PLACE OPTION
when the communicator is an intracommunicator, you can do an all-to-all operation in-place β meaning the output buffer is used as the input buffer. iconic, efficient, a little spicy. π₯
to do it, use the variable MPI_IN_PLACE as the value of sendbuf. in this case, sendcount and sendtype are ignored. instead, each process's input data is assumed to already live in the area where that process would receive its own contribution to the receive buffer. so like, it's already in the right spot. no cap. π
π NOTES
- all arguments on all processes are significant. the
commargument especially β it must describe the same communicator on all processes. everyone has to be in the same group chat or the whole thing falls apart π - there are two MPI library functions that are more general than
MPI_Alltoall:MPI_Alltoallvallows all-to-all communication to and from buffers that don't need to be contiguous β different processes may send and receive different amounts of data.MPI_AlltoallwexpandsMPI_Alltoallv's functionality to allow the exchange of data with different datatypes.
π ERRORS
almost all MPI routines return an error value β C routines as the return result of the function, and Fortran routines in the last argument.
before the error value is returned, the current MPI error handler associated with the communication object (e.g., communicator, window, file) is called. if no communication object is associated with the MPI call, then the call is considered attached to MPI_COMM_SELF and will call the associated MPI error handler. when MPI_COMM_SELF is not initialized (i.e., before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when using the Sessions Model exclusively) the error raises the initial error handler. the initial error handler can be changed by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model, or the mpi_initial_errhandler CLI argument to mpiexec or info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. if no other appropriate error handler has been set, then the MPI_ERRORS_RETURN error handler is called for MPI I/O functions and the MPI_ERRORS_ABORT error handler is called for all other MPI functions. ok that was a lot, but like, read it twice if you gotta π«Ά
Open MPI includes three predefined error handlers you can use:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. dramatic but honest πMPI_ERRORS_ABORTβ an error handler that can be invoked on a communicator, window, file, or session. when called on a communicator, it acts as ifMPI_Abortwas called on that communicator. if called on a window or file, it acts as ifMPI_Abortwas called on a communicator containing the group of processes in the corresponding window or file. if called on a session, it aborts only the local process.MPI_ERRORS_RETURNβ returns an error code to the application.
MPI applications can also implement their own error handlers by calling:
MPI_Comm_create_errhandlerthenMPI_Comm_set_errhandlerMPI_File_create_errhandlerthenMPI_File_set_errhandlerMPI_Session_create_errhandlerthenMPI_Session_set_errhandleror atMPI_Session_initMPI_Win_create_errhandlerthenMPI_Win_set_errhandler
β οΈ note that MPI does not guarantee that an MPI program can continue past an error. like, it might just be over. π
see the MPI man page for a full list of MPI error codes.
see the Error Handling section of the MPI-3.1 standard for more information.
π SEE ALSO
MPI_AlltoallvMPI_Alltoallw
π COPYRIGHT
2003-2026, The Open MPI Community
and that's the whole page bestie, you ate that πβ¨ this Open MPI drop is dated Sep 11, 2026, brought to you by the Open MPI girlies of 2003-2026, The Open MPI Community β go forth and all-to-all, fr fr π
ππ¦
π¦ where this page comes from
- arch rolling: openmpi 5.0.11-1 Β· BSD-3-Clause AND LicenseRef-MPICH
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms