MPI_Neighbor_alltoall(3)
π« MPI_Neighbor_alltoall(3) β the MPI manual, but make it slay π«
okay bestie, so this is a page from the MPI manual β section 3, the library calls β and it's all about MPI_Neighbor_alltoall. grouping chat energy only, but the facts are keeping their full main character status, no cap π
β¨ NAME β¨
MPI_Neighbor_alltoall β sends and receives data from all neighboring processes π¦ (the original says "Receivs" and honestly? iconic typo, we're keeping the vibe, the meaning is the same: you send, you receive, everybody eats)
πΈ SYNOPSIS πΈ
int MPI_Neighbor_alltoall(const void *sendbuf, int sendcount,
MPI_Datatype sendtype, void *recvbuf, int recvcount,
MPI_Datatype recvtype, MPI_Comm comm)
int MPI_Neighbor_alltoall_c(const void *sendbuf, MPI_Count sendcount,
MPI_Datatype sendtype, void *recvbuf,
MPI_Count recvcount, MPI_Datatype recvtype,
MPI_Comm comm)
like look at her, two whole signatures, one classic and one _c version for when your counts are Big π
π INPUT PARAMETERS π
the stuff you gotta hand over, bestie:
sendbufβ the starting address of your send buffer (a choice, so, your pick)sendcountβ how many elements you're sending to each neighbor (a non-negative integer, so zero and up, no negatives allowed π)sendtypeβ the data type of the elements in your send buffer (a handle)recvcountβ how many elements you're receiving from each neighbor (also a non-negative integer, same rules)recvtypeβ the data type of the elements in your receive buffer (a handle)commβ the communicator, which has to have topology structure (a handle)
π«Ά OUTPUT PARAMETERS π«Ά
the one thing that comes back out:
recvbufβ the starting address of your receive buffer (also a choice)
π₯ NOTES π₯
okay so here's the tea π΅ β in this function, every process i receives data items from every process j if an edge (j,i) exists in the topology graph or Cartesian topology. and like, symmetrically, each process i sends data items to all processes j where an edge (i,j) exists.
this call is more general than MPI_NEIGHBOR_ALLGATHER, because with this one you can send different data items to each neighbor β not just the same thing to everyone, we love range β¨
and the mapping? the k-th block in the send buffer goes to the k-th neighboring process, and the l-th block in the receive buffer comes in from the l-th neighbor. so like, index your blocks and your neighbors line up, periodt.
π THREAD AND INTERRUPT SAFETY π
this routine is thread-safe β meaning you can safely call it from multiple threads without needing any user-provided thread locks. yes queen, go parallel, no babysitting required π
BUT β it is not interrupt safe. typically that's because of memory allocation routines like malloc, or other non-MPICH runtime routines, which are themselves not interrupt-safe. so like, threads yes, interrupts no, okurrr β οΈ
π NOTES FOR FORTRAN π
- every MPI routine in Fortran (except
MPI_WTIMEandMPI_WTICK) gets an extra argumentierrtacked onto the end of the argument list.ierris an integer and it means exactly the same thing as the return value of the routine in C. - in Fortran, MPI routines are subroutines, invoked with the
callstatement. very demure, very mindful. - all MPI objects (like
MPI_Datatype,MPI_Comm) are of typeINTEGERin Fortran. that's just the way it is π§
π ERRORS π
okay so every MPI routine (except MPI_Wtime and MPI_Wtick) returns an error value β C routines as the value of the function, Fortran routines in that last argument. before the value comes back, the current MPI error handler gets called. by default, this error handler aborts the MPI job π so yeah, dramatic consequences, be aware.
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 also be used, but its use is deprecated β like, retired, don't make it happen π
the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned instead. also important: MPI does not guarantee that an MPI program can continue past an error β however, MPI implementations will attempt to continue whenever possible. fingers crossed bestie π€
here's the error code lineup:
MPI_SUCCESSβ no error, the MPI routine completed successfully. we love a clean run β¨MPI_ERR_BUFFERβ invalid buffer pointer. usually a null buffer where one is not valid. bestie. don't pass null. πMPI_ERR_COMMβ invalid communicator. a common mistake is using a null communicator in a call (which isn't 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. also, this error can happen if an uncommittedMPI_Datatype(seeMPI_Type_commit) is used in a communication call β so commit your types, iykyk.MPI_ERR_OTHERβ other error; useMPI_Error_stringto get more information about this error code.
and that's the whole page, bestie π no skips, no summaries, every flag and error code present and accounted for, we ate and left no crumbs π
this was page MPI_Neighbor_alltoall(3) from the MPI manual, dated 4/10/2026 β mwah, take care of her, love you bye ππΈπ¦
π¦ 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