int bufid = pvm_initsend (int encoding)
call pvmfinitsend (encoding, bufid)
int bufid = pvm_mkbuf (int encoding)
encoding
is one of PvmDataDefault
, PvmDataRaw
,
PvmDataInPlace
int info = pvm_freebuf (int bufid)
bufid
pvm_mkbuf()
to create a buffer for a new
message if required
pvm_initsend()
int bufid = pvm_getsbuf (void)
int bufid = pvm_getrbuf (void)
int oldbuf = pvm_setsbuf (int bufid)
bufid
int oldbuf = pvm_setrbuf (int bufid)
bufid
bufid
is set to 0 in pvm_set?buf()
, then the present
buffer is save and there is no active buffer
This can be used to save the present state of an application's
messages
So that a math library or graphical interface which also used PVM
messages will not interfere with the state of the application's
buffersoldid = pvm_setsbuf (0) ; bufid = pvm_recv (src, tag) ; info = pvm_send (dst, tag) ; info = pvm_setrbuf (oldid) ;
nitem
which is the total number of items to pack from
this array
stride
which is the stride to use when packing
pvm_pkstr()
is an exception; its packs a NULL
terminated
character string and so does not need nitem
nor stride
int info = pvm_pkbyte (char *cp, int nitem, int stride) int info = pvm_pkcplx (float *fp, int nitem, int stride) int info = pvm_pkdcplx (double *dp, int nitem, int stride) int info = pvm_pkdouble (double *dp, int nitem, int stride) int info = pvm_pkfloat (float *fp, int nitem, int stride) int info = pvm_pkint (int *np, int nitem, int stride) int info = pvm_pklong (long *np, int nitem, int stride) int info = pvm_pkshort (short *np, int nitem, int stride) int info = pvm_pkstr (char *cp)
call pvmfpack (datatype, data, item,
stride, info)
datatype
is one of
STRING |
0 | REAL4 |
4 |
BYTE1 |
1 | REAL8 |
6 |
INTEGER2 |
2 | COMPLEX8 |
5 |
INTEGER4 |
3 | COMPLEX16 |
7 |
data
is the first item to be packed
nitem
is the total number of item to be packed
stride
is the stride to use when packing
M
int info = pvm_upkbyte (char *cp, int nitem, int stride) int info = pvm_upkcplx (float *fp, int nitem, int stride) int info = pvm_upkdcplx (double *dp, int nitem, int stride) int info = pvm_upkdouble (double *dp, int nitem, int stride) int info = pvm_upkfloat (float *fp, int nitem, int stride) int info = pvm_upkint (int *np, int nitem, int stride) int info = pvm_upklong (long *np, int nitem, int stride) int info = pvm_upkshort (short *np, int nitem, int stride) int info = pvm_upkstr (char *cp)
call pvmfunpack (datatype, data, nitems, stride, info)
int info = pvm_send (int tid, int msgtag)
call pvmfsend(tid, mstag, info)
msgtag
tid
int info = pvm_mcast (int *tids, int ntask,
int msgtag)
call pvmfmcast (ntask, tids, mstag, info)
msgtag
ntask
tasks specified in the
array tids
int bufid = pvm_nrecv (int tid, int msgtag)
call pvmfnrecv (tid, mstag, info)
msgtag
has arrived from
tid
, places this message in a new active receive buffer
which is created
msgtag
or tid
matches anything
(wildcard)
int bufid = pvm_recv (int tid, int msgtag)
call pvmfrecv (tid, mstag, info)
msgtag
has
arrived from tid
pvm_nrecv()
C ** sender ** C send a int N and an array of N reals CALL PVMFINITSEND (PVMDEFAULT, IBUF) CALL PVMFPACK (INTEGER4, N, 1, 1, IERR) CALL PVMFPACK (REAL8, Y(1), N, 1, IERR) CALL PVMFSEND (TIDS(I), METAG, IERR) C ** receiver ** CALL PVMFRECV (-1, METAG, IBUF) CALL PVMFUNPACK (INTEGER4, N, 1, 1, IERR) CALL PVMFUNPACK (REAL8, Z(1), N, 1, IERR)
int info = pvm_bufinfo (int bufid, int *bytes,
int *msgtag, int *tid)
call pvmfbufinfo (bufid, bytes, mstag, tid, info)
bufid
:
bufid = pvm_recv (-1, -1) ; info = pvm_bufinfo (bufid, &bytes, &type, &source) ; printf ("message from %d, tag %d\n", source, type) ;
int bufid = pvm_probe (int tid, int msgtag)
call pvmfprobe (tid, mstag, bufid)
msgtag
has arrived
from tid
tid
and msgtag
may be wildcarded by the value -1
pvm_recv()
must be
call before the message can be unpacked
pvm_bufinfo()
can be called with the
returned buffer ID to determine information about the
message before receiving it
tid = pvm_parent () ; msgtag = 4 ; arrived = pvm_probe (tid, msgtag) ; if (arrived) info = pvm_bufinfo (arrived, &len, &tag, &tid) ; else /* go to other computing */
int (*old)() = pvm_recvf (
int (*new)(int buf, int tid, int tag))
pvm_recv()
< 0 | return immediately with this error code |
0 | do not pick this message |
1 | pick this message and stop now |
> 1 | pick this highest preference after scanning them all |
pvm_recvf()
#include "pvm3.h" static foundit = 0 ; static int foo_match (int mid, int tid, int code) { int t, c, cc ; if ((cc = pvm_bufinfo (mid, (int *) 0, &c, &t)) < 0) return cc; if ((tid == -1 || tid == t) && (code == -1 || code == c)) foundit = 1 ; return 0 ; } int probe (int src, int code) { int (*omatch)(), cc ; omatch = pvm_recvf (foo_match) ; foundit = 0 ; if ((cc = pvm_nrecv (src, code) < 0) return cc ; pvm_recvf (omatch) ; return foundit ; }