MPI_Neighbor_alltoallw_init(3)

πŸ’– MPI_Neighbor_alltoallw_init πŸ’–

okay bestie, so this is a page from the MPI manual set β€” MPI_Neighbor_alltoallw_init(3), section 3. Pull up a chair, we're doing persistent neighbor communication today and honestly? iconic.


✨ NAME ✨

MPI_Neighbor_alltoallw_init β€” she creates a persistent request for neighbor_alltoallw. That's it, that's the whole job. πŸ‘‘


🌸 SYNOPSIS 🌸

The C version, looking all fancy:

int MPI_Neighbor_alltoallw_init(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,
MPI_Info info, MPI_Request *request)

And the big-count sibling, for when your counts are MPI_Count sized and you're feeling extra:

int MPI_Neighbor_alltoallw_init_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,
MPI_Info info, MPI_Request *request)

🫢 INPUT PARAMETERS 🫢

These are the things you hand over, okay bestie, don't forget a single one:

  • sendbuf β€” the starting address of the send buffer (choice).
  • sendcounts β€” a non-negative integer array, length equals outdegree, telling us how many elements go to each neighbor (non-negative integer).
  • sdispls β€” integer array, length outdegree. Entry j says the displacement in bytes, relative to sendbuf, where the outgoing data destined for neighbor j gets taken from (integer).
  • sendtypes β€” array of datatypes, length outdegree. Entry j = the type of data you're sending to neighbor j (handle).
  • recvcounts β€” non-negative integer array, length indegree, saying how many elements get received from each neighbor (non-negative integer).
  • rdispls β€” integer array, length indegree. Entry i says the displacement in bytes, relative to recvbuf, where the incoming data from neighbor i gets placed (integer).
  • recvtypes β€” array of datatypes, length indegree. Entry i = the type of data received from neighbor i (handle).
  • comm β€” communicator that has a topology structure (handle).
  • info β€” info argument (handle).

πŸ’… OUTPUT PARAMETERS πŸ’…

The stuff that comes back to you:

  • recvbuf β€” the starting address of the receive buffer (choice).
  • request β€” communication request (handle).

🧡 THREAD AND INTERRUPT SAFETY 🧡

This routine is thread-safe, periodt. That means multiple threads can use it at the same time and you don't gotta provide any thread locks yourself. πŸŽ€

⚠️ But no cap β€” she is not interrupt safe. Typically that's because of memory allocation routines like malloc or other non-MPICH runtime routines, and those cuties are themselves not interrupt-safe. So like, thread-safe yes, interrupt-safe no, don't mix those up bestie. 😭

πŸ¦‹ NOTES FOR FORTRAN πŸ¦‹

All MPI routines in Fortran (except for MPI_WTIME and MPI_WTICK) get one extra argument: ierr, tacked onto the end of the argument list. ierr is an integer and means the same thing as the return value of the routine in C. In Fortran, MPI routines are subroutines and you invoke them with the call statement.

Also, every MPI object (like MPI_Datatype, MPI_Comm) is of type INTEGER in Fortran. That's just the vibe over there. πŸ’œ


⭐ ERRORS ⭐

Every MPI routine (except MPI_Wtime and MPI_Wtick) returns an error value β€” C routines as the return value of the function, Fortran routines in that last argument. Before the value is returned, the current MPI error handler gets called. By default, this error handler aborts the MPI job, which is giving dramatic main character exit, but maybe not what you wanted. 🫠

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 β€” like, it works, but why. πŸ™ˆ The predefined error handler MPI_ERRORS_RETURN can be used to cause error values to be returned. And note: 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 error roster:

  • MPI_SUCCESS β€” No error; MPI routine completed successfully. πŸ’–
  • MPI_ERR_ARG β€” Invalid argument. Some argument is invalid and is not identified by a specific error class (e.g., MPI_ERR_RANK).
  • MPI_ERR_BUFFER β€” Invalid buffer pointer. Usually a null buffer where one is not valid.
  • MPI_ERR_COMM β€” Invalid communicator. A common error is to use a null communicator in a call (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_INFO β€” Invalid Info.
  • 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!! 🌈✨

This one came out of the MPI manual, dated 4/10/2026, and she's filed under MPI_Neighbor_alltoallw_init(3). go forth and make your persistent requests, you absolute icon πŸ‘‘πŸ’–

πŸ“¦ where this page comes from