Communicating messages
Message passing
A procedure for sending messages in PVM involves three steps.
- A send buffer is initialized by a call to
pvmfinitsend(encoding,bufid)
- The message must be packed using
pvmfpack(what,xp,nitem,stride,info)
- The completed message is sent to another process by calling
pvmfsend(tid,msgtag,info)
or multi-cast with
pvmfmcast(ntask,tids,msgtag,info)
Routines and arguments will be explained in more detail later in the course.
These three steps may be combined (in PVM 3.3) in a single call to
pvmfpsend(tid,msgtag,xp,len,what,info)
This
- Packs and sends a contiguous array of a single datatype.
- Uses its own send buffer and so does not affect a partially
packed buffer used by pvmfsend.
- Is asynchronous.
- Can be received by any PVM receive.
- Allows the possibility of faster implementations, particularly on MPP
machines.
A procedure for receiving messages involves two steps.
- A message is received using the blocking routine
pvmfrecv(tid,msgtag,bufid)
or the non-blocking routine
pvmfnrecv(tid,msgtag,bufid)
- The message is then unpacked using
pvmfunpack(what,xp,nitem,stride,info)
These two calls may be combined (in PVM 3.3) in a single call to
pvmfprecv(tid,msgtag,buf,len,datatype,atid,atag,alen,info)
This
Multiple message buffers
PVM 3 supports management of multiple buffers.
- There is only one active send and one active receive buffer per process at any given moment.
- The packing, sending, receiving, and unpacking routines only affect active buffers.
- The developer may switch between multiple buffers for message passing.
Packing Data
- A number of C routines exist for packing data.
- A single Fortran routine handles all the packing functions. This
routine is
pvmfpack(what,xp,nitem,stride,info)
Sending Data
- The routine
pvmfsend(tid,msgtag,info)
labels the message with an integer identifier msgtag and sends it immediately to the process tid.
- The routine
pvmfmcast(ntask,tids,msgtag,info)
labels the message with an identifier msgtag and broadcasts the message to all tasks in the tids array, which is of length ntask.
Combining send and pack
The routine pvmfpsend(tid,msgtag,xp,len,what,info)
packs and sends an array of datatype what to the task
identified by tid.
xp is the address of the send buffer and
len is the length of this buffer.
Receiving Data
There exist blocking and non-blocking receive calls.
- Blocking receive
pvmfrecv(tid,msgtag,bufid)
will wait until a message with label msgtag arrives from
tid.
- Non-blocking receive
pvmfnrecv(tid,msgtag,bufid)
If the requested message has not arrived, then bufid=0 is
returned. If a message with label msgtag arrives from tid,
the routine places this message in a new active buffer with
ID in bufid.
Unpacking data
- A number of C routines exist for unpacking data from the receive active buffer.
- A single Fortran routine handles all the unpacking functions;
pvmfunpack(what,xp,nitem,stride,info)
Combining receive and unpack
The routine pvmfprecv(tid,msgtag,xp,len,what,atid,atag,alen,info)
blocks until a message with label msgtag arrives from tid.
buf is the receive buffer. atid, atag, and
alen return the actual tid of the sender, the actual
message tag, and the actual message length respectively.
Submitted by Mark Johnston,
last updated on 21 February 1995.