CS160 – Spring 2000 – Berman/Papadopoulos Program #1
Due by 4:40PM on April 28, 2000
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.
<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