MPI\_Send, MPI\_Isend, MPI\_Recv, and MPI\_Irecv APIs
The pair mpi.send and mpi.recv are two most used blocking
calls for point-to-point communications. An int, double or char vector
can be transmitted from any source to any destination.
The pair mpi.isend and mpi.irecv are the same except that
they are nonblocking calls.
Blocking and nonblocking calls are interchangeable, e.g., nonblocking sends can be matched with blocking receives, and vice-versa.
mpi.send(x, type, dest, tag, comm = 1) mpi.isend(x, type, dest, tag, comm = 1, request=0) mpi.recv(x, type, source, tag, comm = 1, status = 0) mpi.irecv(x, type, source, tag, comm = 1, request = 0)
x |
data to be sent or received. Must be the same type for source and destination. The receive buffer must be as large as the send buffer. |
type |
1 for integer, 2 for double, and 3 for character. Others are not supported. |
dest |
the destination rank. Use |
source |
the source rank. Use |
tag |
non-negative integer. Use |
comm |
a communicator number. |
request |
a request number. |
status |
a status number. |
The pair mpi.send (or mpi.isend) and mpi.recv
(or mpi.irecv) must be used together, i.e., if there is a sender,
then there must be a receiver. Any mismatch will result a deadlock
situation, i.e., programs stop responding. The receive buffer must be
large enough to contain an incoming message otherwise programs will be
crashed. One can use mpi.probe (or mpi.iprobe) and
mpi.get.count to find the length of an incoming message
before calling mpi.recv. If mpi.any.source or
mpi.any.tag is used in mpi.recv, one can use
mpi.get.sourcetag to find out the source or tag of the
received message. To send/receive an R object rather than an int, double
or char vector, please use the pair mpi.send.Robj and
mpi.recv.Robj.
If multiple nonblocking sends or receives are used, please use request
number consecutively from 0. For example, to receive two messages from two
slaves, try
mpi.irecv(x,1,source=1,tag=0,comm=1,request=0)
mpi.irecv(y,1,source=2,tag=0,comm=1,request=1)
Then mpi.waitany, mpi.waitsome or mpi.waitall can be
used to complete the operations.
mpi.send and mpi.isend return no value. mpi.recv
returns the int, double or char vector sent from source. However,
mpi.irecv returns no value. See details for explanation.
Hao Yu
#on a slave mpi.send(1:10,1,0,0) #on master x <- integer(10) mpi.irecv(x,1,1,0) x mpi.wait() x
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.