CS475 Lab 5 Getting Started with MPI

This lab is intended to introduce you to MPI. For your enjoyment, you are provided with a version of the SAT code discussed in class.

Also, you will edit skeleton code to pass messages around in a circle, and to exchange messages between consecutive processes. This exercise is not about speed up, it is just about learning to write message passing code. Still, there is timing code provided, so you can see how to time in MPI. In the CS lab we use openmpi. Download and untar the provided mess.tar file. To be clear there are 3 distinct tasks:

  1. sat: run and report execution times on CS machines and the Cray

    This is a complete code provided to you. It shows collective communication and timing.
  2. cycle: edit this code to complete the message passing

    This program sends messages of a certain size a certain number of times around a circle of processes. The message passing is initiated by process 0: it sends to process 1, and receives from process p-1. The other processes receive from their left neighbor and send to their right neighbor. Notice that (p-1)-s right neighbor is 0.
  3. exchange: edit this code to complete the message passing

    This program exchanges messages of a certain size a certain number of times between processes. Process 0 only communicates with process 1, process p-1 only communicates with process p-2. All other processes communicate with their right and left neighbor.

Running the Code

Make sure you have openmpi in your path and library load path, when running on CS (state-capital) machines:

echo $path
...  /usr/lib64/openmpi/bin .

echo $LD_LIBRARY_PATH
...:/usr/lib64/openmpi/lib

To set the environment variable in Bash terminals, use the following commands

export PATH=/usr/lib64/openmpi/bin:$PATH
export LD_LIBRARY_PATH=/usr/lib64/openmpi/lib

Run your programs with mpirun in CS machines, example:

To run the program "exchange" with 4 processes
	mpirun -np 4 exchange 5 100 v

Run your programs with aprun on the Cray, example:

Use the following command to swap to gcc
	module list
	module swap PrgEnv-cray PrgEnv-gnu
To compile your programs in CRAY
	Change Makefile: CC = cc (instead of CC = mpicc)

To run your programs in CRAY
	Copy the executables in to "lustrefs" directory
	To run the program "sat" with 4 processes
		aprun -n4 sat