Difference between revisions of "Compilers"

From PHASTA Wiki
Jump to: navigation, search
(Created page with "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...")
 
Line 24: Line 24:
  
 
   soft add +intelcompilers-64bit
 
   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.
 
There are some known issues with debugging Fortran code (particularly if it uses dynamically allocated arrays)  using the Intel toolchain.
 +
 +
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.
 +
 +
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.
 +
 +
==LLVM/Clang==
 +
  soft add @llvm-3.2svn
 +
 +
==LLVM/Dragonegg==

Revision as of 18:33, 28 September 2012

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.

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.

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.

LLVM/Clang

 soft add @llvm-3.2svn

LLVM/Dragonegg