MPI_Allgatherv_init(3)

πŸ’– MPI_Allgatherv_init πŸ’–

okay bestie, so this page is MPI_Allgatherv_init(3) from the MPI manual, and it's literally the glow-up version of allgatherv: instead of doing the whole dance every single time, you set it up once as a persistent request and then just keep reusing it. obsessssed. πŸŽ€


✨ NAME ✨

MPI_Allgatherv_init β€” Create a persistent request for allgatherv. πŸ’…

no cap, that's the whole vibe: it creates a persistent request for allgatherv. it does not do the gathering, it sets you up so you can do the gathering again and again. main character energy fr.


🌸 SYNOPSIS 🌸

C version:

int MPI_Allgatherv_init(const void *sendbuf, int sendcount,
MPI_Datatype sendtype, void *recvbuf,
const int recvcounts[], const int displs[],
MPI_Datatype recvtype, MPI_Comm comm, MPI_Info info,
MPI_Request *request)

and the big-number girlie version, _c, for when your counts and displacements are simply Too Much for plain int:

int MPI_Allgatherv_init_c(const void *sendbuf, MPI_Count sendcount,
MPI_Datatype sendtype, void *recvbuf,
const MPI_Count recvcounts[], const MPI_Aint displs[],
MPI_Datatype recvtype, MPI_Comm comm, MPI_Info info,
MPI_Request *request)

πŸ¦‹ INPUT PARAMETERS πŸ¦‹

  • sendbuf β€” starting address of send buffer (choice). this is the stuff you're sending out into the world πŸ’Œ
  • sendcount β€” number of elements in send buffer (non-negative integer). must be >= 0, no negativity allowed in this house
  • sendtype β€” data type of send buffer elements (handle)
  • recvcounts β€” non-negative integer array (of length group size) containing the number of elements that are received from each process (non-negative integer). one slot per process bestie, and slot i tells you how much process i is sending you
  • displs β€” integer array (of length group size). Entry i specifies the displacement (relative to recvbuf) at which to place the incoming data from process i (integer). it's the seating chart fr, everyone gets their assigned spot πŸͺ‘
  • recvtype β€” data type of receive buffer elements (handle)
  • comm β€” communicator (handle)
  • info β€” info argument (handle)

πŸŽ€ OUTPUT PARAMETERS πŸŽ€

  • recvbuf β€” address of receive buffer (choice)
  • request β€” communication request (handle). this is the persistent request you just birthed, keep it safe ✨

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

This routine is thread-safe. slay. that means this routine may be safely used by multiple threads without the need for any user-provided thread locks. let the threads cook, no extra locking needed 🫢

⚠️ BUT. However. The routine is not interrupt safe. πŸ’€ Typically, this is due to the use of memory allocation routines such as malloc or other non-MPICH runtime routines that are themselves not interrupt-safe. so like, don't go interrupting it mid-malloc, that's the tea.

🌈 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 has the same meaning as the return value of the routine in C. it's giving "same energy, different outfit". ✨

In Fortran, MPI routines are subroutines, and they are invoked with the call statement. so: call. iconic behavior.

All MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. periodt. πŸ’…


😭 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 the value is returned, the current MPI error handler is called. By default, this error handler aborts the MPI job. not dramatic at all, it just ends everything 😭

The error handler may 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 bestie, it's giving 1994. πŸ™ˆ

The predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned. Note that MPI does not guarantee that an MPI program can continue past an error; however, MPI implementations will attempt to continue whenever possible. fingers crossed fr fr.

Here's the lineup of error codes, no gatekeeping:

  • MPI_SUCCESS β€” No error; MPI routine completed successfully. we LOVE to see it πŸ’–
  • 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. the classic null moment πŸ’€
  • MPI_ERR_COMM β€” Invalid communicator. A common error is to use a null communicator in a call (not even allowed in MPI_Comm_rank). like, even MPI_Comm_rank said no thanks.
  • MPI_ERR_COUNT β€” Invalid count argument. Count arguments must be non-negative; a count of zero is often valid. zero is fine, negative is not, we do not tolerate negativity here ✨
  • 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. commit your types, bestie, don't send them out uncommitted πŸŽ€
  • MPI_ERR_OTHER β€” Other error; use MPI_Error_string to get more information about this error code. the mysterious one, go read its diary via MPI_Error_string

and that's the whole page, bestie, you ate it πŸ’…βœ¨

this was MPI_Allgatherv_init(3) from the MPI manual, dated 4/10/2026 β€” go forth and make some persistent requests, you've got this 🫢🌸

πŸ“¦ where this page comes from