Click here to go to the TACC Home Page
Point-to-Point Communications

The MPI library has a wide variety of message-passing subroutines 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. Subroutine names for each mode are distinctive, as shown in this table:

ModeSend subroutineReceive subroutine
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 (an integer array) 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 (passed) data (message). The calling syntax also requires a message tag for distinguishing messages, a communicator for context, and an error variable (itag, icomm, ierr). The extra message-status argument of a receive subroutine 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 (see the examples for size determination). The generic syntax and arguments are:

call mpi_<xsend> (data, icount, itype, idest, itag, icomm, ierr)
call mpi_<xrecv> (data, icount, itype, isrc, itag, icomm, istatus, ierr)
where:

Parameter Description Status
data data location (type integer, real, character, etc.) [IN]
icount number of elements in data array [IN]
itype type of data elements (MPI_REAL, MPI_INTEGER, ...) [IN]
idest/isrc destination/source process (rank within communicator group) [IN]
itag message tag (identifier) [IN]
icomm communicator (use MPI_COMM_WORLD as predefined context for processes) [IN]
istatus 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.