|
| |
I have written some programs that demonstrate the use of PVM. Let me just say PVM is a
nicely written piece of code. All of the functions are well documented in man pages and
there is very tight error detection. The message and data passing routines are very
intuitive and I found the example code very useful.
| Say Hi! |
| The first program I built was one that tested some of PVM's simpler
functions. This program just looked to see who was connected to the Virtual Network and
printed out their names. See the code for sayhi.c. |
| Primes |
| This was my first attempt at writing an actual application using PVM's
API. The purpose of the program was to find primes. The has two parts: a
master and a slave. The master maintains a current number that is to be tested and
spawns off one process that searches for any multiples of the number. This isn't a really
distributed architecture, but I just wanted to get used to the notion of sending and
receiving messages. The slave prime program took three parameters: the number being
tested, the number to start searching at, and the number to stop searching at. My
reasoning behind this trio was I thought that once numbers had twenty digits, it would be
a little easier to search for multiples with all of the machines. I later dropped this
notion because I was working with relatively small numbers (yes, 2 Billion is still a
small number compared with some of the numbers they're looking for primes for).
See the code for primes_master.c and prime_slave.c. |
| Primes,
take two! |
| The second version of the prime searching program used a little more
sophisticated approach. The first difference is that the child processes stay
resident on the remote machines. This requires the slave program be a little more
intelligent, but by keeping it resident, it reduces the amount of network traffic created
by the communicating processes and decreases the amount of time waiting for the slave
program to start. The second difference is that the master program spawns as many
processes as it can in its search. It maintains the current test number and waits
for responses from the slave processes. What's nice about this topology, other than being
partially parallel, is that since the slave processes return the number they tested along
with its primeality information, the order in which they are received is not important. At the last minute, I decided to do a little benchmarking with the
system I made. I was hoping to get the PVM system running on the NeXT machines because the
speed advantage would be more apparent. Anyway, the table below indicates my Virtual
Machine. It consisted of three PCs all running FreeBSD.
| Machine
# |
Machine
Type |
| 1 |
AMD 6x86 200 |
| 2 |
Pentium 233 MMX |
| 3 |
Pentium II-266 MMX |
The benchmark consisted of the prime_master2 program searching for
primes between two-billion and two-billion, ten-thousand. This table shows how the Virtual
Machine did while calculating primes. know that a single machine could have probably
calculated primes faster than all three did, but this table is just for demonstration
purposes.
| Configuration |
# of
Numbers |
Starting
Number |
Time
(min:sec) |
| 1 |
10,000 |
2 Billion |
0:15.80 |
| 1, 2 |
10,000 |
2 Billion |
0:12.99 |
| 1, 2, 3 |
10,000 |
2 Billion |
0:12.57 |
|
| 1 |
100,000 |
2 Billion |
2:35.05 |
| 1, 2 |
100,000 |
2 Billion |
2:06.05 |
| 1, 2, 3 |
100,000 |
2 Billion |
2:02.59 |
| * Bolded number indicates host computer. |
I think it should be noted that with three machines, the host machine
could not consume packets fast enough. If I had designed the program to send more than one
number to the slave program, I think it would have made the system more efficient.
See the code for prime_master2.c and prime_slave2.c. |
| Afterthoughts. |
| Looking back, I wish I had decided to change to this project sooner
because I could have added support for numbers that are bigger than two billion. Most of
the work in this field has been with numbers that have two hundred digits. It seems
fairly petty to be working with numbers that are supported natively by most compilers. Oh,
well. I guess it will give me something to work on over the summer! |
|