MPI_Alltoallw(3)
π MPI_Alltoallw(3) π
okay bestie, welcome to the MPI manual page for MPI_Alltoallw, and ngl this one is the drama queen of collective communication. every partner gets to pick their own datatype, their own count, and their own displacement. it's giving "everybody wants something different" and honestly? iconic. no cap. π
β¨ NAME β¨
MPI_Alltoallw β Generalized all-to-all communication allowing different datatypes, counts, and displacements for each partner π¦
β¨ SYNOPSIS β¨
int MPI_Alltoallw(const void *sendbuf, const int sendcounts[],
const int sdispls[], const MPI_Datatype sendtypes[],
void *recvbuf, const int recvcounts[], const int rdispls[],
const MPI_Datatype recvtypes[], MPI_Comm comm)
int MPI_Alltoallw_c(const void *sendbuf, const MPI_Count sendcounts[],
const MPI_Aint sdispls[], const MPI_Datatype sendtypes[],
void *recvbuf, const MPI_Count recvcounts[],
const MPI_Aint rdispls[], const MPI_Datatype recvtypes[],
MPI_Comm comm)
πΈ INPUT PARAMETERS πΈ
sendbufβ starting address of send buffer (choice)sendcountsβ a non-negative integer array (of length group size) that says how many elements you're sending to each rank (non-negative integer). bestie, every rank can get a different number. main character energy for real.sdisplsβ integer array (of length group size). entryjspecifies the displacement in bytes (relative tosendbuf) from which to take the outgoing data destined for processj(integer)sendtypesβ array of datatypes (of length group size). entryjspecifies the type of data to send to processj(handle). yes, a type per partner. we're spoiled fr fr.recvcountsβ non-negative integer array (of length group size) specifying the number of elements that can be received from each rank (non-negative integer)rdisplsβ integer array (of length group size). entryispecifies the displacement in bytes (relative torecvbuf) at which to place the incoming data from processi(integer)recvtypesβ array of datatypes (of length group size). entryispecifies the type of data received from processi(handle)commβ communicator (handle) π«Ά
π OUTPUT PARAMETERS π
recvbufβ address of receive buffer (choice)
π§ THREAD AND INTERRUPT SAFETY π§
this routine is thread-safe β¨ meaning you can safely call it from multiple threads without needing any user-provided thread locks. go off, multithreaded queen π
however β and this is the important part, so listen up β the routine is not interrupt safe. typically this is because it uses memory allocation routines such as malloc or other non-MPICH runtime routines that are themselves not interrupt-safe. so like, thread-safe? yes. interrupt-safe? no. we contain multitudes π
π NOTES FOR FORTRAN π
all MPI routines in Fortran (except for MPI_WTIME and MPI_WTICK) have an additional argument ierr at the end of the argument list. ierr is an integer and has the same meaning as the return value of the routine in C. in Fortran, MPI routines are subroutines, and are invoked with the call statement.
all MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. that's just how Fortran rolls, periodt. π
π ERRORS π
all MPI routines (except MPI_Wtime and MPI_Wtick) return an error value; C routines as the value of the function and Fortran routines in the last argument. before the value is returned, the current MPI error handler is called. by default, this error handler aborts the MPI job. π
the error handler may be changed with MPI_Comm_set_errhandler (for communicators), MPI_File_set_errhandler (for files), and MPI_Win_set_errhandler (for RMA windows). the MPI-1 routine MPI_Errhandler_set may be used but its use is deprecated (so like, don't). 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; however, MPI implementations will attempt to continue whenever possible. π«Ά
MPI_SUCCESSβ no error; MPI routine completed successfully. slay β¨MPI_ERR_BUFFERβ invalid buffer pointer. usually a null buffer where one is not valid. πMPI_ERR_COMMβ invalid communicator. a common error is to use a null communicator in a call (not even allowed inMPI_Comm_rank). not the null communicator bestie πMPI_ERR_COUNTβ invalid count argument. count arguments must be non-negative; a count of zero is often valid.MPI_ERR_TYPEβ invalid datatype argument. additionally, this error can occur if an uncommittedMPI_Datatype(seeMPI_Type_commit) is used in a communication call. commit your types, babe πMPI_ERR_OTHERβ other error; useMPI_Error_stringto get more information about this error code.
and that's the whole page, bestie!! π go forth and all-to-all with wildly different types per partner, you absolute legend ππ
this has been MPI_Alltoallw(3), part of the MPI manual, dated 4/10/2026 β mwah, love u, bye!! ππ¦
π¦ where this page comes from
- nixos 26.05: mpich 5.0.1
- ubuntu stonking: mpich-doc 5.0.1-9 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms