GCC

The GNU Compiler Collection (GCC) is a popular general-purpose collection of compilers for several different languages on many architectures. In all software stacks, the module name is gcc and there is often many versions. To load a specific version, run

module load gcc/VERSION

To load the default version, run

module load gcc

Languages

The supported languages and the names of their compiler programs are in the table below.

LanguageCompiler Program
Cgcc
C++g++
Fortrangfortran

OpenMP

GCC supports the OpenMP (Open Multi-Processing) extension for C, C++, and Fortran. Enable it by adding the -fopenmp option to the compiler. Additionally, the -fopenmp-simd option enables using the OpenMP simd directive.

Targeting CPU Architecture

By default, the GCC compilers will compile code targeting the generic version of the CPU the compilers are run on. On an x86-64 node, this means being compatible with the original 64-bit AMD and Intel processors from 2003 and thus no AVX/AVX2/AVX-512 without SSE fallback. The compilers use the following options to control the target architecture:

Compiler OptionDefault ValueMeaning
-march=ARCHgenericGenerate instructions targeting ARCH
-mtune=ARCHgenericTune performance for ARCH but don’t generate instructions not supported by -march=ARCH
-mcpu=ARCHAlias for -march=ARCH -mtune=ARCH

The ARCH values for the different CPU architectures (Spack naming) we provide are

Architecture/Target (Spack naming)ARCH value for GCC
Most generic version of node compiler is running ongeneric
The CPU of the node the compiler is running onnative
haswellhaswell
broadwellbroadwell
skylake_avx512skylake-avx512
cascadelakecascadelake (use skylake_avx512 for GCC 8)
sapphirerapidssapphirerapids (use icelake-client for GCC 10 and older)
zen2znver2 (use znver1 for GCC 8)
zen3znver3 (use znver1 for GCC 8 and znver2 for GCC 9)