|
Workshops differ in how this is done. The instructor will go over this beforehand
mkdir ~/mpi cd ~/mpi
C: | cp /usr/global/docs/training/blaise/mpi/C/* ~/mpi |
Fortran: | cp /usr/global/docs/training/blaise/mpi/Fortran/* ~/mpi |
C: | cp /usr/global/docs/training/blaise/mpi/Serial/C/* ~/mpi |
Fortran: | cp /usr/global/docs/training/blaise/mpi/Serial/Fortran/* ~/mpi |
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.
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.
Invoke the appropriate IBM compiler command:
C: | mpxlc -blpdata -q64 -O2 mpi_array.c -o mpi_array |
In this step you'll set a few POE environment variables. Specifically, those which answer the three questions:
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 pclass |
Selects the interactive node pool |
Now that your execution environment has been setup, run the array decomposition executable:
mpi_array
If we had more time, you might even be able to start with a serial code or two and create your own parallel version. Feel free to try if you'd like.
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 make -f Makefile.Ser.c |
Fortran: | make -f Makefile.MPI.f make -f Makefile.Ser.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 |
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_USE_BULK_XFER to "yes" will demonstrate the difference in performance between RDMA and non-RDMA communications. Try comparing communications bandwidth when both tasks are on the same node versus different nodes too. |
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 mpxlc or mpxlf to compile each code as appropriate.
The buggy behavior will differ for each example. Some hints are provided below.
Code | Behavior | Hints/Notes |
---|---|---|
mpi_bug1 | Hangs | |
mpi_bug2 | Seg fault/coredump/abnormal termination | |
mpi_bug3 | Error message | |
mpi_bug4 | Hangs and gives wrong answer. Compare to mpi_array | Number of MPI tasks must be divisible by 4. |
mpi_bug5 | Dies or hangs - depends upon AIX and PE versions | |
mpi_bug6 | Terminates (under AIX) | Requires 4 MPI tasks. |
This completes the exercise.
![]() |
Please complete the online evaluation form if you have not already done so for this tutorial. |
Where would you like to go now?