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.
Language | Compiler Program |
---|---|
C | gcc |
C++ | g++ |
Fortran | gfortran |
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 Option | Default Value | Meaning |
---|---|---|
-march=ARCH | generic | Generate instructions targeting ARCH |
-mtune=ARCH | generic | Tune performance for ARCH but don’t generate instructions not supported by -march=ARCH |
-mcpu=ARCH | Alias 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 on | generic |
The CPU of the node the compiler is running on | native |
haswell | haswell |
broadwell | broadwell |
skylake_avx512 | skylake-avx512 |
cascadelake | cascadelake (use skylake_avx512 for GCC 8) |
sapphirerapids | sapphirerapids (use icelake-client for GCC 10 and older) |
zen2 | znver2 (use znver1 for GCC 8) |
zen3 | znver3 (use znver1 for GCC 8 and znver2 for GCC 9) |