Basic Message Passing Primitives:
Point-to-Point Communication

SenderReceiver
int MPI_Xxx(const void* buf, int count, MPI_Datatype type, int destRank, int msgTag, MPI_Comm comm);

Three functions that share the prototype above and that result in one of two types of blocking send requests:

  • locally blocking: MPI_Bsend
  • globally blocking: MPI_Ssend, MPI_Rsend (The latter immediately returns with an error code without doing the send if the receiver has not already initiated a receive.)
blocking:

int MPI_Recv(void* buf, int count, MPI_Datatype type, int sourceRank, int msgTag, MPI_Comm comm, MPI_Status* status);

immediate; non-blocking:

int MPI_Irecv(void* buf, int count, MPI_Datatype type, int sourceRank, int msgTag, MPI_Comm comm, MPI_Request* request);

immediate; non-blocking:

int MPI_Isend(const void* buf, int count, MPI_Datatype type, int destRank, int msgTag, MPI_Comm comm, MPI_Request* request);

Notes

  1. A message sent using any of the send APIs in the first column can be received using any of the receive APIs in the second column.
  2. MPI_Send shares the same prototype as MPI_Bsend, MPI_Ssend, and MPI_Rsend. It behaves like MPI_Bsend for sufficiently small messages; it behaves like MPI_Ssend for larger messages. Therefore you don't know whether MPI_Send will be locally or globally blocking. All you know is that, from the perspective of the sender, it blocks until the send buffer can be safely reused.
  3. A message can be received by the rank i process only if the destination rank specified in the send was i, and if the source, tag, and comm values match those in the message.
  4. MPI_Recv and MPI_Irecv can specify "wild cards" for source and/or tag: MPI_ANY_SOURCE and MPI_ANY_TAG, respectively.
  5. The MPI_Status object has the following public fields: In addition, you can query the returned MPI_Status object using:
    int MPI_Get_count(const MPI_Status* status, MPI_Datatype dt, int* count);
  6. After calling MPI_Isend or MPI_Irecv, you can use, for example, any of the MPI_Test* or MPI_Wait* functions, passing the MPI_Request object returned from MPI_Isend or MPI_Irecv.
  7. Messages can be "probed" to see if they are available (e.g., so appropriate receiving buffers can be dynamically allocated): MPI_ANY_SOURCE and MPI_ANY_TAG can be used with these as well.