Vuori User's Guide > Program development > Compilers
Tehdyt toimenpiteet

Compilers

This section describes the compilers on Vuori

Available compiler suites

Four different compiler suites are installed on the machine:

Compiler suite Version Module Man pages User guides
Portland Group (PGI) Default 10.2  PrgEnv-pgi

man pgcc        C
man pgCC      C++
man pgf90      F90/95
man pgf77      F77

  PGI
PathScale Compiler Suite (path) 3.2  PrgEnv-pathscale man pathcc     C/C++
man pathf95   Fortran
man eko         All flags
  PathScale
GNU Compiler Collection (GCC) 4.4  PrgEnv-gnu

man gcc          C/C++
man gfortran  Fortran

  GCC
Intel Compilers Professional Edition
suite (Intel)
11.1  PrgEnv-intel man icc           C/C++
man ifort         Fortran
  Intel

The active compiler package when logging in is PGI. To use another compiler package, or another version of a particular compiler package, one should switch the active package using the module system (see Module environment):

module swap PrgEnv-pgi PrgEnv-gnu   # swap PGI compiler to GNU compiler

Detailed information on the compilers is available in their respective user guides and man pages. To read a man page one should execute the man command after having switched to the relevant programming environment.

Compile command

When compiling one should always use a generic command such as f95 or mpif90, which refer to the compiler of the loaded compiler package.  The aliases are listed in the following table:

Language Serial/Parallel compiler Parallel MPI compiler
Fortran 77 f77 mpif77
Fortran 95 f95 mpif90
C cc mpicc
C++ CC mpiCC

For more information on compiling parallel programs, see the subsection Using MPI.

Choosing a compiler

There are two important factors that should be taken into account when choosing between the compilers: correctness and performance of the compiled program.

Correctness 
Some programs may only produce correct results when compiled with a particular compiler. It is also possible that the program produces wrong results when compiled using aggressive compiler optimizations. It is thus of key importance to always check that the compiled program actually produces correct results.
Performance 
One should choose the compiler gving the best performance, while still producing correct results. It is impossible to know ahead of time which compiler is the best for a particular program. One simply has to find the best compiler and its optimal compiler options using a 'generate and check' method. 

Selecting compiler options

The options available for the PGI, PathScale, GCC, and Intel compiler suites can be found in their individual sections on this page, from their man pages when the corresponding programming environment is loaded, or in the compiler manuals on the Web (see the first table).

In the table below we have listed good optimization flags for the installed compilers. It is best to start from the safe level and then move up to intermediate or even Aggressive, while making sure that the results are corerct and that the program is quicker.


PGI Pathscale GNU
Safe -O -O  -O2
Intermediate -fast -O3 -OPT:Ofast -O3
Aggressive -fast
-O3
-Mipa=fast
-Mfprelaxed
-Ofast
-LNO:simd=2
-O3
-funroll-loops
-ffast-math
-ftree-vectorize

Finally the following table shows some options that are common for all the compilers:

Option Description
-c Compiles only, produces unlinked object filename.o
-o filename Gives the name filename for the executable. Default: a.out
-g Produces symbolic debug information
-Idirname Searches directory dirname for include files or module files
-Ldirname Searches directory dirname for for library files specified by -l
-llibname Searches the specified library file with the name liblibname.a
-O[level] Specifies whether to optimize or not and at which level level