MPI_Neighbor_alltoall(3)

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

πŸ’« 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_WTIME and MPI_WTICK) gets an extra argument ierr tacked onto the end of the argument list. ierr is 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 call statement. very demure, very mindful.
  • all MPI objects (like MPI_Datatype, MPI_Comm) are of type INTEGER in 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 in MPI_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 uncommitted MPI_Datatype (see MPI_Type_commit) is used in a communication call β€” so commit your types, iykyk.
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to 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