MPI_Neighbor_alltoallw(3)
π MPI_Neighbor_alltoallw π
okay so bestie, welcome to the MPI manual page for MPI_Neighbor_alltoallw β yes it's a whole mouthful, yes you're gonna slay it. It's the glow-up version of MPI_Neighbor_alltoallv, except it lets you send and receive with different types to and from each of your neighbors. it's giving bespoke gifting energy, fr fr πβ¨
πΈ NAME πΈ
MPI_Neighbor_alltoallw β like MPI_Neighbor_alltoallv but it allows one to send and receive with different types to and from each neighbor. no cap.
β¨ SYNOPSIS β¨
int MPI_Neighbor_alltoallw(const void *sendbuf, const int sendcounts[],
const MPI_Aint sdispls[],
const MPI_Datatype sendtypes[], void *recvbuf,
const int recvcounts[], const MPI_Aint rdispls[],
const MPI_Datatype recvtypes[], MPI_Comm comm)
int MPI_Neighbor_alltoallw_c(const void *sendbuf, const MPI_Count sendcounts[],
const MPI_Aint sdispls[],
const MPI_Datatype sendtypes[], void *recvbuf,
const MPI_Count recvcounts[],
const MPI_Aint rdispls[],
const MPI_Datatype recvtypes[], MPI_Comm comm)
two flavors, one vibe check π
(yes there's a _c variant, she's the big-count girlie)
π§ INPUT PARAMETERS π§
sendbufβ starting address of send buffer (choice). the place your little outgoing gifts live π«Άsendcountsβ non-negative integer array (of lengthoutdegree) specifying the number of elements to send to each neighbor (non-negative integer). one number per neighbor, no skipping βsdisplsβ integer array (of lengthoutdegree). Entryjspecifies the displacement in bytes (relative tosendbuf) from which to take the outgoing data destined for neighborj(integer). yes babe, bytes, not elements β read it twice πsendtypesβ array of datatypes (of lengthoutdegree). Entryjspecifies the type of data to send to neighborj(handle). everybody gets their own customized type, iconic πrecvcountsβ non-negative integer array (of lengthindegree) specifying the number of elements that are received from each neighbor (non-negative integer)rdisplsβ integer array (of lengthindegree). Entryispecifies the displacement in bytes (relative torecvbuf) at which to place the incoming data from neighbori(integer)recvtypesβ array of datatypes (of lengthindegree). Entryispecifies the type of data received from neighbori(handle)commβ communicator with topology structure (handle). it's gotta have that topology setup, otherwise this whole neighbor thing makes zero sense πΊοΈ
π OUTPUT PARAMETERS π
recvbufβ starting address of receive buffer (choice). this is where all the incoming bestie mail lands π¬
π₯ THREAD AND INTERRUPT SAFETY π₯
This routine is thread-safe. Translation: multiple threads can use it at the same time with zero need for any user-provided thread locks. she's self-sufficient, she doesn't need you hovering π
BUT β and this is the important part, don't skip it β 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, thread-safe yes, interrupt-safe no, they're different things, iykyk π
π 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.
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 β like, entire job, gone, that's not a drill π
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, please move on bestie). 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.
here's the full roster of error codes, all of them, no skips:
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. bestie why is itNULLπMPI_ERR_COMMβ Invalid communicator. A common error is to use a null communicator in a call (not even allowed inMPI_Comm_rank). genuinely not even allowed, not a jokeMPI_ERR_COUNTβ Invalid count argument. Count arguments must be non-negative; a count of zero is often valid. zero is fine, negative is a crime π«MPI_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, they're not gonna commit themselves πMPI_ERR_OTHERβ Other error; useMPI_Error_stringto get more information about this error code. the mystery box of errors π¦
okay that's the whole page, you're officially educated ππ this masterpiece of a manual page comes from MPI, dated 4/10/2026, and it lives at MPI_Neighbor_alltoallw(3). go send some differently-typed data to your neighbors, you absolute legend π¦β¨π
π¦ 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