CS160 – Spring 2000 – Berman/Papadopoulos                                    Program  #1

Due by 4:40PM on April 28, 2000

 

Introduction to PVM

 

  1. PVM has a very primitive scheduler for where to place tasks – it is round-robin across all machines in the VM. It is desirable to have better control of where individual processes of parallel tasks are actually started.  Your first task is to build a generic program launcher called myLauncher.  MyLauncher assumes that PVM is up and running and that the virtual machine has already been constructed. The program takes the following arguments

 

myLauncher hostfile nprocs command [command_args]

  hostfile – list of hosts on which to start command

  nprocs -  number of  copies of command to start

      command – the comm. and to start eg. /bin/hostname

      command_args – arguments to the command

 

example:

      myLauncher hosts 10 /bin/uname –a

where hosts is a file listing hostnames

 

myLauncher should spawn command on the first nprocs hosts in the hostfile. If nprocs is greater than the number of hosts listed, then the program should start at the beginning of the hostfile and continue spawning tasks until nprocs tasks have been started. If present, command_args must be passed to all copies of command.

 

MyLauncher should capture standard output of all spawned programs using pvm_catchout(). If any of the remote processes fail at startup (by checking the output code of pvm_spawn), then myLauncher should kill (using pvm_kill()) any started tasks, print out the error code, and exit.

 

To simplify your coding, assume that nprocs <= 32,  the string length of command and command_args <= 256.

 

  1.  Communication rings and binary reduction trees are common methods to structure communications.  PVM assigns task ids that have meaning for routing messages, but are quite cumbersome for writing SPMD programs. PVM provides a group server to map PVM task ids (TIDS) to group instance numbers, making SPMD-style node labeling much easier.  A group of size N has instance numbers 0, 1, … N –1. To experiment with the numbering and labeling of groups, write an SPMD-style program called ringGatherer that takes nprocs as an argument and performs the following steps:

 

    1. Join the group prog1_group using pvm_joingroup().
    2. After all nprocs members have joined, make the group static using pvm_freezegroup().
    3. Perform a ring gather of information as follows: Starting with group instance nprocs-1, obtain the name of the local machine and the current load on that machine. String print the name of the machine, it’s TID, it’s group instance number, and current load with the following format

 

<instance> <hostname> <tid (hex)> <current load (float)>

 

                        Instance N-1 sends this information to instance N-2. N-2 passes it’s and N-1’s information to N-3 in a single message( look at pvm_pkstr() and pvm_pkfloat()). Finally, instance 0 should have all other nodes information passed to it in a single message from instance 1. Instance 0 should print out this information starting with node N-1’s information first. Each instance’s information should be printed out on a separate line.  Node 0 should also calculate the average of all uptimes and print  out this information.

                       

d.      Perform a tree gather of the same information in c, above in a program called treeGatherer. For this, a binary reduction tree should be used so that  0 gathers information from 1 and 2, 1 gathers from 3 and 4, 2 gathers from 5 and 6, 3 gathers from 7 and 8, and so on. So every intermediate node should get information from at most two sources (receive at most two messages). Do not assume that nprocs is a power of 2 for this reduction. Again, only instance 0 should print out the information gathered from all other nodes, as well as the average of the average of the uptimes. The print out should be in “tree order”.

e.       Assume that nprocs <=32.

 

Grading Criteria

            Correctness

                        Programs must produce the correct output for various inputs.

 

            Readability

                        Your code should not look like spaghetti.

 

            Documentation

                        All functions should be well commented.

 

Submission Instructions

 

            Create a directory prog1, which contains the following files:

 

myLauncher.c, ringGatherer.c, treeGatherer.c

As described above.

 

Makefile.aimk

                        Do a “man aimk” for a description of aimk and a simple example for hello.c.  Note that you may program on any environment you like, but your final submission must be buildable and executable on the APE lab machines.

 

Readme

            Describe how far you got, any remaining bugs, and general notes as necessary.

 

Finally, do these last two steps:

 

prompt> tar cvf prog1.tar prog1

prompt> turnin –c cs160s prog1.tar