Skip to content

Using alternative compilers or dependencies

Using an alternative compiler

Intel

GCC is the most supported compiler

The ITSR Applications Team have compiled the majority of applications available via modules on Apocrita using GCC. Whilst other compilers are available on Apocrita as outlined below, you will receive the best support from us should you choose to use GCC as well.

If you don't specify a compiler when installing something from Spack, Spack will use what it considers to be the best compiler available (usually GCC). But what about if we prefer to use one of the other compilers in our personal packages.yaml file?

First, we can check which compilers are available:

spack compilers output
$ spack -C ${HOME}/spack-config-templates/1.1.1 compilers
==> Available compilers
-- gcc rocky9-x86_64 --------------------------------------------
[e]  gcc@14.2.0  [e]  gcc@12.2.0  [e]  gcc@11.4.1  [^]  gcc@14.2.0  [^]  gcc@12.2.0

-- intel-oneapi-compilers rocky9-x86_64 -------------------------
[e]  intel-oneapi-compilers@2024.1.0  [^]  intel-oneapi-compilers@2024.1.0  [^]  intel-oneapi-compilers@2023.2.4

-- intel-oneapi-compilers-classic rocky9-x86_64 -----------------
[^]  intel-oneapi-compilers-classic@2021.10.0

-- llvm rocky9-x86_64 -------------------------------------------
[^]  llvm@17.0.6

So, we can see a list of available compilers as previously defined.

To use a specific compiler, you need to add it to the install command after the % sigil. So, let's spec nano@6.4, but this time we will use the Intel compiler (so add %oneapi@2024.1.0 to the end of the command):

spack spec output
$ spack -C ${HOME}/spack-config-templates/1.1.1 spec nano@6.4 %oneapi@2024.1.0
 -   nano@6.4 build_system=autotools platform=linux os=rocky9 target=x86_64_v4 %c=oneapi@2024.1.0
[^]      ^compiler-wrapper@1.0 build_system=generic platform=linux os=rocky9 target=x86_64_v4
[^]      ^gettext@0.22.5+bzip2+curses+git~libunistring+libxml2+pic+shared+tar+xz build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]          ^bzip2@1.0.8~debug~pic+shared build_system=generic platform=linux os=rocky9 target=x86_64_v4
[^]              ^diffutils@3.10 build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]          ^gcc-runtime@11.4.1 build_system=generic platform=linux os=rocky9 target=x86_64_v4
[e]          ^glibc@2.34 build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]          ^libxml2@2.10.3+pic~python+shared build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]              ^zlib-ng@2.1.6+compat+new_strategies+opt+pic+shared build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]          ^tar@1.34 build_system=autotools zip=pigz platform=linux os=rocky9 target=x86_64_v4
[^]              ^pigz@2.8 build_system=makefile platform=linux os=rocky9 target=x86_64_v4
[^]              ^zstd@1.5.6+programs build_system=makefile compression:=none libs:=shared,static platform=linux os=rocky9 target=x86_64_v4
[^]          ^xz@5.4.6~pic build_system=autotools libs:=shared,static platform=linux os=rocky9 target=x86_64_v4
[e]      ^glibc@2.34 build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]      ^gmake@4.4.1~guile build_system=generic platform=linux os=rocky9 target=x86_64_v4
[e]      ^intel-oneapi-compilers@2024.1.0~amd+envmods~nvidia build_system=generic platform=linux os=rocky9 target=x86_64
[^]      ^intel-oneapi-runtime@2024.1.0 build_system=generic platform=linux os=rocky9 target=x86_64_v4
[^]          ^gcc-runtime@12.2.0 build_system=generic platform=linux os=rocky9 target=x86_64_v4
[^]      ^ncurses@6.5~symlinks+termlib abi=none build_system=autotools patches:=7a351bc platform=linux os=rocky9 target=x86_64_v4
[^]          ^pkgconf@2.2.0 build_system=autotools platform=linux os=rocky9 target=x86_64_v4

So, a similar output to before - most of the dependencies are already upstream and the only thing that needs to be compiled and installed personally is the actual binary for nano itself. So let's go ahead and run an install:

