Comparing: Point-to-point communication
Point-to-point communication MPI
All MPI communications require a communicator argument and MPI
processes can only communicate if they share a communicator.
A communicator in simple terms comprises a process group, context,
and other attributes.
A group is a list of processes. The processes are ordered and numbered
consecutively from 0, the number of each process is its rank.
To send a message a source process makes an MPI call that specifies the
rank of the destination process. The destination process must make a
corresponding MPI call to receive the message.
Communication modes in MPI
There are four communication modes provided by MPI:
- Standard
- Synchronous
- Buffered
- Ready
These modes refer to the types of send and it is not meaningful to talk
of communication in the context of receive.
- Standard Send
This call completes once the message has been sent. This does
not imply that the message has been received at its destination.
- Synchronous Send
This call completes once the receive has completed.
- Buffered Send
This call guarantees to complete immediately, copying the
message to a system buffer for later transmission if necessary.
To use buffered mode, the user must attach buffer space.
- Ready Send
This call completes immediately. The communication will succeed
if a matching receive has already been posted. However, if no
matching receive has been posted the outcome is undefined.
Sending point-to-point messages in PVM
Sending a message in PVM involves three steps.
- First, a send buffer is initialized by a call to
pvmfinitsend(encoding, bufid)
- Second, the message must be packed
pvmfpack(what, xp, nitem, stride, info)
- Third, the completed message is sent to another process by calling
pvmfsend(tid, msgtag, info)
Initializing the SEND buffer
The routine pvmfinitsend(encoding, bufid)
clears the default send
buffer and prepares it for packing a new message.
encoding
- integer specifying the next message's encoding scheme.
bufid
- integer returned containing the message buffer identifier. Values less than zero indicate an error.
Packing the SEND buffer
The routine pvmfpack(what, xp, nitem, stride, info)
packs an
array of a given data type into the active send buffer.
what
- integer specifying the type of data being packed.
xp
- Pointer to the beginning of a block of bytes.
nitem
- The total number of items to be packed.
stride
- The stride to be used when packing items.
info
- Integer status code returned by routine. Values less than zero indicate an error.
Sending messages
The routine pvmfsend(tid,msgtag,info)
sends a message stored in
the active buffer to the PVM process identified by tid.
tid
- task indentifier of destination process.
msgtag
- integer message tag supplied by the user.
info
- integer status code returned by the routine.
Receiving point-to-point messages in PVM
Receiving a message involves two steps.
- A message is received using the routine
pvmfrecv(tid, msgtag, bufid).
This routine blocks until a message with label msgtag
arrives from tid.
- The message is unpacked using
pvmfunpack(what, xp, nitem, stride, info).
The arguments are as defined in the pvmfpack
routine, with xp the memory location into which data is to be unpacked.
Submitted by Mark Johnston,
last updated on 10 December 1994.