Week 11 - Practical Exercise

Aims

Tasks

Exercise 1

Firstly copy the Examples directory of Lecture 20 to where you are doing this tutorial: bourbaki.Week_11> cp -r ~comp309/Lectures/Lecture_20/Examples/ . Make sure the example programs all compile.

Exercise 2

OK, to run MPI programs we need to use mpirun.

Examples> mpirun -np 1 helloworld
        Hello World!
Examples> mpirun -np 2 helloworld
        Hello World!
        Hello World!

As you would have guessed, the -np flag specifies the number of copies of helloworld to execute.

Exercise 3

Now for something a little more interesting. Try running the whereAmI program:

bourbaki.Examples> mpirun -np 2 whereAmI
I'm clone 0 out of 2 total located @ bourbaki
I'm clone 1 out of 2 total located @ bourbaki

Now we can try adding some nodes to see some different results. To do this, create a file (say myhosts with a list of hosts you want to add:

b1
b2
.
.
b8

And run whereAmI again using the –bynode and –hostfile options

[comp309@b1 ~]$ mpirun -np 5 --bynode --hostfile myhosts whereAmI
I'm clone 0 out of 5 total located @ b1
I'm clone 1 out of 5 total located @ b2
I'm clone 2 out of 5 total located @ b3
I'm clone 4 out of 5 total located @ b5
I'm clone 3 out of 5 total located @ b4