MPI point-to-point communication routines
are utilized for data communications between a sending processor and a
receiving processor. The argument list of these routines takes one of the
following formats:
Blocking communication
MPI-Send (buffer, count, type, dest, tag,
comm)
MPI-Recv (buffer, count, type, source, tag,
comm, status)
Non-blocking communication
MPI-Isend (buffer, count, type, dest, tag,
comm, request)
MPI-Irecv (buffer, count, type, source,
tag, comm, request)
The arguments of these communication
routines are explained as
follows:
A buffer is the application address space
that references the data to be sent or received. In most cases, this is simply
the variable name that is to be sentheceived. For C programs this argument is
passed by the reference and usually must be pre-pended with an ampersand.
A data count indicates the number of data
elements of a particular type to be sent or received. A data type must use the
data types predefined by MPI, though programmers can also create their derived
types. We should note that the MPI types, MPI-BYTE, and MPIPACKED do not
correspond to standard C or Fortran types.
A dest indicates the send process where a
message should be delivered, it is specified as the rank of the receiving
process. A source indicates the originating process of the message; as the
counterpart of the dest, it also specifies the rank of the sending process.
The source may be set to the wild card
MPI-ANY-SOURCE to receive a message from any task. The tag is an arbitrary
non-negative integer assigned by the programmer to uniquely identify a message.
The send and receive operations should match message tags.
For a receive operation, the wild card
MPIANYTAG can be used to receive any message regardless of its tag. The MPI
standard guarantees that integers 0-32767 can be used as tags, but most
implementations allow much wider range than this.
A comm represents the designated
communicator and indicates the communication context, or the set of processes
for which the source or destination fields are valid. The predefined
communicator MPI-COMM-WORLD is usually used, unless a programmer is explicitly
creating new communicators.
A status indicates the source of the
message and the tag of the message for a receive operation. In C, this argument
is a pointer to a predefined structure MPI-Status. In Fortran, it is an integer
array of size MPI STATUS SIZE. Additionally the actual number of bytes received
is obtainable fromstatus via the MPI-GET-COUNT routine.
A request is used by non-blocking send and
receive operations. Since nonblocking operations may return before the
requested system buffer space is obtained, the system issues a unique request
number. The programmer uses this system assigned handle later to determine
completion of the nonblocking operation. In C, this argument is a pointer to a
predefined structure MPI-Request. In Fortran, it is an integer.
In the following, we present an example of
point-to-point communication. Suppose that in the distributed load flow
computation, SACCi and SACCj will exchange boundary state variables. For
simplicity but without losing generality, we assume that SACCi will only send
the magnitude of one boundary voltage variable.
If the ranks of SACCi and SACC, are
assigned by the distributed system are x and y, respectively, then SACCi and
SACC, can use the following function calls to realize synchronous
communication:
SACCi
SACCj
SACCi and SACC, can use the following
function calls to realize the asynchronous communication:
MPI-Send (vk, 1, MPI-FLOAT, y, 8, comm)
MPI-Recv (vb, 1, MPI-FLOAT, x, 8, comm,
status)
SACCi
SACCj
MPI-Isend (vk, 1, MPI-FLOAT, y, 8, comm, 5)
MPI-Irecv (vb, 1, MPI-FLOAT, x, 8, comm, 7)
No comments:
Post a Comment