NERSCPowering Scientific Discovery Since 1974

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

Availability

The GNU/GCC Fortran, C, and C++ compilers are available on all NERSC systems.  Current NERSC GNU/GCC bugs are listed at GNU bugs.

On Hopper, use the following:

% module swap PrgEnv-pgi PrgEnv-gnu

On Edison, use this:

% module swap PrgEnv-intel PrgEnv-gnu

On Carver, type the following:

% module swap pgi gcc
% module swap openmpi openmpi-gcc

PackagePlatformCategoryVersionModuleInstall DateDate Made Default
GCC babbage compilers/ programming 4.8.0 gcc/4.8.0 2014-08-27 2014-08-27
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 carver compilers/ programming 4.7.3 gcc-sl6/4.7.3 2013-10-24 2013-10-24
GCC carver compilers/ programming 4.8.0 gcc/4.8.0 2013-05-01
GCC carver_sl6 compilers/ programming 4.8.3 gcc/4.8.3 2014-07-01 2014-07-01
GCC edison compilers/ programming 4.4.7 gcc/4.4.7 2014-10-24
gcc edison compilers/ general 4.8.2 gcc/4.8.2 2014-04-24 2014-04-24
gcc genepool applications/ programming 2013.1.117 intel/2013.1.117 2013-06-13 2013-06-13
gcc genepool applications/ programming 4.6.3 gcc/4.6.3 2012-06-17 2012-07-15
gcc genepool applications/ programming 4.6.4 gcc/4.6.4 2014-12-10
gcc genepool applications/ programming 4.7.1 gcc/4.7.1 2012-07-10 2012-07-10
gcc genepool applications/ programming 4.7.2 gcc/4.7.2 2013-03-20
gcc genepool applications/ programming 4.7.3 gcc/4.7.3 2013-04-25
gcc genepool applications/ programming 4.8.0 gcc/4.8.0 2013-04-25
gcc genepool applications/ programming 4.8.1 gcc/4.8.1 2013-06-02
gcc genepool applications/ programming 4.9.2 gcc/4.9.2 2014-12-10
gcc genepool_sl6 applications/ programming 4.6.4 gcc/4.6.4 2014-12-10 2014-12-10
gcc genepool_sl6 applications/ programming 4.8.3 gcc/4.8.3 2014-12-09 2014-12-09
gcc genepool_sl6 applications/ programming 4.9.2 gcc/4.9.2 2014-12-09
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 pdsf_sl6 applications/ programming 4.8.1 gcc/4.8.1 2013-07-17 2013-07-17
gcc phoebe applications/ programming 2013.1.117 intel/2013.1.117 2013-06-18 2013-06-26
gcc phoebe applications/ programming 4.6.3 gcc/4.6.3 2013-06-18 2013-06-26
gcc phoebe applications/ programming 4.7.1 gcc/4.7.1 2013-06-18
gcc phoebe applications/ programming 4.7.2 gcc/4.7.2 2013-06-18
gcc phoebe applications/ programming 4.7.3 gcc/4.7.3 2013-06-18
gcc phoebe applications/ programming 4.8.0 gcc/4.8.0 2013-06-18
gcc phoebe applications/ programming 4.8.1 gcc/4.8.1 2013-06-18
GCC Compilers hopper compilers/ programming 4.4.4 gcc/4.4.4 2010-09-01
GCC Compilers hopper compilers/ programming 4.6.3 gcc/4.6.3 2012-04-11 2012-06-20
GCC Compilers hopper compilers/ programming 4.7.2 gcc/4.7.2 2012-11-29 2013-02-27
GCC Compilers hopper compilers/ programming 4.8.1 gcc/4.8.1 2013-07-11 2013-12-11
GCC Compilers hopper compilers/ programming 4.8.2 gcc/4.8.2 2014-06-12 2014-06-18
GCC Compilers hopper compilers/ programming 4.9.0 gcc/4.9.0 2014-06-12

Optimization

-O0

(Default).   No optimization.  All other NERSC compilers have some sort of optimization as the default.

-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.

-Ofast

Disregard strict standards compliance.   -Ofast enables all -O3 optimizations.  It also enables optimizations that are not valid for all standard-compliant programs.  It turns on -ffast-math and the Fortran-specific -fno-protect-parens and -fstack-arrays.

The -Ofast optimization argument is the NERSC recommended optimization for gnu compiles unless strict standards compliance is required.

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.