B424 Parallel and Distributed Programming

Lab 1

Date: Tuesday, September 14, 2004. Under your home directory, create a folder named b424 with the command:

mkdir b424
Change the current directory to this new one:
cd b424
With similar operations, create a folder called hello and change the current directory to that one. Go back to the browser window and download the following two files into the folder you just created:
hello_world.cc
Makefile

Compile the program with the command

make
Launch the Beowulf cluster on your computer with the command
lamboot -v
If everything works well, you should receive a message saying "topology done".

Execute the program with the command:

mpirun -np 4 hello

The result of the program should be a group of hello messages from all processes, then a group of messages marking "after the barrier" mixed with messages communicating the value of n which should be 5.

Try it again by changing the number of processes (the number after the -np). If at any point your program is stuck in a deadlock, type Ctrl-C to stop its execution.

Modify the program such that the process with the rank 0 which is the source of the broadcast does not execute the call to this function, but all of the others do. Test the program again.

Modify the program such that the process with the rank (id) equal to 2 does not call the broadcast function, and all of the others do (including the process 0). Recompile the program and execute it again to see the result. What does this tell you about the function broadcast?

Modify the program again so that the process with the rank 2 calls the receive function instead of the broadcast. For this, you'll have to declare a variable status and add the following call:

MPI_Status status;
MPI_Recv(&n, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &status);
What can you deduce about combining broadcast calls with the receive function?

When you have finished your experiences, close the Beowulf cluster with the command

wipe

Don't forget to log out before you leave.