MPI_Iallreduce(3)

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

πŸ’– MPI_Iallreduce β€” the group chat "k everyone agree?" move πŸ’–

okay so bestie, welcome to the MPI manual, section 3 (that's library calls, for the uninitiated 🫢). This one's called MPI_Iallreduce, and it is literally the nonblocking glow-up of everybody's fave collective.


✨ NAME ✨

MPI_Iallreduce β€” combines values from all processes and distributes the result back to all processes, but in a nonblocking way πŸ’…

Like, it does the whole "everyone shouts their number, everyone gets the total" thing, except it does not make you wait around for it. You hand in your homework, you get a receipt (request), and you go live your life. Main character energy fr fr. πŸ‘‘


🌈 SYNOPSIS 🌈

int MPI_Iallreduce(const void *sendbuf, void *recvbuf, int count,
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm,
MPI_Request *request)

int MPI_Iallreduce_c(const void *sendbuf, void *recvbuf, MPI_Count count,
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm,
MPI_Request *request)

not one but TWO flavors, because why have one signature when you can have a _c variant with the big-girl MPI_Count count πŸŽ€


🌸 INPUT PARAMETERS 🌸

  • sendbuf β€” starting address of send buffer (choice). this is the thing you're putting in the potluck, bestie πŸ“
  • count β€” number of elements in send buffer (non-negative integer). non-negative!! we do not do negative counts in this house πŸ’€
  • datatype β€” data type of elements of send buffer (handle)
  • op β€” operation (handle) β€” the little spell you cast on the pile of everyone's values ✨
  • comm β€” communicator (handle) β€” aka the group chat itself πŸ‘―

πŸ¦‹ OUTPUT PARAMETERS πŸ¦‹

  • recvbuf β€” starting address of receive buffer (choice). where the combined result lands so everybody sees it 🫢
  • request β€” communication request (handle). your lil receipt, so you can check on it later 🧾

πŸ’œ 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 user-provided thread locks. no cap. πŸ”₯

But heads up: it is not interrupt safe. πŸ™ˆ Usually that's because it uses memory allocation routines like malloc, or other non-MPICH runtime routines, and those are themselves not interrupt-safe. so like, respecc the boundary.

⭐ NOTES FOR FORTRAN ⭐

All MPI routines in Fortran (except for MPI_WTIME and MPI_WTICK) get an extra argument ierr tacked onto the end of the argument list. ierr is an integer and it means exactly the 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. classic Fortran behaviour πŸ’…

All MPI objects (e.g. MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran.


πŸ’€ 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 that value comes back, the current MPI error handler gets called. By default, this error handler aborts the MPI job β€” like, the whole thing, gone, bye 😭

The error handler can 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 (we don't do that anymore, queen πŸ‘‘). 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. so, y'know, vibes permitting.

Here's the full roster of possible error codes:

  • MPI_SUCCESS β€” No error; MPI routine completed successfully. ate and left no crumbs ✨
  • 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_OP β€” Invalid operation. MPI operations (objects of type MPI_Op) must either be one of the predefined operations (e.g., MPI_SUM) or created with MPI_Op_create.
  • 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 πŸŽ€ go forth and reduce, nonblocking-ly πŸ’–

this lil love letter came to you from the MPI manual, dated 4/10/2026, filed under MPI_Iallreduce(3) 🫢 slay.
πŸ“¦ where this page comes from