spack install output (click to expand)
$ spack -C ${HOME}/spack-config-templates/1.1.1 install -j ${SLURM_NTASKS} nano@6.4 %oneapi@2024.1.0
[+] /usr (external glibc-2.34-xri56vcyzs7kkvakhoku3fefc46nw25y)
[+] /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-12.2.0/intel-oneapi-compilers/2024.1.0-bdqsx5f (external intel-oneapi-compilers-2024.1.0-ngzdq2pq6qlfghsd7jz74bvfdcyyx7yp)
[+] /usr (external glibc-2.34-vjgsh5eoloariofarhttteo73mj5rgql)
[+] /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/none-none/compiler-wrapper/1.0-oqjjbmb
[+] /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-11.4.1/gcc-runtime/11.4.1-llid4hw
[+] /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-12.2.0/gcc-runtime/12.2.0-w77gg5r
[+] /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-11.4.1/xz/5.4.6-rwn7pno
[+] /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-11.4.1/zlib-ng/2.1.6-g2yruc3
[+] /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-11.4.1/gmake/4.4.1-xchit5a
[+] /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/oneapi-2024.1.0/intel-oneapi-runtime/2024.1.0-kppzkgj
[+] /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-11.4.1/pigz/2.8-somkvv4
[+] /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-11.4.1/libxml2/2.10.3-q6zmsq6
[+] /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-11.4.1/zstd/1.5.6-my7tyw6
[+] /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-11.4.1/ncurses/6.5-4n2uzha
[+] /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-11.4.1/bzip2/1.0.8-uj4wyhx
[+] /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-11.4.1/tar/1.34-ivzmnos
[+] /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-11.4.1/gettext/0.22.5-udcuonu
==> No binary for nano-6.4-t5l5fob4hwziic2dzgq4n2ij37gvcbt5 found: installing from source
==> Installing nano-6.4-t5l5fob4hwziic2dzgq4n2ij37gvcbt5 [18/18]
==> Using cached archive: /gpfs/scratch/abc123/spack/cache/_source-cache/archive/41/4199ae8ca78a7796de56de1a41b821dc47912c0307e9816b56cc317df34661c0.tar.xz
==> No patches needed for nano
==> nano: Executing phase: 'autoreconf'
==> nano: Executing phase: 'configure'
==> nano: Executing phase: 'build'
==> nano: Executing phase: 'install'
==> nano: Successfully installed nano-6.4-t5l5fob4hwziic2dzgq4n2ij37gvcbt5
  Stage: 0.14s.  Autoreconf: 0.00s.  Configure: 40.94s.  Build: 1.53s.  Install: 0.65s.  Post-install: 0.44s.  Total: 45.01s
[+] /gpfs/scratch/abc123/spack/apps/linux-rocky9-x86_64_v4/intel-oneapi-compilers-2024.1.0/nano/6.4-t5l5fob

So, once again:

  • The existing available upstream dependencies have been used from the central location as opposed to reinstalled
  • Spack has noticed that nano@6.4 compiled against Intel is missing and has re-used the existing cached tarball and then manually compiled it and installed it to the location defined as install_tree: root: in config.yaml.

Let's now return to our spack find command:

spack find output
$ spack -C ${HOME}/spack-config-templates/1.1.1 find -x -p nano
-- linux-rocky9-x86_64_v4 / %c=gcc@14.2.0 -----------------------
nano@6.4  /gpfs/scratch/abc123/spack/apps/linux-rocky9-x86_64_v4/gcc-14.2.0/nano/6.4-muklb7y

-- linux-rocky9-x86_64_v4 / %c=oneapi@2024.1.0 ------------------
nano@6.4  /gpfs/scratch/abc123/spack/apps/linux-rocky9-x86_64_v4/intel-oneapi-compilers-2024.1.0/nano/6.4-t5l5fob

-- linux-rocky9-x86_64_v4 / no compilers ------------------------
nano@7.2  /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-12.2.0/nano/7.2-4ew6nde
nano@8.2  /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-14.2.0/nano/8.2-7onanyb
==> 4 installed packages

And we now have a module file available for the version compiled against Intel (note that the module name lists oneapi-2024.1.0 and not gcc-14.2.0):

module avail output
$ module avail -l nano
- Package/Alias -----------------------.- Versions --------.- Last mod. -------
/gpfs/scratch/abc123/spack/privatemodules/linux-rocky9-x86_64_v4:
nano/6.4-gcc-14.2.0                                         2026/06/18 09:02:59
nano/6.4-intel-oneapi-compilers-2024.1.0                    2026/06/19 14:43:59

