MPI_Scatterv_init(3)
π« 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). Entryispecifies the displacement (relative tosendbuf) from which to take the outgoing data to processi(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 inMPI_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 InfoMPI_ERR_TYPEβ Invalid datatype argument. Additionally, this error can occur if an uncommittedMPI_Datatype(seeMPI_Type_commit) is used in a communication call. Commit your types, bestie π«ΆMPI_ERR_OTHERβ Other error; useMPI_Error_stringto 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
- 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