A
roundtrip
Here is a simple MPI-exercises to get
you going. You may use C or
Fortran.
We would like to send a message (an
integer) to a set of
processes. The master process sets the integer to zero after which the
master sends the integer to the first worker/slave (in rank
order). The work process adds one to the integer and sends it on to the
next worker etc. The last worker sends the number back to the master,
who prints the number (the number of slaves, in other word).
To run in parallel you can use any of the five remote-machines,
remote1.studat.chalmers.se to remote5.studat.chalmers.se. To see the
load on the CPUs, give the unix-command top and type 1 (digit one) with
the mouse in the top
window. If it looks something like this (on a four-CPU machine) before starting your program:
Cpu0 : 18.0% us, 81.6%
sy, 0.3% ni, 0.0% id, 0.0% wa, 0.0% hi,
0.0% si
Cpu1 : 22.0% us, 78.0%
sy, 0.0% ni, 0.0% id, 0.0% wa, 0.0% hi,
0.0% si
Cpu2 : 27.3% us, 72.7%
sy, 0.0% ni, 0.0% id, 0.0% wa, 0.0% hi,
0.0% si
Cpu3 : 99.7% us, 0.3%
sy, 0.0% ni, 0.0% id, 0.0% wa, 0.0% hi,
0.0% si
you do not expect to get good speedups. User time plus system time (us
+ sy) is almost a 100 % on each CPU (the cpus are all 0.0% idle, i.e.
they are busy). The following situation is better but not perfect.
Doing a test on three CPUs should work well.
Cpu0 : 0.3% us,
1.3% sy, 0.0% ni, 98.0% id, 0.3% wa, 0.0% hi,
0.0% si
Cpu1 : 0.0% us,
3.3% sy, 27.5% ni, 69.3% id, 0.0% wa, 0.0% hi, 0.0% si
Cpu2 : 0.3% us,
0.0% sy, 0.0% ni, 99.7% id, 0.0% wa, 0.0% hi,
0.0% si
Cpu3 : 37.1% us, 2.6%
sy, 0.0% ni, 59.9% id, 0.3% wa, 0.0% hi, 0.0% si
