MPI_Neighbor_alltoallv(3)
π MPI_Neighbor_alltoallv(3) π
okay bestie, gather round, because today we're learning the vector variant of MPI_Neighbor_alltoall, and she is serving π
. This one lets you send and receive different numbers of elements to and from each neighbor. Yes, each one gets her own custom amount. main character energy fr fr.
This is from the MPI manual, section 3, if you were wondering. iykyk.
β¨ SYNOPSIS β¨
like, here's the whole squad of arguments π«Ά:
int MPI_Neighbor_alltoallv(const void *sendbuf, const int sendcounts[],
const int sdispls[], MPI_Datatype sendtype,
void *recvbuf, const int recvcounts[],
const int rdispls[], MPI_Datatype recvtype,
MPI_Comm comm)
and because we're extra, there's also the big-count version:
int MPI_Neighbor_alltoallv_c(const void *sendbuf, const MPI_Count sendcounts[],
const MPI_Aint sdispls[], MPI_Datatype sendtype,
void *recvbuf, const MPI_Count recvcounts[],
const MPI_Aint rdispls[], MPI_Datatype recvtype,
MPI_Comm comm)
πΈ INPUT PARAMETERS πΈ
sendbufβ the starting address of the send buffer (a choice, bestie)sendcountsβ non-negative integer array (of lengthoutdegree) telling you how many elements go out to each neighbor (non-negative integer)sdisplsβ integer array (of lengthoutdegree). Entryjsays where the outgoing data to neighborjlives, as a displacement relative tosendbuf(integer)sendtypeβ data type of the send buffer elements (handle)recvcountsβ non-negative integer array (of lengthindegree) telling you how many elements get received from each neighbor (non-negative integer)rdisplsβ integer array (of lengthindegree). Entryisays where the incoming data from neighborigets placed, as a displacement relative torecvbuf(integer)recvtypeβ data type of the receive buffer elements (handle)commβ communicator with topology structure (handle)
π OUTPUT PARAMETERS π
recvbufβ starting address of the receive buffer (a choice)
π₯ THREAD AND INTERRUPT SAFETY π₯
okay so the good news: this routine is thread-safe β¨. that literally means multiple threads can use it at the same time and you don't have to bring your own thread locks, no cap.
the bad news: she is not interrupt safe π. typically that's because of memory allocation routines like malloc or other non-MPICH runtime routines that are themselves not interrupt-safe. so yeah. not the vibe for interrupts.
π NOTES FOR FORTRAN π
every MPI routine in Fortran (except for MPI_WTIME and MPI_WTICK, the little rebels) has an extra argument ierr chillin' 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. and in Fortran, MPI routines are subroutines and you invoke them with the call statement. periodt.
also! all MPI objects (like MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. keep that in mind π
.
π ERRORS π
so every MPI routine (except MPI_Wtime and MPI_Wtick) returns an error value β C routines as the value of the function, and Fortran routines in the last argument. before that value comes back, the current MPI error handler gets called. by default, this error handler aborts the MPI job π« . dramatic, i know.
you can change the error handler 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 (big yikes, don't do it). and the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned instead.
heads up bestie: MPI does not guarantee that an MPI program can continue past an error. however, MPI implementations will attempt to continue whenever possible. so like. maybe. π
here's the whole error roster:
MPI_SUCCESSβ no error; the MPI routine completed successfully. slay β¨MPI_ERR_BUFFERβ invalid buffer pointer. usually a null buffer where one is not valid.MPI_ERR_COMMβ invalid communicator. a common error is using a null communicator in a call (which is 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 page bestie!! go forth and alltoallv responsibly πβ¨ππ¦πΈ
okay love u, bye!! this was the MPI_Neighbor_alltoallv(3) page from the MPI docs, dated 4/10/2026 π
no cap, that's literally the version info. mwah π«Ά
π¦ 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