GNU Compilers
Overview
The GNU Compiler Collection supports a number of programming languages.
Several versions are available on the CSF – please see the table below.
Advice on programming in Fortran or C is currently beyond the scope of this webpage.
Restrictions on use
Code may be compiled on the login node, but aside from ‘very’ short test runs (e.g., one minute on fewer than 4 cores), executables must always be run by submitting to the batch system, Slurm. If you need to do a bigger test than this then please use batch or srun
(see below).
Set up procedure
This depends on which version you require.
Version | Commands / compilers available | Module required | Additional Notes |
---|---|---|---|
14.2.0 | gcc, g++, gfortran | module load compilers/gcc/14.2.0 |
|
14.1.0 | gcc, g++, gfortran | module load compilers/gcc/14.1.0 |
|
13.3.0 | gcc, g++, gfortran | module load compilers/gcc/13.3.0 |
Use this or newer if optimizing for AMD nodes |
12.2.0 | gcc, g++, gfortran | module load compilers/gcc/12.2.0 |
|
11.4.1 | gcc, g++, gfortran | System default, no modulefile to load |
Older versions listed in the table below are no longer supported by us. Existing apps that were available on the old CSF may still load the modulefiles. But if problems occur with these compilers, or any application compiled with them, we may simply recompile the app with a newer version, or recommend that you recompile your own code.
Version | Commands / compilers available | Module required | Additional Notes |
---|---|---|---|
11.2.0 | gcc, g++, gfortran | module load compilers/gcc/11.2.0 |
Limited support |
9.3.0 | gcc, g++, gfortran | module load compilers/gcc/9.3.0 |
Limited support |
8.2.0 | gcc, g++, gfortran | module load compilers/gcc/8.2.0 |
Limited support |
6.4.0 | gcc, g++, gfortran | module load compilers/gcc/6.3.0 |
No longer supported |
4.8.5 | gcc, g++, gfortran | module load compilers/gcc/4.8.5 |
No longer supported |
4.2.3 | gcc, g++, gfortran | module load compilers/gcc/4.2.3 |
No longer supported |
By loading/swapping modules, the correct LD_LIBRARY_PATH
will be set.
Running the application
Example Code Compilations
The following are minimum / basic compiler commands. See below for how to compile more optimized code for the various CSF node architectures:
gcc hello_world.c -o hello g++ hello_world.c++ -o cpphello gfortran hello_fworld.f77 -o f77hello gfortran hello_fworld.f95 -o f95hello
Optimizing Flags for CSF Hardware
Note that in general, you will not need to recompile or reinstall any applications, python envs, R packages, conda envs for the AMD Genoa nodes. Code that you have previously compiled for older CSF nodes will run perfectly well on the new nodes. However, you may wish to recompile to see whether the compiler can optimize your code for the newer hardware.
The AMD Genoa hardware provides the avx
, avx2
and avx512
vector instructions found in the CSF’s Intel CPUs. So applications are expected to perform at least as well on the new nodes. A full discussion of this hardware is outside of the scope of this page, so please see the AMD documentation if you want more in-depth information.
You may wish to compile code, to be optimized a little more for the AMD nodes. We will be providing more information about this in the next few months, but for now, we have some advice below.
We recommend using the GCC 13.3.0 compiler (or newer) as this supports the AMD znver4
microarchitecture, which enables the AVX-512 extensions.
AMD provide some recommended compiler flags (PDF) to use with various compilers (GNU compiler collection, Intel OneAPI C/C++ and the AMD AOCC compiler.) You will need to use at least anarchitecture flag to enable the AVX-512 extensions available in the Genoa CPUs:
# GNU compilers -march=znver4 # Code will only run on AMD Genoa and Intel Skylake (or newer) -march=haswell -mtune=znver4 # Code will run on all CSF3 node types, with some further # tuning for the AVX-512 extensions found in the AMD and # Intel Skylake nodes where possible. # Intel OneAPI compilers -mavx2 -axCORE-AVX512,CORE-AVX2,AVX # Code will run on all CSF3 node types, with AVX-512 # instruction enabled if supported # AMD AOCC compilers (not yet installed on the CSF - coming soon) -march=znver4 # Code will only run on AMD Genoa and Intel Skylake (or newer) # Note that the above flags can be applied when compiling code on the login nodes. # An alternative is to login to the AMD nodes, using srun, and then compile for # the "current" node's architecture, using: -march=native
The above PDF provides further optimization flags you may wish to use in addition to the above architecture flags.
An example of using the common configure
command when compiling on CSF3 that we’ve used when installing applications, is:
./configure 'CFLAGS=-march=haswell -mtune=znver4' CPPFLAGS='-march=haswell -mtune=znver4' --prefix=path/to/install/area
Serial batch job submission
Please see the Running Serial Jobs documentation.
Reminder that if you loaded a particular compiler modulefile to compile your code, your must load that modulefile in your jobscript (or srun
interactive session – see below) before you run your program.
Parallel batch job submission
Your code, and thus the resulting executable, must use either OpenMP and/or MPI in order to run in parallel. Please see the Running Parallel Jobs documentation.
Reminder that if you loaded a particular compiler modulefile to compile your code, your must load that modulefile in your jobscript (or srun
interactive session – see below) before you run your program.
Testing via srun and batch
srun
can be used to gain interactive access to a compute node (limited resources reserved for this). This is useful for both compilation and testing of your code. Example:
# Start a 1-core 30-minute interactive session (max 1 hour is permitted) on an AMD Genoa node srun -p interactive -n 1 -t 30 --pty bash module load compilers/gcc/14.2.0 # Compile with additional optimization for AMD Genoa, but will run on any CSF node type gcc -march=haswell -mtune=znver4 hello_world.c -o hello # Run your code ./hello
Further info
- Online manuals available from the command line:
man gcc # for the C/C++ compiler man gfortran # for the fortran compiler
- GNU Compiler Collection website
- If you require advice on programming matters, for example how to debug a code, or how to use MKL, please contact us