Compilers

From PHASTA Wiki
Jump to: navigation, search


We have access to several different sets of compilers and libraries. Ideally your code should work with all of them, and you can test which produces the fastest executables. Some also have different debugging features.

GNU

The GNU toolchain is the standard in the open source world and tends to be the most compatible (at least for C/C++ code). Several versions which ship with the operating system should be available by default and can be invoked as:

 gcc #C code
 g++ #C++ code
 gfortran #F77, F90

To compile with debug support add at least

 -g

to your compile flags. Adding

 -g -O0 -fno-omit-frame-pointer -fbounds-check -ftrapv

may make the code easier to debug. See the manpages for language specific options.

To generate an optimized build start with

 -O3

and see the manpage for more optional optimizations.

There are also some newer versions available using the softenv tool. Note that if you use a newer GNU toolchain, you should also have it loaded into your environment at runtime to ensure that the correct libraries are used.

Intel

The Intel toolchain typically generates fast executables for Intel processors. It also ships with some debugging and profiling tools. You can load the Intel toolchain by executing:

 soft add +intelcompilers-64bit

You can then invoke

 icc #C
 icpc #C++
 ifort #F90/F77/F2003

There are some known issues with debugging Fortran code (particularly if it uses dynamically allocated arrays) using the Intel toolchain. These bugs seem to be fixed in the release version of Intel 2013, which is starting to become available on some machines (not ours yet)

For debugging, you need at a minimum

 -g

For best results, try

 -O0 -debug all -fstack-protector -no-ipo -g

For an optimized build, start with:

 -O3

and check the manpage for more options.

When compiling Fortran, it is a good idea to also pass

 -fheap-arrays

The Intel debugger is called

 idb

(but note that it consumes a license for the entire compiler suite, so please don't leave it running for long periods of time)

Portland

The PGI toolchain is an alternative toolchain, with which we have had good luck debugging Fortran codes. It also supports OpenACC (like OpenMP for GPUs)

You can load the PGI compilers by running

 soft add +pgi-64bit

and invoke them as

 pgcc #C
 pgCC #C++
 pgfortran #various Fortran
 pgf90 #F90
 pgf77 #F77

Note that PGI 11.x has some bad C++ related bugs. You should use PGI 12 or newer.

If you experience extremely long link times (particularly with PGI version 12.3), try adding

 -Mnoipa 

to your compiler flags. Note that this flag has a runtime performance cost.

LLVM/Clang

 soft add @llvm-3.2svn

LLVM/Dragonegg