CS475 Lab 5, MPI Start
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:
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.
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.
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 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:
mpirun -np 4 exchange 5 100 v
Run your programs with mpirun on the Cray, example:
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
Lab Report
The lab report should follow a slightly different format/outline.
- Algorithm description (all 3)
- Parallelization approach. This can be combined with the algorithm
description. Focus on message order and communication types.
- Experimental setup (both machines)
- Performance Results. This time you don't need speedup. Just report
your observed execution times.
- Questions to answer:
- What order did you choose for the messages in exchange? Why?
- Provide a listing of the 3 pieces of code you were asked to provide in exchange.
- How do you know if the messages were successfully sent and recieved?
- What order did you choose for the messages in cycle? Why?
- Provide a listing of the 2 pieces of code you were asked to provide in cycle.
- How do you know if the messages were successfully sent and recieved?
- Was the execution time of sat faster on the CS machines or the Cray?