NERSCPowering Scientific Discovery Since 1974

GNU Compilers (Fortran, C, and C++)

Availability

The Cray Fortran, C, and C++ compilers are available on all NERSC systems.  To make this compiler the one used by the ftn, C, and C++ compiler wrappers on Hopper, type in the following

module swap PrgEnv-pgi PrgEnv-gnu

To make this compiler the one used by the mpif90, mpicc, and mpiCC compiler wrappers on Carver, type in the following:

module unload pgi openmpi
module load gcc openmpi-gcc

PackagePlatformCategoryVersionModuleInstall DateDate Made Default
GCC carver compilers/ programming 4.4.2 gcc/4.4.2 2010-02-08 2012-01-13
GCC carver compilers/ programming 4.5.2 gcc/4.5.2 2012-01-13
GCC carver compilers/ programming 4.6.1 gcc/4.6.1 2012-01-13
GCC carver compilers/ programming 4.7.0 gcc/4.7.0 2012-03-27 2012-04-11
gcc edison compilers/ general 4.4.4 gcc/4.4.4 2011-04-27
gcc edison compilers/ general 4.7.2 gcc/4.7.2 2012-11-08 2012-12-05
gcc genepool applications/ programming 4.6.3 gcc/4.6.3 2012-06-17 2012-07-15
gcc genepool applications/ programming 4.7.1 gcc/4.7.1 2012-07-10 2012-07-10
gcc hopper compilers/ programming 4.4.4 gcc/4.4.4 2010-09-01
gcc hopper compilers/ programming 4.5.2 gcc/4.5.2 2010-01-25 2010-01-25
gcc hopper compilers/ programming 4.6.2 gcc/4.6.2 2012-01-17 2012-03-20
gcc hopper compilers/ programming 4.7.1 gcc/4.7.1 2012-07-12 2012-08-15
gcc hopper compilers/ programming 4.7.2 gcc/4.7.2 2012-11-29
gcc pdsf compilers/ general 4.3.2 gcc/4.3.2 2012-03-12
gcc pdsf compilers/ general 4.6.2 gcc/4.6.2 2012-03-12 2012-03-12
gcc phoebe applications/ programming 4.6.3 gcc/4.6.3 2012-07-15 2012-07-15
gcc phoebe applications/ programming 4.7.1 gcc/4.7.1 2012-07-10

Optimization

-O0

(Default).   Reduce compilation time and make debugging produce the expected results.

-O/-O1

The compiler tries to reduce code size and execution time, without performing any optimizations that take a great deal of compilation time.  The following optimization flags are turned on:  -fauto-inc-dec -fcprop-registers -fdce -fdefer-pop -fdelayed-branch -fdse -fguess-branch-probability -fif-conversion2 -fif-conversion -finline-small-functions -fipa-pure-const -fipa-reference -fmerge-constants -fsplit-wide-types -ftree-ccp -ftree-ch -ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-fre -ftree-sra -ftree-ter -funit-at-a-time.

-O2

In addition to the -O/-O1 optimizations nearly all supported optimizations are performed that do not involve a space-speed tradeoff. The compiler does not perform loop unrolling or function inlining.  The additional optimization flags included are:  -fthread-jumps -falign-functions -falign-jumps -falign-loops -falign-labels -fcaller-saves -fcrossjumping -fcse-follow-jumps -fcse-skip-blocks -fdelete-null-pointer-checks -fexpensive-optimizations -fgcse -fgcse-lm -foptimize-sibling-calls -fpeephole2 -fregmove -freorder-blocks -freorder-functions -frerun-cse-after-loop -fsched-interblock -fsched-spec -fschedule-insns -fschedule-insns2 -fstrict-aliasing -fstrict-overflow -ftree-pre -ftree-vrp.

-O3

Add these option to the -O2 options:  -finline-functions, -funswitch-loops, -fpredictive-commoning, -fgcse-after-reload and -ftree-vectorize.

-Os

Optimize for size.   -Os enables all -O2 optimizations that do not typically increase code size. It also performs further optimizations designed to reduce code size.  -Os disables the following optimization flags: -falign-functions -falign-jumps -falign-loops -falign-labels -freorder-blocks -freorder-blocks-and-partition -fprefetch-loop-arrays -ftree-vect-loop-version.

If you use multiple -O options, with or without level numbers, the last such option is the one that is effective.

Debugging Options

  • -g - generates symbolic debug information used by a debugger.
  • -fbounds-check - For front-ends that support it, generate additional code to check that indices used to access arrays are within the declared range.  This is currently only supported by the Java and Fortran front-ends, where this option defaults to true and false respectively.

Documentation.

GNU documentation.