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_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 they're invoked with the call statement.
  • All MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in 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 in MPI_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 Info
  • 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.

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