| Message Passing Interface (MPI) Exercise |
Make sure that you are logged into your assigned SP node with your assigned userid for this exercise. Ask the instructor if you have any questions.
The $WORKSHOP variable defines the root location for the workshop files, and may vary from workshop to workshop. Find out if this has already been setup for your workshop:
echo $WORKSHOP
If this environment variable is not set, check with the instructor for the correct location. Then, depending upon your shell, set $WORKSHOP:
| csh/tcsh | setenv WORKSHOP instructor/specified/path |
|---|
mkdir ~/mpi
cd ~/mpi
| C: | cp $WORKSHOP/mpi/samples/C/* ~/mpi |
| C: | cp $WORKSHOP/mpi/samples/Serial/C/* ~/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.
Descriptions and sample images for these codes are also available.
Select any or all of the exercise files. If a serial version exists, you may want to start by reviewing the serial version of the code. Most of the codes should have comments which explain how parallelism with MPI has been implemented.
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 |
You can also compile selected example codes individually - see the Makefile for details. For example, to compile just the Array example code:
| C: | make -f Makefile.MPI.c mpi_array |
In this step you'll set a few POE environment variables. Specifically, those which answer the three questions:
Depending upon your shell, set the following environment variables as shown:
| Description | csh/tcsh | ksh/bsh
| Request 4 nodes for 4 tasks
| setenv MP_PROCS 4 |
|---|
After setting up your execution environment, running the executables is as simple as just issuing the executable's name. A few exceptions are noted below:
This concludes the MPI exercise.