Hprc banner tamu.png

Difference between revisions of "Ada:Compile:MPI"

From TAMU HPRC
Jump to: navigation, search
Line 77: Line 77:
 
=== Running MPI Code ===
 
=== Running MPI Code ===
  
Running mpi code requires a mpi launcher. The launcher will setup the environment and launch the requested number of mpi tasks. Use the following command to start a mpi program:  
+
Running mpi code requires a mpi launcher. The launcher will setup the environment and start the requested number of mpi tasks. Use the following command to start a mpi program:  
  
'''mpirun''' <mpi_flags> <executable> <executable params>
+
<pre>
 +
mpirun [mpi_flags] <executable> [executable params]
 +
</pre>
  
 +
where ''[mpi_flags]'' are options passed to the mpi launcher, ''<executable>'' is the name of the mpi program and ''[executable params]'' are optional parameters for the mpi program.
 
   
 
   
  

Revision as of 16:29, 2 December 2014

MPI Code

There are currently two MPI stacks installed on ADA; OpenMPI and Intel MPI. The recommended MPI stack for software development is the Intel MPI software stack and most of this section will focus on this MPI stack.

Compiling MPI Code

To compile MPI code a MPI compiler wrapper is used. The wrapper will call the appropriate underlying compiler with additional linker flags specific for MPI programs. The Intel MPI software stack has wrappers for Intel compilers as well as wrappers for gnu compilers. Any argument not recognized by the wrapper will be passed to the underlying compiler. Therefore, any valid compiler flag (Intel or gnu) will also work when using the mpi wrappers

The following table shows the most commonly used mpi wrappers used by Intel MPI.


MPI wrapper Compiler Language Example
mpiicc icc C mpiicc <compiler_flags> prog.c
mpicc gcc C mpicc <compiler_flags> prog.c
mpiicpc icpc C++ mpiicpcp <compiler_flags> prog.cpp
mpicxx g++ C++ mpicxx <compiler_flags> prog.cpp
mpiifort ifort Fortran mpiifort <compiler_flags> prog.f90
mpif90 gfortran Fortran mpif90 <compiler_flags> prog.f90


Example 1: compile MPI program named mpi_prog.c, written in C, and name it mpi_prog.x. Use the underlying Intel compiler with -O3 optimization

-bash-4.1$ mpiicc -o mpi_prog.x -O3 mpi_prog.c 

Example 2: compile MPI program that also contains OpenMP directives, written in Fortran, and name it mpi_prog.x. Use the underlying Intel compiler.

-bash-4.1$ mpiifort -o mpi_prog.x -openmp mpi_prog.f90

Example 3: same as Example 2, but this time use underlying gnu Fortran compiler.

-bash-4.1$ mpif90 -o mpi_prog.x -fopenmp mpi_prog.f90 

To see the full compiler command of any of the mpi wrapper scripts use the **-show** flag. This flag does not actually call the compiler, it only prints the full compiler command and exits. This can be useful for debugging purposes and/or when experiencing problems with any of the compiler wrappers

Example: Show the full compiler command for the mpiifort wrapper script

 -bash-4.1$ mpiifort -show 
ifort -I/software/easybuild/software/impi/4.1.3.049/intel64/include -I/software/easybuild/software/impi/4.1.3.049/intel64/include 
-L/software/easybuild/software/impi/4.1.3.049/intel64/lib -Xlinker --enable-new-dtags -Xlinker -rpath -Xlinker 
/software/easybuild/software/impi/4.1.3.049/intel64/lib -Xlinker -rpath -Xlinker -/opt/intel/mpi-rt/4.1 -lmpigf -lmpi -lmpigi -ldl -lrt -lpthread`


Running MPI Code

Running mpi code requires a mpi launcher. The launcher will setup the environment and start the requested number of mpi tasks. Use the following command to start a mpi program:

mpirun [mpi_flags] <executable> [executable params]

where [mpi_flags] are options passed to the mpi launcher, <executable> is the name of the mpi program and [executable params] are optional parameters for the mpi program.


Flag Description
-np <n> The number of mpi task to start
-n <n> The number of mpi task to start (same as -np)
-perhost <n> Place <n> consecutive processes on host
-ppn <n> Stands for Process Per Node (same as -perhost)
-hostfile <file> File containing host names.
-f <file> File containing hots names (same as -hostfile)
-hosts {host list} comma seperated list of hostnames
-help Shows list of available flags and options