MPI_Alltoall_init(3)
π MPI_Alltoall_init β bestie edition π
okay so this is a page from the MPI manual (section 3, the library-calls girlies), and today we're doing MPI_Alltoall_init. get comfy, grab a strawberry, we're gonna make a persistent request for alltoall and it's gonna be so cute.
β¨ NAME β¨
MPI_Alltoall_init β Create a persistent request for alltoall.
that's it. that's the whole vibe. a persistent request. for alltoall. she's lowkey iconic for that ngl π
πΈ SYNOPSIS πΈ
the C girlies get two flavors β the regular one and the big-count one:
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)
int MPI_Alltoall_init_c(const void *sendbuf, MPI_Count sendcount,
MPI_Datatype sendtype, void *recvbuf,
MPI_Count recvcount, MPI_Datatype recvtype,
MPI_Comm comm, MPI_Info info, MPI_Request *request)
yes bestie, MPI_Alltoall_init_c is out here with MPI_Count counts instead of plain int, like a main character who sized up. π
π INPUT PARAMETERS π
everything you gotta hand over, one by one:
sendbufβ starting address of send buffer (choice).sendcountβ number of elements sent to each process (non-negative integer). note the "to each process" bestie, she's a gossip, everybody gets a copy π«Άsendtypeβ data type of send buffer elements (handle).recvcountβ number of elements received from any process (non-negative integer).recvtypeβ data type of receive buffer elements (handle).commβ communicator (handle).infoβ info argument (handle).
π¦ OUTPUT PARAMETERS π¦
what she hands back to you:
recvbufβ address of receive buffer (choice).requestβ communication request (handle).
π₯ THREAD AND INTERRUPT SAFETY π₯
okay so this routine is thread-safe. meaning: multiple threads can use it safely, and you do not need to bring your own thread locks. no gatekeeping, no drama, she's chill like that. π
BUT. (there's always a but π) the routine is not interrupt safe. typically this is because of memory allocation routines like malloc or other non-MPICH runtime routines that are themselves not interrupt-safe. so like, thread-safe bestie, not interrupt-safe bestie. two different things. don't mix them up. π
π NOTES FOR FORTRAN π
Fortran girlies, listen up, this part is for you:
- All MPI routines in Fortran (except for
MPI_WTIMEandMPI_WTICK) have an additional argumentierrat the end of the argument list.ierris an integer and has the same meaning as the return value of the routine in C. - In Fortran, MPI routines are subroutines, and they're invoked with the
callstatement. - All MPI objects (e.g.,
MPI_Datatype,MPI_Comm) are of typeINTEGERin Fortran.
so ierr is just the C return value, but wearing a little Fortran hat. periodt. π©
π ERRORS π
every MPI routine (except MPI_Wtime and MPI_Wtick) returns an error value β C routines as the value of the function, and Fortran routines in that last argument. before the value comes back, the current MPI error handler is called.
β οΈ by default this error handler aborts the MPI job. like, full stop. not a drill. π³
you can swap that handler out 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 (we don't stan, bestie π).
the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned instead.
also: MPI does not guarantee that an MPI program can continue past an error. however, MPI implementations will attempt to continue whenever possible. so likeβ¦ hope for the best? πΈ
here's the error-code lineup:
MPI_SUCCESSβ No error; MPI routine completed successfully. πMPI_ERR_ARGβ Invalid argument. Some argument is invalid and is not identified by a specific error class (e.g.,MPI_ERR_RANK).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).MPI_ERR_COUNTβ Invalid count argument. Count arguments must be non-negative; a count of zero is often valid.MPI_ERR_INFOβ Invalid InfoMPI_ERR_TYPEβ Invalid datatype argument. Additionally, this error can occur if an uncommittedMPI_Datatype(seeMPI_Type_commit) is used in a communication call.MPI_ERR_OTHERβ Other error; useMPI_Error_stringto get more information about this error code.
and that's the whole page bestie, every flag, every handle, every error code, all accounted for, no cap β¨
okay bye, go build something persistent, ily π«Άπ
mwah π β this page is from the MPI manual, MPI_Alltoall_init(3), dated 4/10/2026.
π¦ 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