4.1. Introduction

PreviousUpNext
Up: Point-to-Point Communication Next: Blocking Send and Receive Operations Previous: Point-to-Point Communication

Sending and receiving of messages by MPI processes is the basic MPI communication mechanism. The basic point-to-point communication operations are send and receive. Their use is illustrated in Example Introduction.


Example A simple `hello world' example usage of point-to-point communication.

Image file

In Example Introduction, process zero (myrank = 0, strictly `the MPI process with rank 0 in communicator MPI_COMM_WORLD') sends a message to process one using the send operation MPI_SEND. The operation specifies a send buffer in the sender memory from which the message data is taken. In the example above, the send buffer consists of the storage containing the variable message in the memory of process zero. The location, size and type of the send buffer are specified by the first three parameters of the send operation. The message sent will contain the 13 characters of this variable. In addition, the send operation associates an envelope with the message. This envelope specifies the message destination and contains distinguishing information that can be used by the receive operation to select a particular message. The last three parameters of the send operation, along with the rank of the sender, specify the envelope for the message sent.

Process one (myrank = 1, strictly `the MPI process with rank 1 in communicator MPI_COMM_WORLD') receives this message with the receive operation MPI_RECV. The message to be received is selected according to the value of its envelope, and the message data is stored into the receive buffer. In the example above, the receive buffer consists of the storage containing the string message in the memory of process one. The first three parameters of the receive operation specify the location, size and type of the receive buffer. The next three parameters are used for selecting the incoming message. The last parameter is used to return information on the message just received.


Advice to users.

Colloquial usage commonly permits references to ``rank 0'' or ``process 0'', which are strictly ambiguous and ideally should be qualified by including the relevant context, for example, the MPI communicator in the case above. ( End of advice to users.)
The next sections describe the blocking send and receive operations. We discuss send, receive, blocking communication semantics, type matching requirements, type conversion in heterogeneous environments, and more general communication modes. Nonblocking communication is addressed next, followed by probing and cancelling a message, channel-like constructs and send-receive operations, ending with a description of the ``dummy'' MPI process, MPI_PROC_NULL.


PreviousUpNext
Up: Point-to-Point Communication Next: Blocking Send and Receive Operations Previous: Point-to-Point Communication


Return to MPI-4.1 Standard Index
Return to MPI Forum Home Page

(Unofficial) MPI-4.1 of November 2, 2023
HTML Generated on November 19, 2023