- Login to the workshop machine
Workshops differ in how this is done. The instructor will go over this
beforehand
- Copy the example files
- In your SP home directory, create a subdirectory for the MPI test codes
and cd to it.
mkdir ~/mpi
cd ~/mpi
- Copy either the Fortran or the C version of the parallel MPI exercise
files to your mpi subdirectory:
C:
|
cp /usr/global/docs/training/blaise/mpi/C/* ~/mpi
|
Fortran:
|
cp /usr/global/docs/training/blaise/mpi/Fortran/* ~/mpi
|
- Some of the example codes have serial versions for comparison. If you are
interested in comparing/running the serial versions of the
exercise codes, use the appropriate command below to copy those files
to your mpi subdirectory also.
C:
|
cp /usr/global/docs/training/blaise/mpi/Serial/C/* ~/mpi
|
Fortran:
|
cp /usr/global/docs/training/blaise/mpi/Serial/Fortran/* ~/mpi
|
- List the contents of your MPI subdirectory
You should notice quite a few files. The parallel MPI versions have names
which begin with or include mpi_. The serial versions have
names which begin with or include ser_. Makefiles are
also included.
Note: These are example files, and as such, are intended to
demonstrate the basics of how to parallelize a code. Most execute in
a second or two. The serial codes will be faster because the problem sizes
are so small and there is none of the overhead associated with parallel
setup and execution.
- Review the array decomposition example code
Depending upon your preference, take a look at either mpi_array.c or
mpi_array.f. The comments
explain how MPI is used to implement a parallel data decomposition on
an array. You may also wish to compare this parallel version with its
corresponding serial version, either ser_array.c or ser_array.f.
- Compile the array decomposition example code
Invoke the appropriate IBM compiler command:
C:
|
mpcc -q64 -O2 mpi_array.c -o mpi_array
Fortran:
|
mpxlf -q64 -O2 mpi_array.f -o mpi_array |
|
- Setup your execution environment
In this step you'll set a few POE environment variables. Specifically,
those which answer the three questions:
- How many tasks/nodes do I need;
- How will nodes be allocated?
- How will communications be conducted (protocol and network)?
Set the following environment variables as shown:
Environment Variable |
Description |
setenv MP_PROCS 4 |
Request 4 MPI tasks |
setenv MP_NODES 1 |
Specify the number of nodes to use |
setenv MP_RMPOOL 0 |
Selects the interactive node pool |
- Run the executable
Now that your execution environment has been setup, run the array
decomposition executable:
mpi_array
- Try any/all of the other example codes
The included Makefiles can be used to compile any or all of the exercise
codes. For example, to compile all of the parallel MPI codes:
C:
|
make -f Makefile.MPI.c
Fortran:
|
make -f Makefile.MPI.f |
|
You can also compile selected example codes individually - see the Makefile
for details. For example, to compile just the matrix multiply example code:
C:
|
make -f Makefile.MPI.c mpi_mm
Fortran:
|
make -f Makefile.MPI.f mpi_mm |
|
In either case, be sure to examine the makefile to understand the actual compile
command used.
Most of the executables require only 4 MPI tasks or less. Exceptions are noted below.
mpi_array
| Requires that MP_PROCS be evenly divisible by 4
|
mpi_group
mpi_cartesian
| mpi_group requires 8 MPI tasks
mpi_cartesian requires 16 MPI tasks
You can accomplish this with a combination of MP_PROCS, MP_NODES
and MP_TASKS_PER_NODE environment variables.
|
mpi_wave
mpi_heat2D
| These examples attempt to generate an X windows display.
You will need to make sure that your Xwindows environment and
software is setup correctly. Ask the instructor if you have any
questions.
|
mpi_latency
mpi_bandwidth
| The mpi_latency example requires only 2 MPI tasks, and the mpi_bandwidth
example requires an even number of tasks.
Setting MP_EUILIB to us then ip will demonstrate the
difference in performance between User Space and Internet communications
protocols. Try comparing communications bandwidth when both tasks are
on the same node versus different nodes too. |
- When things go wrong...
There are many things that can go wrong when developing MPI programs. The
mpi_bugX.X series of programs demonstrate just a few.
See if you can figure out what the problem is with each case and then fix it.
Use mpcc -q64 or mpxlf -q64 to compile each
code as appropriate.
The buggy behavior will differ for each example. Some hints are provided
below.