MPI_Allgatherv(3)

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

πŸ’– MPI_Allgatherv β€” the gossip ring but make it data πŸ’…

okay so bestie, welcome to the MPI_Allgatherv(3) page from the MPI manual. this is the one where literally everybody in the group chat gets everything. no secrets, no crumbs, all tea shared with the whole squad ✨

✨ NAME ✨

MPI_Allgatherv β€” gathers data from all tasks and delivers the combined data to all tasks 🫢

like... everyone sends, everyone receives. it's giving "no private messages, only the group chat" energy. periodt.


πŸ“œ SYNOPSIS πŸ“œ

int MPI_Allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, const int recvcounts[], const int displs[],
MPI_Datatype recvtype, MPI_Comm comm)

int MPI_Allgatherv_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)

yes bestie there's a _c version too, for when your counts are big big. she's the same girl, just with MPI_Count and MPI_Aint instead πŸ‘‘


🌸 INPUT PARAMETERS 🌸

  • sendbuf β€” starting address of send buffer (choice). where your lil contribution lives πŸ’Œ
  • sendcount β€” number of elements in send buffer (non-negative integer). how many things you're handing out, and no, it can't be negative, that's not a vibe πŸ’€
  • sendtype β€” data type of send buffer elements (handle). what kind of little guys you're sending πŸŽ€
  • recvcounts β€” non-negative integer array (of length group size) containing the number of elements that are received from each process (non-negative integer). so like, one number per bestie telling you how much they're bringing to the function 🧚
  • 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). basically the seat assignment. entry i = where process i's data gets to sit ✨
  • recvtype β€” data type of receive buffer elements (handle). the type of the lil guys coming IN 🌈
  • comm β€” communicator (handle). the group chat itself, the whole squad 🫢

πŸ’– OUTPUT PARAMETERS πŸ’–

  • recvbuf β€” address of receive buffer (choice). where all the collected tea gets poured 😭

πŸ“ NOTES πŸ“

okay so this part is messy and we need to talk about it.

the MPI standard (1.0 and 1.1) says that:

The jth block of data sent from each process is received by every process and placed in the jth block of the buffer recvbuf .

...and like, that's misleading, fr fr. the better description is:

The block of data sent from the jth process is received by every process and placed in the jth block of the buffer recvbuf .

see the difference? it's the jth process, not the jth block. huge. iconic correction. the way that one word changes everything 😭

this text was suggested by Rajeev Thakur, and has been adopted as a clarification to the MPI standard by the MPI-Forum. shoutout Rajeev, you ate πŸ‘‘


🧡 THREAD AND INTERRUPT SAFETY 🧡

this routine is thread-safe ✨ which means you can safely use it from multiple threads, no user-provided thread locks required, she handles herself πŸ’…

BUT. and this is a big but bestie β€” 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 interrupt her mid-glow-up, she's not built for that πŸ™ˆ


πŸŽ€ 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. In Fortran, MPI routines are subroutines, and are invoked with the call statement. so Fortran besties get one extra lil guy at the end 🫢
  • All MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. no fancy handle types over there, just plain ol' INTEGER ✨

πŸ’€ 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 😭 so yeah. dramatic. no cap.

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 ⚠️ so like, she's old news, don't text her back.

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. she'll try her best, but no promises πŸ’…

here's the error code roster:

  • MPI_SUCCESS β€” No error; MPI routine completed successfully. ate and left no crumbs βœ…
  • MPI_ERR_BUFFER β€” Invalid buffer pointer. Usually a null buffer where one is not valid. you showed up empty-handed bestie πŸ’€
  • MPI_ERR_COMM β€” Invalid communicator. A common error is to use a null communicator in a call (not even allowed in MPI_Comm_rank). the group chat doesn't exist 😭
  • 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 πŸ™ˆ
  • 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. she's not ready yet, let her commit first πŸŽ€
  • MPI_ERR_OTHER β€” Other error; use MPI_Error_string to get more information about this error code. the mystery box, go ask MPI_Error_string 🌸

reminder bestie: hitting an error by default aborts the whole job. if you want the errors returned instead of the whole thing going down, set MPI_ERRORS_RETURN. protect your peace 🫢

and that's the page!! this was MPI_Allgatherv(3) from the MPI manual, dated 4/10/2026, last updated before I stole her and gave her a personality πŸ’…βœ¨

stay gathered, stay v'd, and remember: everybody gets everybody's tea. that's the whole point. πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from