MHPCC

SP Parallel Programming Workshop
Parallel Virtual Machine (PVM)


© Copyright Statement

  1. Prerequisites

  2. PVM - What is it?
    1. Background Information
    2. Advantages/Disadvantages
    3. Components

  3. PVM Routines
    1. Process Control
    2. Point to Point Communication
    3. Collective Communication
    4. Group Management
    5. Information
    6. Miscellaneous

  4. Running PVM
    1. Acquire, build and install the PVM software (optional)
    2. Design your application and prepare to execute your PVM session.
    3. Compile your application components
    4. Create your PVM hostfile
    5. Create your $HOME/.rhosts file
    6. Start the master PVM daemon
    7. Execute your application
    8. Quit PVM

  5. PVM at the MHPCC

  6. Tips, Tricks, Hints, and Miscellaneous Information

  7. References, Acknowledgments, WWW Resources

  8. Exercises

Prerequisites


PVM - What is it?


Advantages/Disadvantages to Using PVM

Advantages

Disadvantages


PVM Components

Components are the parts of your Parallel Virtual Machine responsible for things such as:

There are two - the PVM Daemon and the PVM Libraries.


PVM Daemon (pvmd3)


PVM Components (cont)
PVM Libraries


PVM Routines
Process Control

pvm_mytid
PVMFMYTID

Enrolls the calling process into PVM and generates a unique task identifier (tid) if this process is not already enrolled in PVM. If the calling process is already enrolled in PVM, this routine simply returns the process's tid. The tid is a 32 bit positive integer created by the local pvmd with no obvious sequence or relation to other tids.

     tid = pvm_mytid ();
     PVMFMYTID (TID)
     
pvm_spawn
PVMFSPAWN

