MPI_Scatterv_init(3)

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

πŸ’« NAME πŸ’«

MPI_Scatterv_init β€” bestie, this one creates a persistent request for scatterv. It's the "set it up once, reuse it forever" era. πŸ‘‘


✨ SYNOPSIS ✨

int MPI_Scatterv_init(const void *sendbuf, const int sendcounts[],
       const int displs[], MPI_Datatype sendtype, void *recvbuf,
       int recvcount, MPI_Datatype recvtype, int root,
       MPI_Comm comm, MPI_Info info, MPI_Request *request)

int MPI_Scatterv_init_c(const void *sendbuf, const MPI_Count sendcounts[],
       const MPI_Aint displs[], MPI_Datatype sendtype,
       void *recvbuf, MPI_Count recvcount,
       MPI_Datatype recvtype, int root, MPI_Comm comm,
       MPI_Info info, MPI_Request *request)

Two flavors, same vibe πŸ’… β€” the plain one with int counts and the _c one with the big MPI_Count / MPI_Aint energy.


🌸 INPUT PARAMETERS 🌸

These are the things you hand over, no take-backs:

  • sendbuf β€” address of send buffer (choice). Where the good stuff lives that you're shipping out πŸ“¦
  • sendcounts β€” non-negative integer array (of length group size) specifying the number of elements to send to each rank (non-negative integer). Like a little guest list: how much each rank gets πŸŽ€
  • displs β€” integer array (of length group size). Entry i specifies the displacement (relative to sendbuf) from which to take the outgoing data to process i (integer). Basically the GPS coordinates of each rank's slice πŸ—ΊοΈ
  • sendtype β€” data type of send buffer elements (handle)
  • recvcount β€” number of elements in receive buffer (non-negative integer)
  • recvtype β€” data type of receive buffer elements (handle)
  • root β€” rank of sending process (integer). The main character doing the sending πŸ‘‘
  • comm β€” communicator (handle)
  • info β€” info argument (handle)

πŸŽ€ OUTPUT PARAMETERS πŸŽ€

What you get back, and honestly? worth it:

  • recvbuf β€” address of receive buffer (choice)
  • request β€” communication request (handle). Hold onto this, you'll need it later fr fr

πŸ’– THREAD AND INTERRUPT SAFETY πŸ’–

This routine is thread-safe. Periodt. That means it may be safely used by multiple threads without the need for any user-provided thread locks. Slay πŸ’…

But β€” and stay with me β€” 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 no Ctrl+C shenanigans mid-call, bestie 😭


🧚 NOTES FOR FORTRAN 🧚

Okay so, 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 they're invoked with the call statement. Very demure, very Fortran πŸ™ˆ

Also: all MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. That's just how it is over there πŸ¦‹


πŸ”₯ 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 like... yeah, it's giving final boss.

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 β€” old news, we don't do that anymore πŸ’€. 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 🀞

And here's the full error menu:

  • 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.
  • MPI_ERR_COMM β€” Invalid communicator. A common error is to use a null communicator in a call (not even allowed in MPI_Comm_rank). Not even allowed!! 😭
  • MPI_ERR_COUNT β€” Invalid count argument. Count arguments must be non-negative; a count of zero is often valid.
  • 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 🫢
  • MPI_ERR_OTHER β€” Other error; use MPI_Error_string to get more information about this error code.

🌟 SEE ALSO vibes check: this page lives in the MPI manual, so peek at the other MPI pages when you need them.

Okay that's the whole tea, bestie πŸ’œ This was MPI_Scatterv_init(3) from the MPI manual, and this particular glow-up is dated 4/10/2026 β€” the MPI_Scatterv_init(3) of record, archived and iconic. Go forth and scatter, persistently. βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from