MPI_Igather(3)

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

πŸ’– MPI_Igather β€” bestie edition πŸ’–

okay so this is a page from the MPI manual (section 3, function calls, iykyk) and it's all about MPI_Igather ✨


🌈 NAME 🌈

MPI_Igather β€” gathers together values from a group of processes in a nonblocking way 🫢

Like, everyone sends their lil values over to one root process, but it does NOT block you. main character energy fr fr.


✨ SYNOPSIS ✨

int MPI_Igather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype, int root,
MPI_Comm comm, MPI_Request *request)

int MPI_Igather_c(const void *sendbuf, MPI_Count sendcount,
MPI_Datatype sendtype, void *recvbuf, MPI_Count recvcount,
MPI_Datatype recvtype, int root, MPI_Comm comm,
MPI_Request *request)

🌸 INPUT PARAMETERS 🌸

the stuff you gotta hand over, no cap:

  • sendbuf β€” starting address of send buffer (choice)
  • sendcount β€” number of elements in send buffer (non-negative integer)
  • sendtype β€” data type of send buffer elements (handle)
  • recvcount β€” number of elements for any single receive (non-negative integer)
  • recvtype β€” data type of recv buffer elements (handle)
  • root β€” rank of receiving process (integer)
  • comm β€” communicator (handle)

πŸŽ€ OUTPUT PARAMETERS πŸŽ€

what comes back outta this thing:

  • recvbuf β€” address of receive buffer (choice)
  • request β€” communication request (handle)

πŸ¦‹ THREAD AND INTERRUPT SAFETY πŸ¦‹

okay so this routine is thread-safe πŸ’… β€” that means multiple threads can use it at the same time and you do NOT need to write your own thread locks, which is honestly so nice of it.

BUT. and this is a big but 😭 β€” the routine is not interrupt safe. typically 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, vibe check before you go interruptin', bestie.


⭐ 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 it 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.

all MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. that's just the lore, we don't make the rules πŸ’œ


πŸ”₯ ERRORS πŸ”₯

okay this part is lowkey important so listen up:

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 that 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 can be changed 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 be used but its use is deprecated ⚠️ (yes, deprecated, we're moving on).

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 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_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 thing, bestie πŸ₯° this page came from the MPI manual, dated 4/10/2026, under the title MPI_Igather(3) β€” so yeah, go forth and gather nonblockingly, you absolute icon πŸ‘‘βœ¨

πŸ“¦ where this page comes from