MPI_Neighbor_alltoallv(3)

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

πŸ’– 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 length outdegree) telling you how many elements go out to each neighbor (non-negative integer)
  • sdispls β€” integer array (of length outdegree). Entry j says where the outgoing data to neighbor j lives, as a displacement relative to sendbuf (integer)
  • sendtype β€” data type of the send buffer elements (handle)
  • recvcounts β€” non-negative integer array (of length indegree) telling you how many elements get received from each neighbor (non-negative integer)
  • rdispls β€” integer array (of length indegree). Entry i says where the incoming data from neighbor i gets placed, as a displacement relative to recvbuf (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 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. additionally, this error can occur if an uncommitted MPI_Datatype (see MPI_Type_commit) is used in a communication call.
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to 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