LLVM (Clang, etc.)
The LLVM is a collection of compiler and toolchain tools and libraries, which includes its own compiler Clang (clang and clang++) and is the foundation on which many other compilers are built.
This page has information only on the compilers that are officially part of LLVM, not 3rd party compilers built on top of it.
The Clang C and C++ compilers are intentionally quite compatible with the GCC compilers; supporting many of the same extensions beyond the official language standards, having similar compiler options, and often being able mix C++ code compiled by both.
In all software stacks, the module name is llvm
.
To load a specific version, run
module load llvm/VERSION
To load the default version, run
module load llvm
Languages
The supported languages and the names of their compiler programs are in the table below.
Language | Compiler Program |
---|---|
C | clang |
C++ | clang++ |
OpenMP
Clang supports the OpenMP (Open Multi-Processing) extension for C and C++.
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 Clang 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 the compilers |
---|---|
Most generic version of node compiler is running on | generic |
The CPU of the node the compiler is running on | native (not available before LLVM 16) |
haswell | haswell |
broadwell | broadwell |
skylake_avx512 | skylake-avx512 |
cascadelake | cascadelake |
sapphirerapids | sapphirerapids (use icelake-client for LLVM 11 and older) |
zen2 | znver2 |
zen3 | znver3 (use znver2 for LLVM 11 and older) |