This lab and solution is for the talk Introduction to PVM. Copyright 1992 by Cornell University Before starting the lab: If you can open more than one window on your screen, then leave these instructions in one window and type the commands in another. If your screen does not have windows, you may wish to print out these instructions so that you can refer to the text while you work through the lab. Introduction to PVM 2.4 Lab Exercises (with solutions) (1) In this lab, you will run a PVM code in an "n" machine parallel cluster. The machines available for this exercise are the ones assigned to you prior to the beginning of this lab. All instructions for this lab exercise should be executed from the local RS6000 that you are already (2) Check to make sure that the pvmd executable is installed on this system. % ls -l /tmp/pvm/pvmd (3) Review the online documentation for PVM (man pages are for C routines only -- there are no man pages for FORTRAN routines). % man pvm_intro % man pvmd % man libpvm % man {individual pvm library routines} (4) Optional. Create a .rhosts file in your home directory which will give trusted hosts permissions to your cluster machines. This file must contain at least the name of the machine you are currently logged on to; all other machines are optional. % cd ~ % vi .rhosts {then insert the following, substituting the correct hostnames and userid} host1.tc.cornell.edu myuserid host2.tc.cornell.edu myuserid host3.tc.cornell.edu myuserid (5) Create an architecture specific PVM directory within your home directory -- for an RS/6000 this should be called pvm/RIOS. This is where your PVM codes should reside. % cd % mkdir pvm pvm/RIOS (6) Create a PVM hostfile (call it myhostfile) that lists your cluster machines. The first machine listed should be the "master" machine, the machine that you are currently logged onto. Don't forget to use the pw option if you decided NOT to create a .rhosts file. % cd ~/pvm/RIOS See examples hostfiles in the Introduction to PVM presentation. (7) The following files are located within the subdirectory: /usr/local/doc/training/pvm2.4/Intro.to.PVM.Lab C Language files: Fortran files: pvm.ex1.master.c pvm.ex1.master.f pvm.ex1.worker.c pvm.ex1.worker.f make.pvm.ex1.c make.pvm.ex1.f Select either the C or the Fortran files and copy them to your own ~/pvm/RIOS directory. For example, you may use the following command: % cp /usr/local/doc/training/pvm2.4/Intro.to.PVM.Lab/*ex1*.c . - or - % cp /usr/local/doc/training/pvm2.4/Intro.to.PVM.Lab/*ex1*.f . (8) Review the example master and worker programs and notice the PVM library calls, as well as the message passing logic. (9) Review the example makefile and notice the compile options that are in effect for PVM programs. Then, use the example makefile to compile the PVM example master and worker programs. % make -f make.pvm.ex1.c - or - % make -f make.pvm.ex1.f (10) Start the master pvmd in the background on your local host. It will automatically start the pvmds on the remote hosts. % /tmp/pvm/pvmd myhostfile & wait for the message "pvm is ready." You may need to press RETURN to get the prompt back afterwards. (11) Execute the master program several times and notice the output. You should notice that the workers do not always finish "in order" and that upon completion of an execution, a new "epoch" will follow. % ex1.m (12) Quit PVM. Remember that PVM is running in the background. Use "ps" to find the process number of /tmp/pvm/pvmd. Then issue the "kill" command on that process number. NOTE: If you are having unusual problems starting the PVM daemons or running your application, try using the pvmcleanup utility. The syntax is: pvmcleanup myhostfile <-u user components> The -u option permits you to specify a list of components that will be searched for and killed, in addition to any hung PVM daemons. If time permits..... (13) In window #1, Start PVM in the interactive mode and try some of the commands. % /tmp/pvm/pvmd -i myhostfile You should then see "starting on" messages followed by the pvmd prompt. Try the "help" and "conf" commands. pvmd, help pvmd, conf See the man page for pvmd for additional information and explanations. In window #2 (create if needed) Telnet and login to your PVM host machine in the cluster. Then cd to your pvm/RIOS directory and execute the host program. % ex1.m Notice that output from the worker instances is passed back to the master pvmd and that output from the master instance is displayed wherever it is executed. Edit your pvm.ex1.worker program (C or Fortran version) to include a "sleep" delay. You can add the call to sleep immediately before the call to pvm_exit (C version) or pvmfexit (Fortran version). The appropriate call to sleep is: For C: sleep(10); For Fortran call sleep_(10) Recompile (use the appropriate makefile) and then execute the master component again (window #2), but this time, try issuing a "ps -a" command in window #1 while it's running. If you time this right, (while there is actual activity in the worker instances) a runtime status will display in window #1. It will also be interspersed with output from the pvmds on remote machines. When you're finished, kill the interactive PVM session by entering "quit" in window #1. Last revised: 6/27/93 bbarney