Setting your MPI path
By default none of the MPI commands are in your path. The reason being is that there are multiple copies of MPI for the different network hardware and different compilers.
The base path for all the different MPI's is /opt/mpich below this directory are directories for ethernet and myrinet. The commands in these directories correspond to the type of hardware you want to use, so if you want your code to run on the Myrinet hardware use this path /opt/mpich/myrinet. Below both the Ethernet and Myrinet directories are gcc and icc directories. These directories are for different compilers, gcc is for the GNU compiler and icc is for the Intel compiler. Finally below each of these directories are a set of directories the only one that is important is bin which is where the commands to compile and run your code is.
Here is a complete list of the MPI paths:
So to set your path for Ethernet/GNU Comiler you would use the following commands.
For the bash shell:
export PATH=$PATH:/opt/mpich/gnu/bin
For the csh or tcsh shell:
setenv PATH /opt/mpich/gnu/bin:$PATH
Compiling MPI Code
The command to compile your MPI code is mpicc for C code and mpiCC for C++ code. They take the same arguments as the associated compiler.
There are two ways to use these commands to compile your code. First you can follow the directions in the previous section and add the proper path and type the command at the prompt. The other way would be to type the full path in front of command name.
Here are a couple of examples:
mpicc -o test test.c -lm
/opt/mpich/myrinet/gcc/bin/mpiCC -o test test.c -O5 -ffast-math -lm
Running MPI Programs
The command to run your MPI binary is mpirun. Again you can either add MPI to your path or type the full path in front of the command name. You can find a full set of arguments for mpirun by typeing man mpirun at the prompt.
Here are some examples:
mpirun -np 4 -machinefile test.in test -- This would run the program test on four processors, the first four listed in the file test.in.
/opt/mpich/myrinet/icc/bin/mpirun -np 4 -machinefile test.in test
The preferred method for running MPI programs on cortex is through the queue system. Please read the Queue System Howto located here.References