.2.
1 MPI_ Recv
The first six arguments to MPI_Recv correspond to the first six arguments
of MPI_Send:
CS8083 MCP Notes UNIT IV
8 B.Shanmuga Sundari, AP/CSE
The first three arguments specify the memory available for receiving the
message.
msg_buf_p: points to the block of memory
buf_size : determines the number of objects that can be stored in the
block
buf_type:indicates the type of the objects.
The next three arguments identify the message.
source: specifies the process from which the message should be received.
tag: should match the tag argument of the message being sent
communicator: match the communicator used by the sending process.
Message matching
Suppose process q calls MPI Send with
Also suppose that process r calls MPI_Recv with
Then the message sent by q with the above call to MPI_Send can be
received by r with
the call to MPI_Recv if
CS8083 MCP Notes UNIT IV
9 B.Shanmuga Sundari, AP/CSE
If recv_type = send_type and recv_buf_sz= send_buf_sz, then the
message sent by q can
be successfully received by r.
The status_p argument
A receiver can receive a message without knowing
1. the amount of data in the message
2. the sender of the message, or
3. the tag of the message.
The MPI type MPI_Status is a struct with at least the three members MPI_
SOURCE,
MPI_TAG, and MPI_ERROR.
Suppose our program contains the definition MPI_Status status; Then,
after a call to MPI
Recv in which &status is passed as the last argument, we can determine
the sender and
tag by examining the two members
status.MPI SOURCE status.MPI TAG
The amount of data that‘s been received isn‘t stored in a field that‘s
directly accessible to
the application program. However, it can be retrieved with a call to
MPI_Get_count.
Then the call MPI_Get_count(&status, recv type, &count) will return the
number of
elements received in the count argument.
Syntax of MPI Get count
Semantics of MPI Send and MPI Recv
The sending process will assemble the message. For example, it will add
the envelope
information to the actual data being transmitted—the destination process
rank, the
sending process rank, the tag, the communicator, and some information
on the size of the
message. Once the message has been assembled, there are essentially
two possibilities: