| ACADEMIC COMPUTING and COMMUNICATIONS CENTER | |||||||||
ARGO-NEW: The Message Passing Interface (MPI) | ||||||||||||
| Overview | ||||||||||||
|
MPI (Message Passing Interface)* is a library specification the foundation of which is a group of functions that can be used, either in Fortran or C, to achieve parallelism. An MPI function permits one process to talk to another by the transmission of data (messages). There is one implementation of MPI on the cluster: |
||||||||||||
| Setting up the MPI environment | ||||||||||||
MPICH version 2Home location: /usr/common/mpich2-1.0.1 You will make two changes: one to the PATH variable; the other, the LD_LIBRARY_PATH. The former is mandatory. The latter is optional depending on the compiler you use. If you login shell is C, then the changes are made to the .cshrc file. If you use bash, then the changes are to the .bash_profile file. To see which shell is your default, enter:
If the output is /bin/bash, you are using the bash shell; if /bin/csh, then the C shell. For a bash shell user, append the following in .bash_profile:
For a C shell user, append the following in your .cshrc:
Note: If you do not use the GNU compilers (instead, you use the supported Portland Group compilers), then the change to the LD_LIBRARY_PATH is unncessary because you will specify the appropriate library path with the -L option in the compile statement. See example below. MPICH version 1Home: /usr/common/pgi/linux86/6.0 Version 1 is included with the Portland Group compilers. Several enviromental variables must be defined or changed. The user must manually set them in the login file (.bash_profile for bash shell and .cshrc for C shell). To see which shell you use, enter the following command:
If the output is /bin/bash, you are using the bash shell; if /bin/csh, then the C shell. If you are a bash shell user, append the following in your .bash_profile file:
If you are a C shell user, append the following in your .cshrc file:
|
||||||||||||
| Available and Supported compilers | ||||||||||||
|
The GNU compilers as well as those from Portland Group are compatible with both versions of MPI. For more information about compilers, see the Available Software page. |
||||||||||||
| Executing an example program to test your environment (for MPICH2 only) | ||||||||||||
|
Below are two sample scripts (both named my_script): one for bash shell users; the other, C shell users: #! /bin/bash export MPICH2_HOME=/usr/common/mpich2-1.0.1 export PATH=$MPICH2_HOME/bin:$PATH mpiexec -n 3 $MPICH2_HOME/examples/cpi#! /bin/csh setenv MPICH2_HOME /usr/common/mpich2-1.0.1 setenv PATH=($MPICH2_HOME/bin $path) mpiexec -n 3 $MPICH2_HOME/examples/cpi To execute the appropriate example, enter: The expected output is something like
If you have been using MPICH version 1, then the mpirun command is how you started your MPI program. While MPICH2 provides an mpirun command for backward compatability, mpiexec is the recommended execution command. Compiling and Linking the Parallel Hello World Program using MPICH2The following example illustrates compiling using the Portland Group compilers:
The -L/usr/common/mpich2-1.0.1/lib is required when using Portland
Group compilers; without it, the compiler will use MPICH version 1 libraries
and not version 2.
The following scripts are another way to compile and link your program:
Each script invokes the appropriate GNU compiler.. Compiling and Linking the Parallel Hello World Program using MPICHpgcc -o mpihello hello1.c -D REENTRANT -lmpich Link flagsVanilla MPI:
|
||||||||||||
| Running an MPI program | ||||||||||||
|
Use the qsub command to submit an MPI job to torque. Vanilla MPI requires a machine file which will contain the names of the nodes to be used to run a job. There is no required name for the machine file though it is recommended that a useful name be selected. It is also recommended that file be placed in a home directory though it is not required. The format of the machine file is one node per line with the names left-justified. For example:
the above machine file is called node_file and is located in the home directory. Obviously, your node file may have more or less nodes than is shown in the example. There are two scripts that are used in the running of a example vanilla MPI job. Here is the key information:
Script #1 (x1):
Script #2 (x):
To excute the MPI program hello, enter the following:
The x1 script
The x script
Warnings and gotchas:
|
||||||||||||
| Examples | ||||||||||||
| Help | ||||||||||||
|
General MPICH2 informarion can be found at: Message Passing Interface Forum: MPI-2: Extensions to the Message-Passing Interface:
|
||||||||||||
| 2007-4-23 ACCC Systems Group |
|