The First Program - Communication Is Everything

Finally we reached the point where we can write and hopefully run our first PVM program.
This program is very simple but it will show you how to use PVM's most important features, starting programs on remote hosts and sending a message to another program.
The plan
Write a program which determines the names and the local time of all the physical machines in the virtual machine and prints the information to standard output.
The model
The most successful and probably the most straightforward model for writing parallel programs using PVM is called Master and Slave. The master process is the only one started by the user on one of the machines. It then starts and controls processes on the other machines which perform the actual work.
The master
has to do the following How this could look in C
How this could look in fortran
The slave
does the following How this could look in C
How this could look in fortran
Compile the source codes for the slave processes with the command,

cc -o answer c_slave.c -lpvm3

For Fortran users, you can find all commands and setup in our Makefile.

It is important that you call the executable answer as this is the name of the program the master process tries to start. If you are using computers of different architecture then you have to repeat this step on one machine of every architecture and immediately copy the executable into the architecture specific directories you created in your configuration step.

Compile the source codes for the master process by using the command,

cc -o master c_master.c -lpvm3

The resulting program is called master and you have to do this compilation only once on the machine where you want to run the master.

Let's Go
After you installed and configured PVM, created your own parallel machine, compiled all the programs and put them into their place all that is left to do is starting the master process from the unix prompt. Type

master

you should get a result similar to

The master process runs on mango
I found the following hosts in your virtual machine
mango
goophy
daphy
coconut
mango's time is Fri May 10 13:10:50 1996

daphy's time is Fri May 10 15:15:42 1996

coconut's time is Fri May 10 13:15:46 1996

goophy's time is Fri May 10 15:17:01 1996

which makes it pretty obvious that I really have to change the time on some of our computers.


Warning! At some point things may get somewhat confused with PVM, in which case it's a good idea to stop it and start over again. Sometimes, in order to restart PVM, you may have to change to the directory /tmp and remove some of the pvm files you have created there. (You can issue a long list command ls -l to see the names, owners, and creation times of files, and remove the files with the rm command.)
To make the whole process a little bit more transparent we included a step by step description of how this can be done.
Previous: The PVM console
Next: The bifurcation map - made to be parallized
Index: Getting started with PVM