/share/apps/rocky9/environmentmodules/apocrita-modules/spack:
nano/7.2-gcc-12.2.0                                         2026/06/18 10:02:14
nano/8.2-gcc-14.2.0                                         2026/06/18 10:02:14

$ module load nano/6.4-intel-oneapi-compilers-2024.1.0
$ which nano
/gpfs/scratch/abc123/spack/apps/linux-rocky9-x86_64_v4/intel-oneapi-compilers-2024.1.0/nano/6.4-t5l5fob/bin/nano
$ nano --version
 GNU nano, version 6.4
 (C) 2022 the Free Software Foundation and various contributors
 Compiled options: --disable-libmagic --enable-utf8

Using alternative dependencies

Intel/Intel MPI

Open MPI is the most supported MPI implementation

The ITSR Applications Team have compiled almost all centrally installed applications available on Apocrita against bespoke installations of Open MPI integrating advanced features such as Infiniband, and you will receive the best support from us if you also use Open MPI (defined as an external package as advised in the above packages.yaml documentation). Using other MPI versions as detailed below is possible, but not as well-supported.

You'll have noticed that the above examples for Gromacs and LAMMPS all use the ^openmpi dependency. But it is also possible to compile using the Intel compiler and Intel MPI instead.

Let's take LAMMPS as a simple example. The default centrally installed CPU versions (the lammps modules) have been compiled using GCC and Open MPI, using the following variant:

lammps ^openmpi

Let's run a spec command using our personal config scope, but this time swapping out ^openmpi with Intel and Intel MPI:

Use the intel-oneapi-* Spack packages

Spack uses the intel-oneapi-* naming scheme for all Intel packages such as intel-oneapi-compilers, intel-oneapi-mpi etc. Search the Spack Packages site for more details.

We will use the Intel compiler, Intel MPI and the Intel MKL libraries (which will provide fftw via the +cluster variant of Intel MKL and the fft=mkl variant of LAMMPS itself).

