MPI_Ialltoall(3)

πŸ“¦
version 5.0.1 Β· 5 versions
, in nixos 26.05, ubuntu stonking

πŸ’– MPI_Ialltoall πŸ’– (the MPI_Ialltoall(3) page, bestie)

okay so picture this: everyone in the group chat needs to send something to everyone else, all at the same time, and nobody wants to sit around waiting for their turn. that's MPI_Ialltoall. the "I" stands for "I am NOT blocking, I promise" ✨


🌸 NAME 🌸

MPI_Ialltoall β€” sends data from all to all processes in a nonblocking way πŸ¦‹

like, literally all-to-all. everyone sends, everyone receives, nobody blocks. it's giving democracy. it's giving ✨horizontal communication✨


πŸŽ€ SYNOPSIS πŸŽ€

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_Ialltoall_c(const void *sendbuf, MPI_Count sendcount,
MPI_Datatype sendtype, void *recvbuf, MPI_Count recvcount,
MPI_Datatype recvtype, MPI_Comm comm, MPI_Request *request)

yep, there's a _c version too β€” it's the same vibe but with the big-girl MPI_Count types instead of plain int. πŸ’…


πŸ’Œ INPUT PARAMETERS πŸ’Œ

  • sendbuf β€” starting address of send buffer (choice). this is where your stuff lives before it goes out into the world 🫢
  • sendcount β€” number of elements sent to each process (non-negative integer). note: to each process, not total. do not fumble this one bestie 😭
  • 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). the group chat itself πŸ’¬

🫢 OUTPUT PARAMETERS 🫢

  • recvbuf β€” address of receive buffer (choice). where all the incoming goodies land πŸ“
  • request β€” communication request (handle). keep this!! you'll need it later. it's your ticket to the finish line 🎟️

πŸ”₯ THREAD AND INTERRUPT SAFETY πŸ”₯

this routine is thread-safe. translation: multiple threads can use it at the same time and you do not need to bring your own thread locks. no gatekeeping, no drama. πŸ‘‘

however β€” and this is the part where I hold your hand β€” it is not interrupt safe. usually that's because of memory allocation routines like malloc or other non-MPICH runtime routines that are themselves not interrupt-safe. so like, respect the boundary. πŸ™ˆ


πŸ’œ NOTES FOR FORTRAN πŸ’œ

okay Fortran girlies, listen up:

  • every MPI routine in Fortran (except MPI_WTIME and MPI_WTICK) has an extra argument ierr tacked onto the end of the argument list. ierr is an integer and means the exact same thing as the return value of the routine in C. 🎯
  • in Fortran, MPI routines are subroutines, and you invoke them with the call statement. iconic. old school. correct. ⭐
  • all MPI objects (like MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. that's just the rules bestie πŸ’…

😭 ERRORS 😭

every MPI routine (except MPI_Wtime and MPI_Wtick) returns an error value β€” C routines as the value of the function, Fortran routines in that last argument. before the value comes back, the current MPI error handler gets called. by default, that error handler aborts the MPI job. 😳 yes, aborts. like, pull the plug.

you can swap the error handler with:

  • MPI_Comm_set_errhandler β€” for communicators
  • MPI_File_set_errhandler β€” for files
  • MPI_Win_set_errhandler β€” for RMA windows

the MPI-1 routine MPI_Errhandler_set may also be used, but its use is deprecated β€” like wearing low-rise jeans in 2026, technically possible, not recommended. πŸ’€

the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned instead. note that MPI does not guarantee that an MPI program can continue past an error; however, MPI implementations will attempt to continue whenever possible. 🀞

here's the error menu:

  • MPI_SUCCESS β€” no error; MPI routine completed successfully. slay. ✨
  • 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 in MPI_Comm_rank). πŸ’€
  • MPI_ERR_COUNT β€” invalid count argument. count arguments must be non-negative; a count of zero is often valid. 0️⃣
  • MPI_ERR_TYPE β€” invalid datatype argument. additionally, this error can occur if an uncommitted MPI_Datatype (see MPI_Type_commit) is used in a communication call. 🎭
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to get more information about this error code. πŸ”

fr fr bestie, remember: MPI_Ialltoall is nonblocking, so the moment it returns you have a request and the work is still happening. don't touch that buffer until you've waited on it. no cap. πŸ™

and that's the whole page, diva. πŸ’– this was MPI_Ialltoall(3), from the MPI manual, dated 4/10/2026. go forth and all-to-all, you absolute legend. πŸŽ€βœ¨πŸ¦‹πŸ’…πŸ‘‘

πŸ“¦ where this page comes from