GNU Compiler Collection (GCC)¶
Baseline¶
Unless the documentation says otherwise, GCC version 8.5.0, provided by the base repository of Red Hat Enterprise Linux 8, is employed to compile the code of the packages marked as GCC-compatible (the name of the corresponding environment modules include the suffix “gcc”). Therefore, GCC version 8.5.0 is considered to be the baseline version used for compiling the most of the packages installed in the software repository. Users are adviced to stick to that particular version as much as possible and employ other (usually higher) versions of GCC only when it is necessary.
Important
The default version of the libstdc++ library in the system is defined by the baseline version of the GCC.
Supported versions¶
To check which GCC versions are currently supported on Discoverer, execute on the login node:
module avail gcc
Loading¶
To obtain access to the latest GCC, load the environment module gcc/latest
:
module load gcc/latest
otherwise replace latest
with the reqired version.
Compilers¶
Host/Target specification¶
The provided GNU Compiler Collection matches the following host/target specification:
x86_64-pc-linux-gnu
More about the host and target specifications:
Supported compilers and tools¶
Warning
GCC package provides classic C, C++, and Fortran compilers only! If you are looking to find LLVM compilers, check the document LLVM Compiler Infrastructure.
The following classic compiles are provided by the GCC package:
gcc
- C compilerg++
- C++ compilergfortran
- Fortran compiler
In addition to the classic compilers, the GCC package offers a suite of tools to facilitate the pre- and post-compilation processes:
gcc-ar
- creates, modifies, and extracts from archivesgcc-nm
- lists the symbols from object filesgcc-ranlib
- generates an index to the contents of an archive and stores it in the archivegcov
- a test coverage programgcov-dump
- a tool you can use in conjunction with GCC to dump content of gcda and gcno profile files offlinegcov-tool
- an offline tool to process gcc’s gcda profile fileslto-dump
- a tool you can use in conjunction with GCC to dump link time optimization object files
Embedded Libraries (MPFR, GMP, MPC, ISL)¶
Warning
The baseline version of GCC does not come with embedded third-party libraries! Which implies that, if the presence of those libraries is required with the GCC baseline version, the relevant environment modules must be loaded explicitly (see GNU MP (GMP), GNU MPC, GNU MPFR, ISL).
All GCC builds installed in the software repository (excluding the baseline GCC version, which comes with the Linux distribution) embed the following third-party libraries:
That means you do not need to load those libraries explicitly through any other environment module. Once the GCC environment module is loaded the shared and static versions of those libraries become accessible from within the user environment.
Compiler optimization flags for AMD Zen2 CPU¶
Note
The compute nodes of Dicoverer HPC are equipped with AMD EPYC 7H12 64-Core processors, which implies AMD Zen2 CPU architecture.
The following compiler flags can be useful during the compile-time optimization of your binary code on AMD Zen2:
-march=core-avx2 -mtune=core-avx2
For example:
gcc -march=core-avx2 -mtune=core-avx2 ...
g++ -march=core-avx2 -mtune=core-avx2 ...
gfortran -march=core-avx2 -mtune=core-avx2 ...
If GCC > 8 is loaded then -march
and -mtune
compiler flags can be assigned the value of znver2
(much precise specification of the AMD Zen2 CPU microarchitecture):
gcc -march=znver2 -mtune=znver2 ...
g++ -march=znver2 -mtune=znver2 ...
gfortran -march=znver2 -mtune=znver2 ...
Important
The use of -march=znver2
implies -mfma
.
More on the supported compiler flags: AMD EPYC™ 7xx2-series Processors Compiler Options Quick Reference Guide
See also: Best Practice Guide - AMD EPYC
Interaction with CMake¶
It is recommended to specify the compiler executables when invoking cmake
tool:
-DCMAKE_C_COMPILER=gcc
-DCMAKE_CXX_COMPILER=g++
-DCMAKE_Fortran_COMPILER=gfortran
The corresponding optimization compiler flags can be passed to cmake
as well:
-DCMAKE_C_FLAGS="-march=core-avx2 -mtune=core-avx2"
-DCMAKE_CXX_FLAGS="-march=core-avx2 -mtune=core-avx2"
-DCMAKE_Fortran_FLAGS="-march=core-avx2 -mtune=core-avx2"
or (GCC > 8):
-DCMAKE_C_FLAGS="-march=znver2 -mtune=znver2"
-DCMAKE_CXX_FLAGS="-march=znver2 -mtune=znver2"
-DCMAKE_Fortran_FLAGS="-march=znver2 -mtune=znver2"
Build recipe¶
If you are interested in the recipe we followed to compile the programming code of GCC, you can find it here:
Getting help¶
See Getting help