spack spec output (click to expand)
$ spack -C ${HOME}/spack-config-templates/1.1.1 spec lammps fft=mkl %oneapi ^intel-oneapi-mpi ^intel-oneapi-mkl+cluster
-   lammps@20250722.3~adios~amoeba~asphere~atc~awpmd~bocs~body~bpm~brownian~cg-dna~cg-spica~class2~colloid~colvars~compress~coreshell~cuda~cuda_mps~curl~dielectric~diffraction~dipole~dpd-basic~dpd-meso~dpd-react~dpd-smooth~drude~eff~electrode~extra-command~extra-compute~extra-dump~extra-fix~extra-molecule~extra-pair~fep~ffmpeg~granular~h5md~heffte~intel~interlayer~ipo~jpeg~kim~kokkos+kspace~latboltz~lepton+lib~machdyn~manifold+manybody~mc~mdi~meam~mesont~mgpt~misc~ml-hdnnp~ml-iap~ml-pace~ml-pod~ml-rann~ml-snap~ml-uf3~mofff+molecule~molfile+mpi~netcdf~opencl+openmp~openmp-package~opt~orient~peri~phonon~plugin~plumed~png~poems~ptm~python~qeq~qtb~reaction~reaxff~replica~rheo+rigid~rocm~scafacos~shock~smtbq~sph~spin~srd~tally~tools~uef~voronoi~vtk~yaff build_system=cmake build_type=Release fft=mkl fftw_precision=double generator=make gpu_precision=mixed lammps_sizes=smallbig platform=linux os=rocky9 target=x86_64_v4 %c,cxx=oneapi@2024.1.0
[^]      ^cmake@3.27.9~doc+ncurses+ownlibs build_system=generic build_type=Release platform=linux os=rocky9 target=x86_64_v4
[^]          ^curl@8.7.1~gssapi~ldap~libidn2~librtmp~libssh~libssh2+nghttp2 build_system=autotools libs:=shared,static tls:=openssl platform=linux os=rocky9 target=x86_64_v4
[^]              ^nghttp2@1.57.0 build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]                  ^diffutils@3.10 build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]              ^openssl@3.3.0~docs+shared build_system=generic certs=mozilla platform=linux os=rocky9 target=x86_64_v4
[^]                  ^ca-certificates-mozilla@2023-05-30 build_system=generic platform=linux os=rocky9 target=x86_64_v4
[^]              ^perl@5.38.0+cpanm+opcode+open+shared+threads build_system=generic patches:=714e4d1 platform=linux os=rocky9 target=x86_64_v4
[^]                  ^berkeley-db@18.1.40+cxx~docs+stl build_system=autotools patches:=26090f4,b231fcc platform=linux os=rocky9 target=x86_64_v4
[^]                  ^bzip2@1.0.8~debug~pic+shared build_system=generic platform=linux os=rocky9 target=x86_64_v4
[^]                  ^gdbm@1.23 build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]                      ^readline@8.2 build_system=autotools patches:=bbf97f1 platform=linux os=rocky9 target=x86_64_v4
[^]              ^pkgconf@2.2.0 build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]          ^gcc-runtime@12.2.0 build_system=generic platform=linux os=rocky9 target=x86_64_v4
[e]          ^glibc@2.34 build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]          ^ncurses@6.5~symlinks+termlib abi=none build_system=autotools patches:=7a351bc platform=linux os=rocky9 target=x86_64_v4
[^]          ^zlib-ng@2.1.6+compat+new_strategies+opt+pic+shared build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]      ^compiler-wrapper@1.0 build_system=generic platform=linux os=rocky9 target=x86_64_v4
[e]      ^glibc@2.34 build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]      ^gmake@4.4.1~guile build_system=generic platform=linux os=rocky9 target=x86_64_v4
[^]          ^gcc-runtime@11.4.1 build_system=generic platform=linux os=rocky9 target=x86_64_v4
[e]      ^intel-oneapi-compilers@2024.1.0~amd+envmods~nvidia build_system=generic platform=linux os=rocky9 target=x86_64
[^]      ^intel-oneapi-mkl@2024.2.2+cluster+envmods+gfortran~ilp64+shared build_system=generic mpi_family=mpich threads=none platform=linux os=rocky9 target=x86_64_v4
[^]          ^intel-tbb@2021.9.0~ipo+shared+tm build_system=cmake build_type=Release cxxstd=default generator=make patches:=91755c6 platform=linux os=rocky9 target=x86_64_v4
[^]              ^hwloc@2.9.1~cairo~cuda~gl~libudev+libxml2~netloc~nvml~oneapi-level-zero~opencl+pci~rocm build_system=autotools libs:=shared,static platform=linux os=rocky9 target=x86_64_v4
[^]                  ^libpciaccess@0.17 build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]                      ^libtool@2.4.7 build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]                          ^findutils@4.9.0 build_system=autotools patches:=440b954 platform=linux os=rocky9 target=x86_64_v4
[^]                          ^m4@1.4.19+sigsegv build_system=autotools patches:=9dc5fbd,bfdffa7 platform=linux os=rocky9 target=x86_64_v4
[^]                              ^libsigsegv@2.14 build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]                      ^util-macros@1.19.3 build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]                  ^libxml2@2.10.3+pic~python+shared build_system=autotools platform=linux os=rocky9 target=x86_64_v4
[^]                      ^xz@5.4.6~pic build_system=autotools libs:=shared,static platform=linux os=rocky9 target=x86_64_v4
[^]      ^intel-oneapi-mpi@2021.12.1+envmods~external-libfabric~generic-names~ilp64 build_system=generic platform=linux os=rocky9 target=x86_64_v4
[^]      ^intel-oneapi-runtime@2024.1.0 build_system=generic platform=linux os=rocky9 target=x86_64_v4
[^]          ^gcc-runtime@12.2.0 build_system=generic platform=linux os=rocky9 target=x86_64_v4

So, all dependencies are upstream and all we need to do is recompile LAMMPS. If you follow through and install that personal variant, then, assuming you broadly follow the example modules.yaml template, the module should be named something like:

lammps/20250722.3-intel-oneapi-mpi-2021.12.1-intel-oneapi-compilers-2024.1.0

And when loading the above module and running $ mpirun -np ${SLURM_NTASKS} lmp -help you should see a section like this:

Compiler: Intel LLVM C++ 202401.0 / Intel(R) oneAPI DPC++/C++ Compiler 2024.1.0 (2024.1.0.20240308) with OpenMP 5.1
C++ standard: C++17
Embedded fmt library version: 10.2.0
Embedded JSON class version: 3.12.0

MPI v3.1: Intel(R) MPI Library 2021.12 for Linux* OS

Accelerator configuration:

FFT information:

FFT precision  = double
FFT engine  = mpiFFT
FFT library = MKL with threads