1. Preparing software environment
This section offers guidelines on setting up an environment for building and running application software on LANTA.
1.1 HPE Cray Programming Environment
LANTA is an HPE Cray EX cluster. On the system, HPE Cray Programming Environment (PrgEnv or CPE) is installed by the vendor and is preferred. The environment provides a uniform interface across different sets of compiler and libraries. Below are the modules for each available compiler suite.
Module name | Description | Note |
---|---|---|
PrgEnv-gnu | GNU compiler suite | - |
PrgEnv-intel | INTEL compiler suite | Intel oneAPI (default), with MKL |
PrgEnv-cray | Cray Compiling Environment (CCE) | Loaded by default, upon login |
PrgEnv-nvhpc | NVIDIA HPC SDK compiler suite | Inherently with CUDA |
PrgEnv-aocc | AMD AOCC compiler suite | Without AOCL |
GPU acceleration
For building an application with GPU acceleration, users can use either PrgEnv-nvhpc
, cudatoolkit/<version>
or nvhpc-mixed
. For simplicity, we recommend using PrgEnv-nvhpc
.
Build target
To enable optimizations that depend on the hardware architecture of LANTA, the following modules should be loaded together with PrgEnv
.
Module name | Hardware target | Note |
---|---|---|
craype-x86-milan | AMD EPYC Milan (x86) | - |
craype-accel-nvidia80 | NVIDIA A100 | Load after |
Cray optimized libraries
Most Cray optimized libraries become accessible only after loading a PrgEnv
, ensuring compatibility with the selected compiler suite. Additionally, some libraries, such as NetCDF, require loading other specific libraries first. Below is the hierarchy of commonly used cray-*
modules.
CPE version
To ensure backward compatibility after a system upgrade, it is recommended to fix the Cray Programming Environment version using either cpe/<version>
or cpe-cuda/<version>
. Otherwise, the most recent version will be loaded by default.
1.2 ThaiSC pre-built modules
For user convenience, we provide several shared modules of some widely used software and libraries. These modules were built on top of the HPE Cray Programming Environment, using the CPE toolchain.
CPE toolchain
A CPE toolchain module is a bundle of craype-x86-milan
, PrgEnv-<compiler>
and cpe-cuda/<version>
. The module is defined as a toolchain for convenience and for use with EasyBuild, the framework used for installing most ThaiSC modules.
ThaiSC modules
All ThaiSC modules are located at the same module path, so there is no module hierarchy. Executing module avail
on LANTA will display all available ThaiSC modules. For a more concise list, you can use module overview
, then, use module whatis <name>
or module help <name>
to learn more about a specific module.
Users can readily use ThaiSC modules and CPE toolchains to build their applications. Some popular application software are pre-installed as well, for more information, refer to Applications usage.
username@lanta-xname:~> module avail --------------------------------- /lustrefs/disk/modules/easybuild/modules/all --------------------------------- ADIOS2/2.9.0-cpeCray-23.03 ParallelIO/2.6.2-cpeIntel-23.09 ADIOS2/2.9.1-cpeIntel-23.09 (D) Perl/5.36.0-cpeGNU-23.03 Amber/2022-cpeGNU-CUDA-11.7 PostgreSQL/15.3-cpeIntel-23.09 Apptainer/1.1.6 QuantumESPRESSO/7.2-libxc-6.1.0-cpu (D) Armadillo/12.4.0-cpeIntel-23.09 QuantumESPRESSO/7.2-libxc-6.1.0-gpu AutoDock-vina/1.2.5 RAxML-NG/1.2.0-cpeGNU-23.03 Autoconf/2.71 SAMtools/1.17-cpeGNU-23.03 Automake/1.16.5 SCOTCH/7.0.3-cpeCray-23.03 Autotools/20220317 SPAdes/3.15.4-cpeGNU-23.03 BCFtools/1.17-cpeGNU-23.03 SQLite/3.41.2-cpeIntel-23.09 BEDTools/2.30.0-cpeGNU-23.03 SWIG/4.0.2-cpeGNU-23.03 BLAST+/2.14.0-cpeGNU-23.03 SWIG/4.1.1-cpeIntel-23.09 (D) BLASTDB/v5 Tcl/8.6.13-cpeIntel-23.09 BWA/0.7.17-cpeGNU-23.03 Trimmomatic/0.39-Java-17 BamTools/2.5.2-cpeGNU-23.03 VASP/6.3.2-GNU-cpu_vtst (D) Beast/2.7.5-cpeGNU-23.03 VASP/6.3.2-Intel-cpu_vtst Bison/3.8.2 VASP/6.3.2-NVHPC-gpu_vtst Boost/1.79.0-cpeGNU-23.03 VCFtools/0.1.16-cpeGNU-23.03 Boost/1.81.0-cpeGNU-23.03 WPS/4.4-DM-cpeCray-23.03 (D) Boost/1.81.0-cpeIntel-23.09 WPS/4.5-DM-cpeIntel-23.09 Boost/1.82.0-cpeCray-23.03 (D) WRF/4.4.2-DMSM-cpeCray-23.03 Bowtie/1.3.1-cpeGNU-23.03 WRFchem/4.5.1-DM-cpeIntel-23.09 Bowtie2/2.5.1-cpeGNU-23.03 XZ/5.4.3-cpeCray-23.03 C-Blosc2/2.10.5-cpeIntel-23.09 XZ/5.4.3-cpeGNU-23.03 CFITSIO/4.2.0-cpeIntel-23.09 XZ/5.4.3-cpeIntel-23.09 (D) CGAL/5.5.2-cpeCray-23.03 Xerces-C++/3.2.4
2. Building an application software
After an appropriate environment is loaded, this section provides guidelines on how to use it to build an application software on LANTA.
2.1 Compiler wrapper
<wrapper> command | Description | Manual | In substitution for |
| C compiler wrapper |
| mpicc / mpiicc |
| C++ compiler wrapper |
| mpic++ / mpiicpc |
| Fortran compiler wrapper |
| mpif90 / mpiifort |
The Cray compiler wrappers, namely, cc
, CC
and ftn
, become available after loading any PrgEnv-<compiler>
or CPE toolchain. Upon being invoked, the wrapper will pass relevant information about the cray-*
libraries, loaded in the current environment, to the underlying <compiler>
to compile source code. It is recommended to use these wrappers for building MPI applications with the native Cray MPICH library cray-mpich
.
Adding -craype-verbose
to the wrapper when compiling a source file will display the final command executed. To see what will be added before compiling, try <wrapper> --cray-print-opts=all
.
2.2 Build tools
Several tools exist to help us build large and complex programs. Among them, GNU make and CMake are commonly used. The developer team for each software chooses what build tool they will support. Therefore, it is important to thoroughly read the software documentation. For some software, users might need to additionally load the latest CMake or Autotools modules on the system (e.g., module load CMake/3.26.4
).
There are three general stages in building a program using a build tool: configure
, make
and make install
. For more information, see Basic Installation.
Build tools typically detect compilers through environment variables such as CC
, CXX
, and FC
at the configure
stage. Therefore, setting these variables before running configure
should be sufficient to make the tool use the Cray compiler wrappers.
export CC=cc CXX=CC FC=ftn F77=ftn F90=ftn # ./configure --prefix=<your-install-location> ... # or # cmake -DCMAKE_INSTALL_PREFIX=<your-install-location> ...
Nevertheless, if the CMake cache is not clean, you might need to explicitly use:
cmake -DCMAKE_C_COMPILER=cc -DCMAKE_CXX_COMPILER=CC -DCMAKE_Fortran_COMPILER=ftn -DCMAKE_INSTALL_PREFIX=<your-install-location> ...
We encourage users to manually specify the installation path using --prefix=
or -DCMAKE_INSTALL_PREFIX=
as shown above. This path can be within your project home, such as /project/ltXXXXXX-YYYY/<software-name>
, allowing you to manage permissions and share the installed software with your project members. By default on LANTA, your team will be able to read and execute your software but cannot make any changes inside the directory you own.
After these steps, you should be able to execute make
and make install
, then build your software as you would on any other system.
2.3 Related topics
Local module & EasyBuild
A separate page is dedicated for explaining how to manage and install local modules in the user’s home/project paths using EasyBuild → Local module & EasyBuild (In progress)
Useful compiler flags
Intel oneAPI (In progress)
Other approach
3. Running the software
Every main application software must run on compute/gpu/memory nodes. The recommended approach is to write a job script and send it to Slurm scheduler through sbatch
command.
Only use sbatch <job-script>
. If users execute bash <job-script>
or just simply ./<job-script>
, then the script will not get sent to Slurm and will run on frontend node instead!
3.1 Writing a job script
#!/bin/bash #SBATCH -p gpu # Partition #SBATCH -N 1 # Number of nodes #SBATCH --gpus-per-node=4 # Number of GPU card per node #SBATCH --ntasks-per-node=4 # Number of MPI processes per node #SBATCH --cpus-per-task=16 # Number of OpenMP threads per MPI process #SBATCH -t 5-00:00:00 # Job runtime limit #SBATCH -A ltXXXXXX # Billing account # #SBATCH -J <JobName> # Job name module purge # --- Load necessary modules --- module load <...> module load <...> # --- Add software to Linux search paths --- export PATH=<software-bin-path>:${PATH} export LD_LIBRARY_PATH=<software-lib/lib64-path>:${LD_LIBRARY_PATH} # export PYTHONPATH=<software-python-site-packages>:${PYTHONPATH} # source <your-software-specific-script> # --- (Optional) Set related environment variables --- # export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK} # MUST specify --cpus-per-task above # --- Run the software --- # srun <srun-options> ./<software> # or # ./<software>
The above job script template consists of five sections:
1. Slurm sbatch header
The #SBATCH
macro can be used to specify sbatch options that mostly unchanged, such as partition, time limit, billing account, and so on. For optional options like job name, users can specify them when submitting the script (see Submitting a job). For more details regarding sbatch options, please visit Slurm sbatch.
It should be noted that Slurm sbatch options only define and request computing resources that can be used inside a job script. The actual resources used by a software/executable can be different depending on how it will be invoked/issued (see Stage 5).
2. Loading modules
It is advised to load every module used when installing the software in the job script, although build dependencies such as CMake, Autotools, and binutils can be omitted. Additionally, those modules should be of the same version as when they were used to compile the program.
3. Adding software paths
The Linux OS will not be able to find your program if it is not in its search paths. The commonly used ones are namely PATH
(for executable/binary), LD_LIBRARY_PATH
(for shared library), and PYTHONPATH
(for python packages). Users MUST append or prepend them using syntax such as export PATH=<software-bin-path>:${PATH}
, otherwise, prior search paths added by module load
and others will disappear.
If <your-install-location>
is where your software is installed, then putting the below commands in your job script should be sufficient in most cases.
export PATH=<your-install-location>/bin:${PATH} export LD_LIBRARY_PATH=<your-install-location>/lib:${LD_LIBRARY_PATH} export LD_LIBRARY_PATH=<your-install-location>/lib64:${LD_LIBRARY_PATH}
Some of them can be omitted if there no such sub-directory when using ls <your-install-location>
.
4. Setting environment variables
Some software requires additional environment variables to be set at runtime; for example, the path to the temporary directory. Parameters set by Slurm sbatch (see Slurm sbatch - output environment variables) could be utilized in setting up software-specific environment variables.
In addition, OMP_NUM_THREADS
, OMP_STACKSIZE
, ulimit -s unlimited
are commonly set in a job script. An example is shown below.
export XXX_TMPDIR=/scratch/ltXXXXXX-YYYY/${SLURM_JOBID} export OMP_STACKSIZE="32M" export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK} ulimit -s unlimited
5. Running your software
Each software has its own command to be issued. Please read the software documentation and forum. Special attention should be paid to how the software recognizes and maps computing resources (CPU-MPI-GPU); occasionally, users may need to insert additional input arguments at runtime. The total resources concurrently utilized in this stage should be less than or equal to the resources previously requested in Stage 1. Oversubscribing resources can reduce overall performance and could cause permanent damage to the hardware.
Usually, either srun
, mpirun
, mpiexec
or aprun
is required to run MPI programs. On LANTA, srun
command MUST be used instead. The table below compares a few options of those commands.
Command | Total MPI processes | CPU per MPI process | MPI processes per node |
---|---|---|---|
srun | -n, --ntasks | -c, --cpus-per-task | --ntasks-per-node |
mpirun/mpiexec | -n, -np | --map-by socket:PE=N | --map-by ppr:N:node |
aprun | -n, --pes | -d, --cpus-per-pe | -N, --pes-per-node |
There is usually no need to add options to srun
since, by default, Slurm will automatically derive them from sbatch
. However, we recommend explicitly adding GPU binding options such as --gpus-per-task
or --ntasks-per-gpu
according to each software specification to srun
. Please visit Slurm srun for more details.
For multi-threaded applications, it is essential to specify -c
or --cpus-per-tasks
options for srun
to prevent a potential decrease in performance (~50%) due to improper CPU binding.
3.2 Submitting a job
To submit your job script (e.g., job-script.sh
) to Slurm, execute sbatch [options] job-script.sh [arguments]
. For example,
username@lanta-xname:~> sbatch job-script.sh # Simplest Submitted batch job XXXXXX1 username@lanta-xname:~> sbatch -J <jobname> job-script.sh # Same as having '#SBATCH -j jobname1' in job-script.sh Submitted batch job XXXXXX2 username@lanta-xname:~> sbatch -D <your-case-directory> job-script.sh Submitted batch job XXXXXX3
If your software asks for a case directory where all inputs must be in, you may need to submit your job inside that directory, or use -D, --chdir
option.