Starts new PVM processes. Typically executed by a "master" process to start the "worker" processes. The programmer can specify the machine architecture and/or machine name where processes are to be spawned. If successful or partially successful, returns the actual number of processes spawned; if an error occurs, an integer less than zero is returned..

     numt = pvm_spawn ("worker",NULL,PvmTaskDefault,"",1,&tids[i]);
     numt = pvm_spawn ("worker",0,PvmTaskArch,"RS6K",1,&tid[i]); 
     numt = pvm_spawn ("gen1",0,PvmTaskHost,'node1.mhpcc.edu',1,&tid[0]); 
     PVMFSPAWN ('worker',PVMDEFAULT," ",1,TIDS(I),INFO)
     PVMFSPAWN (`node',PVMARCH,`SUN4',1,TID,INFO) 
     PVMFSPAWN (`gen1',PVMHOST,`sun2a.mhpcc.edu',32,TIDS,INFO)
     
pvm_exit
PVMFEXIT

Tells the local pvmd that this process is leaving PVM. This routine should be called by all PVM processes before they stop or exit.

     pvm_exit ();
     PVMFEXIT (INFO)
     
pvm_kill
PVMFKILL

Terminates a specified PVM process. This routine is not designed for use by the calling process to kill itself.

     pvm_kill (tid);
     PVMFKILL (TID,INFO)
     
pvm_halt
PVMFHALT

Shuts down the entire PVM system.

     pvm_halt ( )
     PVMFHALT (info)
     
pvm_addhosts
PVMFADDHOSTS

Add hosts to the virtual machine. The names should have the same syntax as lines of a pvmd hostfile. The C routine may be used to add multiple hosts per call; the Fortran routine may add only one host per call. Useful for designing fault tolerant applications.

     pvm_addhosts (hostarray,4,infoarray);
     PVMFADDHOST (`azure.chem.edu',INFO)
     
pvm_delhost
PVMFDELHOST

Deletes hosts from the virtual machine. The C routine may be used to delete multiple hosts per call; the Fortran routine may delete only one host per call.

     pvm_delhosts (hostarray,4);
     PVMFDELHOST (`azure.chem.edu',INFO)
     
pvm_getopt
PVMFGETOPT

Returns the value of libpvm options. See the man page for details.

     val = pvm_getopt (PvmFragSize);
     PVMFGETOPT (PVMROUTE,VAL)
     
pvm_setopt
PVMFSETOPT

Sets the value of libpvm options. Most useful option is to increase message passing performance by specifing "Direct Routing". See the man page for details.

     pvm_setopt (PvmRoute,PvmRouteDirect); 
     PVMFSETOPT (PVMROUTE,PVMROUTEDIRECT,INFO)
     
pvm_catchout
PVMFCATCHOUT

Causes the calling task (the parent) to catch output from tasks spawned after the call to pvm_catchout. Characters printed on stdout or stderr in children tasks are collected by the pvmds and sent in control messages to the parent task, which tags each line and appends it to the specified file (or console screen).

     pvm_catchout (stdout);
     PVMFCATCHOUT (1,INFO)
     
pvm_sendsig
PVMFSENDSIG

Sends a signal to another PVM process. Should only be used by programmers with Unix signal handling experience. See the man page for details.

     pvm_sendsig (tid,SIGKILL);
     PVMFSENDSIG (TID,SIGNUM,INFO) 
     
pvm_start_pvmd

Starts up a pvmd3 process, the master of a new virtual machine. The routine can be set to block until startup is complete or to return immediately.

     pvm_start_pvmd (argc,argv,block); 
     

PVM Routines
Point To Point Communication

Programming PVM point-to-point communications is typically done as follows:

PVM Routines
Point To Point Communication

pvm_initsend
PVMFINITSEND

Clears the send buffer and specifies the type of data format encoding to be used. By default, PVM assumes a heterogenous machine environment and messages are encoded (converted) to XDR format. Specify PvmDataRaw to turn off XDR format conversion, or PvmDataInPlace to both turn off XDR and skip copying message into send buffer before sending. If successful, returns the message buffer identifier; if an error, then an integer < 0 is returned.

     pvm_initsend (PvmDataDefault)
     PVMFINITSEND (PVMDATARAW,INFO)
     
pvm_pkdatatype
PVMFPACK( datatype ...)

Pack the specified data type into the active send buffer. Should match a corresponding unpack routine in the receive process. C language uses a separate routine for each data type. Fortran uses a single routine, but specifies the data type within the routine's calling parameters. Note that structure data types must be packed by their individual data element. Valid routines/data types are:

    C               Fortran
-----------   -------------------------
pvm_pkbyte    PVMFPACK (BYTE1 ...)
pvm_pkstr     PVMFPACK (STRING ...)
pvm_pkfloat   PVMFPACK (REAL4 ...)
pvm_pkdouble  PVMFPACK (REAL8 ...)
pvm_pkcplx    PVMFPACK (COMPLEX8 ...)
pvm_pkdcplx   PVMFPACK (COMPLEX16 ...)
pvm_pkint     PVMFPACK (INTEGER4 ...)
pvm_pkshort   PVMFPACK (INTEGER2 ...)
pvm_pklong
pvm_pkuint
pvm_pkushort
pvm_pkulong

     pvm_pkint (&array[offset],nbytes,stride)
     pvm_pkstr ("helloworld")

     PVMFPACK (INTEGER4,ARRAY(OFFSET),NBYTES,STRIDE,INFO)
     PVMFPACK (STRING,'helloworld',NBYTES,STRIDE,INFO)
pvm_upkdatatype
PVMFUNPACK( datatype ...)

Unpack the specified data type into the active receive buffer. Should match a corresponding pack routine in the sending process. C language uses a separate routine for each data type. Fortran uses a single routine, but specifies the data type within the routine's calling parameters. Note that structure data types must be unpacked by their individual data element. Valid routines/data types are:

    C               Fortran
-----------   -------------------------
pvm_upkbyte    PVMFUNPACK (BYTE1 ...)
pvm_upkstr     PVMFUNPACK (STRING ...)
pvm_upkfloat   PVMFUNPACK (REAL4 ...)
pvm_upkdouble  PVMFUNPACK (REAL8 ...)
pvm_upkcplx    PVMFUNPACK (COMPLEX8 ...)
pvm_upkdcplx   PVMFUNPACK (COMPLEX16 ...)
pvm_upkint     PVMFUNPACK (INTEGER4 ...)
pvm_upkshort   PVMFUNPACK (INTEGER2 ...)
pvm_upklong
pvm_upkuint
pvm_upkushort
pvm_upkulong

     pvm_upkint (&array[offset],nbytes,stride)
     pvm_upkstr (stringvar)

     PVMFUNPACK (INTEGER4,ARRAY(OFFSET),NBYTES,STRIDE,INFO)
     PVMFUNPACK (STRING,STRINGVAR,NBYTES,STRIDE,INFO)
pvm_send
PVMFSEND

Immediately sends the data in the active message buffer to the specified destination task. This is a blocking, asynchronous send operation. Returns 0 if successful, < 0 otherwise.

     pvm_send (tids[1],MSGTAG);
     PVMFSEND (TIDS(1),MSGTAG,INFO)
     
pvm_psend
PVMFPSEND

Both packs and sends message with a single call. Syntax requires specification of a valid data type for both C and Fortran. Valid types are:

DATA TYPE              C             FORTRAN
------------------  -----------      ----------
byte                PVM_BYTE         BYTE1
string              PVM_STR          STRING
real                PVM_FLOAT        REAL4
double              PVM_DOUBLE       REAL8
complex             PVM_CPLX         COMPLEX8
double complex      PVM_DCPLX        COMPLEX16
int                 PVM_INT          INTEGER4
short               PVM_SHORT        INTEGER2
long integer        PVM_LONG
unsigned short int  PVM_USHORT 
unsigned int        PVM_UINT
unsigned long int   PVM_ULONG


     pvm_psend (tid,msgtag,array,1000,PVM_FLOAT);
     PVMFPSEND (TID,MSGTAG,BUF,CNT,REAL4,INFO)
pvm_mcast
PVMFMCAST

Multicasts a message stored in the active send buffer to ntask tasks specified in the tids array. The message is not sent to the caller even if listed in the array of tids. The receiving processes can call either pvm_recv or pvm_nrecv to receive their copy of the multicast message.

     pvm_mcast (tids,ntask,msgtag);
     PVMFMCAST (NPROC,TIDS,MSGTAG,INFO)
     
pvm_recv
PVMFRECV

Blocks the receiving process until a message with the specified tag has arrived from the specified tid. The message is then placed in a new active receive buffer, which also clears the current receive buffer. Using -1 as either the tag or tid argument causes a message with any tag and/or from any source to be received. If the routine is successful, it returns the buffer id of the new receive buffer; if an error occurs, then an integer < 0 is returned.

     pvm_recv (tid,msgtag);
     PVMFRECV (-1,MSGTAG,BUFID)
     
pvm_nrecv
PVMFNRECV

Same as pvm_recv, except a non-blocking receive operation is performed. If the specified message has arrived, this routine returns the buffer id of the new receive buffer. If the message has not arrived, it returns 0. If an error occurs, then an integer < 0 is returned.

     pvm_nrecv (tid,msgtag);
     PVMFNRECV (-1,MSGTAG,BUFID)
     
pvm_precv
PVMFPRECV

Both receives and unpacks a message with a single call. Accepts -1 as wildcard for either source tid or tag and returns actual source tid, actual message tag and actual message length. Syntax requires specification of a valid data type for both C and Fortran. Valid types are:

DATA TYPE              C             FORTRAN
------------------  -----------      ----------
byte                PVM_BYTE         BYTE1
string              PVM_STR          STRING
real                PVM_FLOAT        REAL4
double              PVM_DOUBLE       REAL8
complex             PVM_CPLX         COMPLEX8
double complex      PVM_DCPLX        COMPLEX16
int                 PVM_INT          INTEGER4
short               PVM_SHORT        INTEGER2
long integer        PVM_LONG
unsigned short int  PVM_USHORT
unsigned int        PVM_UINT
unsigned long int   PVM_ULONG

     pvm_precv (tid,msgtag,array,cnt,PVM_FLOAT,&asrc,&atag,&alen);
     CALL PVMFPRECV (-1,4,BUF,CNT,REAL4,ASRC,ATAG,ACNT,INFO)
pvm_trecv
PVMFTRECV

Same as pvm_recv, except the receive will time-out after the specified number of seconds and microseconds. If the specified message arrives before the time-out, this routine returns the buffer id of the new receive buffer. If the message does not arrive, it returns 0. If an error occurs, then an integer < 0 is returned.

     bufid = pvm_trecv (source,msgtag,&tmout)
     PVMFTRECV (SOURCE,MSGTAG,SEC,USEC,BUFID)
     
pvm_probe
PVMFPROBE

Checks to see if a message with specified msgtag has arrived from specified tid. If a matching message has arrived pvm_probe returns a buffer identifier in bufid. This bufid can be used in a pvm_bufinfo call to determine information about the message such as its source and length. Accepts -1 as wildcard specification for msgtag and tid.

     pvm_probe (tid,msgtag); 
     PVMFPROBE (-1,4,ARRIVED)
     
pvm_recvf

This routine defines the comparison function to be used by the pvm_recv, pvm_nrecv, and pvm_probe functions. It is available as a means to customize PVM message passing. See the man page for details.

Example PVM Code
Process Control and Point-to-Point Message Passing
C Language


#include <stdio.h>
#include "pvm3.h"

#define NTASKS          6
#define HELLO_MSGTYPE   1

main() {
int     mytid, parent_tid, tids[NTASKS], msgtype, i, rc;
char    helloworld[13] = "HELLO WORLD!";

mytid = pvm_mytid();
parent_tid = pvm_parent();
pvm_catchout(stdout);
pvm_setopt(PvmRoute, PvmRouteDirect);

if (parent_tid == PvmNoParent) {
  printf("Parent task id= %d\n",mytid);
  printf("Spawning child tasks ...\n");
  for (i=0; i < NTASKS; i++) {
    rc = pvm_spawn("hello", NULL, PvmTaskDefault, "", 1, &tids[i]);
    printf("   spawned child tid = %d\n", tids[i]);
    }
  printf("Saying hello to all child tasks...\n");
  msgtype = HELLO_MSGTYPE;
  rc = pvm_initsend(PvmDataDefault);
  rc = pvm_pkstr(helloworld);
  for (i=0; i < NTASKS; i++)
    rc = pvm_send(tids[i], msgtype);
  printf("Parent task done.\n");
  }

if (parent_tid != PvmNoParent) {
  printf("Child task id= %d\n",mytid);
  msgtype = HELLO_MSGTYPE;
  rc = pvm_recv(-1, msgtype);
  rc = pvm_upkstr(helloworld);
  printf(" ***Reply to: %d : HELLO back from %d!\n",parent_tid, mytid);
  }

rc = pvm_exit();
}

Example PVM Code
Process Control and Point-to-Point Message Passing
Fortran


      program hello
      include 'fpvm3.h'

      parameter(NTASKS = 6)
      parameter(HELLO_MSGTYPE = 1)

      integer mytid, parent_tid, tids(NTASKS), msgtype, i, info
      character*12 helloworld/'HELLO WORLD!'/

      call pvmfmytid(mytid)
      call pvmfparent(parent_tid)
      call pvmfcatchout(1,info)
      call pvmfsetopt(PVMROUTE, PVMROUTEDIRECT, info)

      if (parent_tid .eq. PvmNoParent) then
        print *,'Parent task id= ', mytid
        print *,'Spawning child tasks...'
        do 10 i=1,NTASKS
        call pvmfspawn("hello", PVMDEFAULT, " ", 1, tids(i), info)
        print *,'   spawned child tid = ', tids(i)
 10     continue
        print *,'Saying hello to all child tasks...'
        msgtype = HELLO_MSGTYPE
        call pvmfinitsend(PVMDEFAULT, info)
        call pvmfpack(STRING, helloworld, 12, 1, info)
        do 20 i=1,NTASKS
        call pvmfsend(tids(i), msgtype, info)
 20     continue
        print *, 'Parent task done.'
      endif

      if (parent_tid .ne. PvmNoParent) then
        print *, 'Child task id= ', mytid
        msgtype = HELLO_MSGTYPE
        call pvmfrecv (-1, msgtype, info)
        call pvmfunpack(STRING, helloworld, 12, 1, info)
        print *,' ***Reply to: ',parent_tid, ' : HELLO back from ',
     &          mytid,'!'
      endif

      call pvmfexit(info)
      end

PVM Routines
Collective Communication

pvm_barrier
PVMFBARRIER

Blocks the calling process until all processes in a group have called pvm_barrier().

     pvm_barrier ("worker",5 );
     PVMFBARRIER ('worker',COUNT,INFO)
     
pvm_bcast
PVMFBCAST

Asynchronously broadcasts the data in the active send buffer to a group of processes. The broadcast message is not sent back to the sender. Receiving tasks can use any PVM receive routine to receive the message. Note that any PVM task can call pvm_bcast(), it need not be a member of the group.

     pvm_bcast ("worker",msgtag);
     PVMFBCAST (`worker',5,INFO)
     
pvm_gather
PVMFGATHER

A specified member of the group receives messages from each member of the group and gathers these messages into a single array. All group members must call pvm_gather(). Note: pvm_gather() does not block. If a task calls pvm_gather and then leaves the group before the root has called pvm_gather() an error may occur.

     pvm_gather (&getmatrix,&myrow,10,PVM_INT,msgtag,"workers",root);
     PVMFGATHER (GETMATRIX,MYCOLUMN,COUNT,INT4,MTAG,`workers',ROOT,INFO)
     
pvm_scatter
PVMFSCATTER

Performs a scatter of data from the specified root member of the group to each of the members of the group, including itself. All group members must call pvm_scatter(). Each receives a portion of the data array from the root in their local result array.

     pvm_scatter (&getmyrow,&matrix,10,PVM_INT,msgtag,"workers",root);
     PVMFSCATTER (GETMYCOLUMN,MATRIX,COUNT,INT4,MTAG,`workers',ROOT,INFO)
     
pvm_reduce
PVMFREDUCE

Performs a reduce operation over members of the specified group. All group members call pvm_reduce() with their local data, and the result of the reduction operation appears on the user specified root task. Users can define their own reduction functions or use one of the following predefined PVM reduction functions: PvmMin PvmMax PvmSum PvmProduct. NOTE: Fortran users must be certain to declare the predefined reduction functions as external. For example: External PvmMin .

     pvm_reduce (PvmMax,&myvals,10,PVM_INT,msgtag,"workers",root);
     PVMFREDUCE (PvmMax,MYVALS,COUNT,INT4,MTAG,`workers',ROOT,INFO)

PVM Routines
Group Management

pvm_joingroup
PVMFJOINGROUP

Enrolls the calling task in the named group and returns the instance number of this task in this group. Instance numbers start at 0 and count up; error numbers less than zero indicate an error. Tasks that leave and rejoin a group may/may not be assigned the same instance number - PVM attempts to "fill gaps" in the instance number sequence left by departing group members.

     rc = pvm_joingroup ("worker");
     CALL PVMFJOINGROUP (`group2',INUM)
     
pvm_lvgroup
PVMFLVGROUP

Unenrolls the calling process from a named group.

      rc = pvm_lvgroup ("worker");
      CALL PVMFLVGROUP (`group2',INFO)
     
pvm_gsize
PVMFGSIZE

Returns the number of members presently in the named group.

     size = pvm_gsize ("worker");
     CALL PVMFGSIZE (`group2',SIZE)
     
pvm_gettid
PVMFGETTID

Returns the tid of the process identified by a group name and instance number.

     tid = pvm_gettid ("worker",0);
     PVMFGETTID ('worker',5,TID)
     
pvm_getinst
PVMFGETINST

Returns the instance number in a group of a PVM process.

     inum = pvm_getinst ("worker",tid[i]);
     PVMFGETINST (`GROUP3',TID,INUM)
     
pvm_freezegroup
PVMFFREEZEGROUP

Freezes dynamic group membership and caches info locally by all group members, making the group static. This is a synchronizing routine and must be called by all group members to complete.

     info = pvm_freezegroup("worker",size);
     CALL PVMFFREEZEGROUP('group2',size,info)
     

Example PVM Code
Group Management and Collective Communications
C Language


#include <stdio.h>
#include "pvm3.h"

#define FIRST   0
#define NTASKS  4

int main() {

int   mytid, tids[NTASKS-1], rank, tag1=1, tag2=2, sum, max, info;

/* Startup - get taskid and then join group */
mytid = pvm_mytid();
rank = pvm_joingroup("summax");
sum = rank;
max = rank;

/* First task spawns the rest */
if (rank == FIRST) {
   info = pvm_spawn("summax", NULL, PvmTaskDefault, "", NTASKS-1, &tids);
   printf("Rank= %d spawned %d tasks\n",rank,info);
   }

/* Causes a barrier until NTASKS have joined, then freezes group */
pvm_freezegroup("summax",NTASKS);
/* Use collective communications calls to compute sum and max across group */
pvm_reduce(PvmSum,&sum,1,PVM_INT,tag1,"summax",FIRST);
pvm_reduce(PvmMax,&max,1,PVM_INT,tag2,"summax",FIRST);

/* First task prints results */
if (rank == FIRST) {
   printf("Done. Sum= %d  Max= %d\n",sum, max);
   }

/* Make sure everybody is done before leaving group and quitting */
pvm_barrier("summax",NTASKS);
pvm_lvgroup("summax");
pvm_exit();
}

Example PVM Code
Group Management and Collective Communications
Fortran


      program summax
      include 'fpvm3.h'

      integer FIRST, NTASKS, TAG1, TAG2
      parameter(FIRST=0)
      parameter(NTASKS=4)
      parameter(TAG1=1)
      parameter(TAG2=2)

      integer mytid, rank, tids(NTASKS-1), info, sum, max

C     Important - Fortran needs to declare these as external
      external PvmSum
      external PvmMax

C     Startup - get taskid and then join group.  
      call pvmfmytid(mytid)
      call pvmfjoingroup('summax',rank)
      sum = rank
      max = rank

C     First task spawns the rest
      if (rank .eq. FIRST) then
        call pvmfspawn('summax',PVMDEFAULT," ",NTASKS-1,tids,info)
        print *,'Rank= ',rank,'spawned',info,'tasks'
      endif

C     Causes a barrier until NTASKS have joined, then freezes group
      call pvmffreezegroup('summax',NTASKS,info)
C     Use collective communications calls to compute sum and max across group
      call pvmfreduce(PvmSum,sum,1,INTEGER4,tag1,'summax',FIRST,info)
      call pvmfreduce(PvmMax,max,1,INTEGER4,tag2,'summax',FIRST,info)

C     First task prints results
      if (rank .eq. FIRST) then
        print *,'Done. Sum= ',sum,' Max=',max
      endif

C     Make sure everybody is done before leaving group and quitting
      call pvmfbarrier('summax',NTASKS,info)
      call pvmflvgroup('summax',info)
      call pvmfexit(info)
      end

PVM Routines
Information

pvm_parent
PVMFPARENT

Returns the tid of the process that spawned the calling process. If the calling process was not created with pvm_spawn, then tid is set to PvmNoParent. Typically used by the "master" process to determine that it is the first active process and needs to spawn the "worker" processes.

     tid = pvm_parent ();
     PVMFPARENT (TID)
     
pvm_bufinfo
PVMFBUFINFO

Returns information about the specified message buffer. Typically used after a "wildcard" receive operation to determine facts about the last received message such as its size or source.

     pvm_bufinfo (bufid,&bytes,&type,&source);
     PVMFBUFINFO (BUFID,BYTES,TYPE,SOURCE,INFO)
     
pvm_pstat
PVMFPSTAT

Returns the status of the specified PVM process. Values are PvmOk if the task is running, PvmNoTask if not, and PvmBadParam if the tid is bad.

     status = pvm_pstat (tid);
     PVMFPSTAT (TID,STATUS)
     
pvm_mstat
PVMFMSTAT

Returns the status of a host in the virtual machine. Values PvmOk host is OK, PvmNoHost host is not in virtual machine, PvmHostFail host is unreachable (and thus possibly failed).

     mstat = pvm_mstat ("msr.ornl.gov");
     PVMFMSTAT (`msr.ornl.gov',MSTAT)
     
pvm_config
PVMFFCONFIG

Returns information about the present virtual machine configuration. The information returned is similar to that available from the console command conf". The C function returns information about the entire virtual machine in one call. The Fortran function returns information about one host per call and cycles through all the hosts. See the man page for details.

     pvm_config(&nhost,&narch,&hostp);
     PVMFCONFIG (NHOST,NARCH,DTID(i),HOST(i),ARCH(i),SPEED(i),INFO)
     
pvm_tasks
PVMFTASKS

Returns information about the tasks running on the virtual machine. The information returned is the same as that available from the console command "ps". The C function returns information about the entire virtual machine in one call. The Fortran function returns information about one task per call and cycles through all the tasks. See the man page for details.

     pvm_tasks (0,&ntask,&taskp);
     PVMFTASKS (DTID,NTASK,TID(i),PTID(i),DTID(i),FLAG(i),AOUT(i),INFO)
     
pvm_hostsync
PVMFHOSTSYNC

Samples the time-of day clock of a host in the virtual machine and returns both the clock value and the difference between local and remote clocks. See the man page for details.

pvm_pvm_tidtohost

Returns the integer host id on which the specified process tid is located. See the man page for details.

PVM Routines
Miscellaneous


The Steps:

Assuming that you are already connected to a functional network (Internet protocol) of Unix processors, follow the steps below to get started with PVM.

  1. Acquire, build and install the PVM software(optional)

  2. Design your application and prepare to execute your PVM session.

  3. Compile your application components

  4. Create your PVM hostfile

  5. Create your $HOME/.rhosts file

  6. Start the master PVM daemon

  7. Execute your application

  8. Quit PVM

Getting Started (cont)
Step 1:
Acquire, Build and Install the PVM Software (optional)


Getting Started (cont)
Step 2: Design Your Application and Prepare to Execute Your PVM session.


Getting Started (cont)
Step 3: Compile Your Application Components

Example Makefiles:


###############################################################################
# FILE: make.hello.c
# DESCRIPTION:  Makefile for trivial PVM example  - C Language
###############################################################################

CC        =     cc
OBJ       =     hello
SRC       =     hello.c
PVMDIR    =     /source/pd/pvm3.3/pvm3
INCLUDE   =     -I${PVMDIR}/include
LIBS      =     -L${PVMDIR}/lib/RS6K -lpvm3

${OBJ}: ${SRC}
        ${CC} ${SRC} ${INCLUDE} ${LIBS} -o ${OBJ}





###############################################################################
# FILE: make.hello.f
# DESCRIPTION:  Makefile for trivial PVM example  - Fortran
###############################################################################

F77       =     xlf
OBJ       =     hello
SRC       =     hello.f
PVMDIR    =     /source/pd/pvm3.3/pvm3
INCLUDE   =     -I${PVMDIR}/include
LIBS      =     -L${PVMDIR}/lib/RS6K -lfpvm3 -lpvm3

${OBJ}: ${SRC}
        ${F77} ${SRC} ${INCLUDE} ${LIBS} -o ${OBJ}

Getting Started (cont)
Step 4: Create your PVM hostfile

Example Hostfiles:


########################################################
# FILENAME:  hostfile.1
# DESCRIPTION: Simple PVM hostfile with no options
########################################################
fr29s01.mhpcc.edu
fr29s02.mhpcc.edu
fr29s03.mhpcc.edu
fr29s04.mhpcc.edu
fr29s05.mhpcc.edu
fr29s06.mhpcc.edu
fr29s07.mhpcc.edu
fr29s08.mhpcc.edu


########################################################
# FILENAME:  hostfile.2
# DESCRIPTION: PVM hostfile with a few options
########################################################
fr29s01.mhpcc.edu
fr29s02.mhpcc.edu
fr29s03.mhpcc.edu
fr29s04.mhpcc.edu
#
# next two hosts will be may be added dynamically later
#
&fr10n12.mhpcc.edu
&fr12n14.mhpcc.edu
#
# next host has differnet path for its PVM executables
#
beech.tc.cornell.edu  ep=/u/user02/pvm/testing/bin
#
# next line applies to all hosts which follow it
#
* lo=user02 pw
kanaha.mhpcc.edu
makena.mhpcc.edu
littleb.mhpcc.edu

Getting Started (cont)
Step 5: Create Your $HOME/.rhosts file


Getting Started (cont)
Step 6: Start the Master PVM Daemon


Getting Started (cont)
Step 7: Execute your application


Getting Started (cont)
Step 8: Quit PVM


kanaha% pvmd3 hosts3 &
[1] 15683
kanaha% pvm
pvmd already running.
pvm> conf
3 hosts, 1 data format
                    HOST     DTID     ARCH   SPEED
        kanaha.mhpcc.edu    40000     RS6K    1000
        makena.mhpcc.edu    80000     RS6K    1000
       littleb.mhpcc.edu    c0000     RS6K    1000
pvm> quit

pvmd still running.
kanaha% hello
Parent task id= 262146
Spawning child tasks ...
   spawned child tid = 524289
   spawned child tid = 786433
   spawned child tid = 262147
   spawned child tid = 524290
   spawned child tid = 786434
   spawned child tid = 262148
Saying hello to all child tasks...
Parent task done.
kanaha% cat /tmp/pvml.288
[t80040000] ready   Wed Mar  9 17:05:02 1994
[t80040000] [t40003] Child task id= 262147
[t80040000] [t40003]  ***Reply to: 262146 : HELLO back from 262147!
[t80040000] [t40004] Child task id= 262148
[t80040000] [t40004]  ***Reply to: 262146 : HELLO back from 262148!
[t80040000] [t80001] Child task id= 524289
[t80040000] [t80001]  ***Reply to: 262146 : HELLO back from 524289!
[t80040000] [tc0001] Child task id= 786433
[t80040000] [tc0001]  ***Reply to: 262146 : HELLO back from 786433!
[t80040000] [tc0002] Child task id= 786434
[t80040000] [tc0002]  ***Reply to: 262146 : HELLO back from 786434!
[t80040000] [t80002] Child task id= 524290
[t80040000] [t80002]  ***Reply to: 262146 : HELLO back from 524290!
kanaha% pvm
pvmd already running.
pvm> halt
[1]    Done                 pvmd3 hosts2
kanaha% 

PVM at the MHPCC


Tips, Tricks, Hints, and Miscellaneous Information


References, Acknowledgments, WWW Resources

Additional Sources of Information on the WWW

References and Acknowledgements


© Copyright 1995 Maui High Performance Computing Center. All rights reserved.

Documents located on the Maui High Performance Computing Center's WWW server are copyrighted by the MHPCC. Educational institutions are encouraged to reproduce and distribute these materials for educational use as long as credit and notification are provided. Please retain this copyright notice and include this statement with any copies that you make. Also, the MHPCC requests that you send notification of their use to help@mail.mhpcc.edu.

Commercial use of these materials is prohibited without prior written permission.

Last revised: 26 September 1996 Blaise Barney