Difference between revisions of "How to Use MPI"
Line 38: | Line 38: | ||
|- | |- | ||
| -output-filename <name> || redirects output into the file <name>.<rank> | | -output-filename <name> || redirects output into the file <name>.<rank> | ||
− | | | + | |- |
| --help || lists all options available with an explanation | | --help || lists all options available with an explanation | ||
|} | |} |
Revision as of 12:01, 4 April 2018
Basics
This will give you a general overview of how to compile and execute a program that has been parallelized with MPI. Many of the options listed below are the same for both OpenMPI and Intel MPI, however, be care if they do differentiate.
How to Compile MPI Code
So, you’ve been given a code that you would like to execute. The first step is to compile it. Depending on whether your code is written in C or Fortran, follow the instructions in one of the tables below. Make sure to replace the arguments inside <…> with specific values.
OpenMPI
To ensure that the OpenMPI module is loaded, check the output of the following command:
$ module list
In case it has not been loaded yet, type
$ module load openmpi
If you are currently using IntelMPI as a default, type
$ module switch intelmpi openmpi
Now you’re ready to compile your OpenMPI code! Use the following command to specify the program you would like to compile (replace <src_file> with a path to your code, e. g. ./myprog.c).
C/C++ | Fortran |
$ mpicc [options] <src_file> | $ mpifort [options] <src_file> |
How to Run an MPI Executable
Don’t forget to put the “-np” or “-n” option as explained below. All the other options listed below are not mandatory.
Option | Function |
-np <num_procs> or -n <num_procs> | number of processes to run |
-path <path> | look for executables in the directory specified |
-q or –quiet | suppress helpful messages |
-output-filename <name> | redirects output into the file <name>.<rank> |
--help | lists all options available with an explanation |