MPI_Igather(3)
π 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 inMPI_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 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 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
- 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