Click here to go to the TACC Home Page

TACC

Point-to-Point Communications

The MPI library has a wide variety of message-passing functions to handle several different modes of communication: synchronous, asynchronous, "blocking", .... Point-to-point message-passing consists of a process which sends a message and another process which receives the message -- a send/receive pair. MPI leaves the details of the underlying communication to the implementer (commercial or government entity) so response times may vary from machine to machine, and even between versions of MPI.

   Message-Passing Interface
Note: This seemingly innocuous fact can be the reason for anomalous behavior of a code on different machines.

We will discuss three commonly-used modes of message-passing in MPI:

Two other communication modes, synchronous and ready, are used somewhat less often and will not be discussed here. Each mode has different characteristics for its send and receive operations and a send/receive pair may employ different modes of communication. Function names for each mode are distinctive, as shown in this table:

ModeSend functionReceive function
standard MPI_Send MPI_Recv
buffered MPI_Bsend none, use mpi_recv
immediate MPI_Isend MPI_Irecv

The calling syntax for sends and receives is quite similar, with the major difference being that receive calls will have one additional argument (a structure pointer) for the message status. To avoid redundancy, the common arguments are defined only once for each send/receive pair below. The first three arguments are the data reference (data, count, itype) that gives the respective send/receive storage location, the number of data elements, and the MPI data type (usually an MPI intrinsic data type parameter) of the communicated data (passed message). The calling syntax also requires a message tag for distinguishing messages and a communicator for context (itag, icomm ). The extra message-status argument of a receive function call is an integer array and other routines use this array to extract status information. The size of the status array may vary from machine to machine and/or implementation The generic syntax and arguments are:

ierr= MPI_<Xsend>(data, icount, itype, idest, itag, icomm)
ierr= MPI_<Xrecv>(data, icount, itype, isrc,  itag, icomm, status)
where:

Parameter Description Status
data (void *) data location (type integer, real, character, etc.) [IN]
icount (int) number of elements in data array [IN]
itype (MPI_Datatype) type of data elements (MPI_REAL, MPI_INTEGER, ...) [IN]
idest/isrc (int) destination/source process (rank within communicator group) [IN]
itag (int) message tag (identifier) [IN]
icomm (MPI_Comm) communicator (use MPI_COMM_WORLD as predefined context for processes) [IN]
status (MPI_Status *) message status of received data [OUT]
ierr MPI error number (0 = no error) [OUT]

data is usually a real or integer array but it may also be a single variable or an MPI derived data type. The itype argument declares the type of data to the called subroutine.