| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
Automated dependency management and compilation toolchain for ABACUS
The ABACUS Toolchain is an automated build system inspired by the cp2k-toolchain that simplifies the compilation and installation of ABACUS and its dependencies. It supports both online and offline installation modes, multiple compiler toolchains, and provides a streamlined path from dependency installation to ABACUS compilation.
QuantumMisaka (Zhaoqing Liu)
Peking University, CCME
For new users, start with one of these pre-configured toolchains:
# GNU toolchain (GCC + OpenMPI + OpenBLAS)
./toolchain_gnu.sh
# Intel toolchain
./toolchain_gcc-mkl.sh # GCC + OpenMPI + MKL
./toolchain_intel.sh # Intel compilers + Intel MPI + MKL
# AMD toolchain options
./toolchain_gcc-aocl.sh # GCC + AMD AOCL
./toolchain_aocc-aocl.sh # AMD AOCC + AOCLAfter successful toolchain installation:
# For GNU toolchain
./build_abacus_gnu.sh
# For Intel toolchain
./build_abacus_intel.sh
# For AMD toolchains
./build_abacus_gcc-aocl.sh
./build_abacus_aocc-aocl.sh# Source the generated environment
source install/setup
# Or use the generated ABACUS environment
source abacus_env.shDownloads packages automatically from official sources:
./toolchain_gnu.sh # Uses system package managers and official repositoriesBefore running the toolchain, please make sure you have loaded the related environments and set the environment variables.
Package Sources:
For air-gapped systems or unreliable internet:
# 1. Create build directory and download packages
mkdir build
# Download required packages to build/ directory with proper naming
# e.g., fftw-3.3.11.tar.gz, openmpi-5.0.10.tar.bz2
# 2. Run toolchain (will detect local packages)
./toolchain_gnu.shThe downloading process can be facilitated via ./toolchain_gnu.sh --pack-run.
Also, for users in China, we provide a Gitee mirror repository with pre-downloaded packages:
# Clone the Gitee repository in toolchain directory
git clone https://gitee.com/jamesmisaka/abacus_toolchain_build.git
# Move packages to build directory
mv abacus_toolchain_build/* build/
# Then run toolchain normallyMix online and offline packages as needed - the toolchain automatically detects locally available packages and downloads missing ones.
| Package | Version (main/alt) | Purpose | License | Default |
|---|---|---|---|---|
| Build Tools | ||||
| CMake | 3.31.7 / 3.30.5 | Build system | BSD-3-Clause | Install |
| GCC | 13.2.0 / 11.4.0 | C/C++ compiler | GPL-3.0-or-later WITH GCC-exception-3.1 | Install |
| MPI Libraries | ||||
| OpenMPI | 5.0.10 / 4.1.8 | MPI implementation | BSD-3-Clause-Open-MPI | Install |
| MPICH | 5.0.1 / 4.3.2 | Alternative MPI | mpich2 (BSD-like) | Alternative |
| Math Libraries | ||||
| OpenBLAS | 0.3.33 / 0.3.30 | Linear algebra | BSD-3-Clause | Install |
| ScaLAPACK | 2.2.3 / 2.2.1 | Parallel linear algebra | BSD-3-Clause | Install |
| Scientific Libraries | ||||
| FFTW | 3.3.11 / 3.3.10 | Fast Fourier Transform | GPL-2.0-or-later | Install |
| LibXC | 7.0.0 / 6.2.2 | Exchange-correlation | MPL-2.0 | Install |
| ELPA | 2026.02.001 / 2024.05.001 | Eigenvalue solver | LGPL-3.0-only | Install |
| Advanced Features | ||||
| Cereal | pinned commit | C++ Serialization | BSD | Install |
| RapidJSON | pinned commit | JSON parsing | MIT | Install |
| LibRI | pinned commit | EXX calculations | GPL-3.0 | Install |
| LibComm | pinned commit | EXX calculations | GPL-3.0 | Install |
| LibTorch | 2.1.2 / 1.12.1 | MLALGO support | BSD-3-Clause | Optional |
| LibNPY | 1.0.1 / 1.0.1 | NumPy I/O | MIT | Optional |
| NEP | main | Neuroevolution potential | MIT | Optional |
Also, Intel-oneAPI and AMD AOCC and AOCL are supported in toolchain by setting them to system option, but one should install them manually by server administrator.
The toolchain supports a dual-version system for most packages, providing both main (latest stable) and alt (alternative/legacy) versions. This allows users to choose between cutting-edge features and proven stability based on their specific requirements.
The --package-version parameter supports two flexible usage patterns:
Method 1: Multiple Independent Parameters (Original support)
./toolchain_gnu.sh --package-version libtorch:alt --package-version elpa:altMethod 2: Single Parameter with Multiple Key-Value Pairs (Enhanced functionality)
./toolchain_gnu.sh --package-version "libtorch:alt elpa:alt"One can also manually edit the toolchain_gnu.sh for selecting specific version of packages.
# ============================================================================
# Package Version Selection (main/alt versions)
# ============================================================================
# Choose between main (latest stable) and alt (alternative/legacy) versions
# Refer to scripts/package_versions.sh for specific version numbers
CMAKE_VERSION="main" # main=3.31.7, alt=3.30.5
OPENMPI_VERSION="main" # main=5.0.10, alt=4.1.8
OPENBLAS_VERSION="main" # main=0.3.33, alt=0.3.30
ELPA_VERSION="main" # main=2026.02.001, alt=2024.05.001
LIBXC_VERSION="main" # main=7.0.0, alt=6.2.2
SCALAPACK_VERSION="main" # main=2.2.3, alt=2.2.1
# Optional Libraries
LIBTORCH_VERSION="main" # main=2.1.2, alt=1.12.1 (use alt for older GLIBC)and other toolchain_*.sh scripts share the same version selection.
Install system dependencies using provided scripts:
# Ubuntu/Debian
sudo ./root_requirements/install_requirements_ubuntu.sh
# Fedora/RHEL/CentOS
sudo ./root_requirements/install_requirements_fedora.sh
# Generic
sudo ./root_requirements/install_requirements.shAdd to your build script:
cmake -B $BUILD_DIR \
-DUSE_CUDA=ON \
-DCMAKE_CUDA_COMPILER=/path/to/cuda/bin/nvcc \
# ... other optionsexport CUDA_PATH=/path/to/CUDA
./toolchain_gnu.sh --enable-cuda --gpu-ver=70 # For V100 (compute capability 7.0)cmake -B $BUILD_DIR \
-DUSE_CUDA=ON \
-DENABLE_ELPA=ON \
# ... other optionscuSolverMP requires NVIDIA HPC SDK. Follow these steps to build with cuSolverMP:
Load the NVHPC module:
For NVIDIA HPC SDK version < 25.9: cuSolverMP relies on HPC-X for communication, so you need to load the nvhpc-hpcx-cudaxx/xx.x module. For example, with HPC SDK 25.3:
module use /opt/nvidia/hpc_sdk/modulefiles
module load nvhpc-hpcx-cuda12/25.3For NVIDIA HPC SDK version >= 25.9: cuSolverMP uses NCCL for communication instead of HPC-X, so only the base nvhpc/xx.x module is needed. For example, with HPC SDK 26.1:
module use /opt/nvidia/hpc_sdk/modulefiles
module load nvhpc/26.1Build with cuSolverMP enabled:
cmake -B $BUILD_DIR \
-DUSE_CUDA=ON \
-DENABLE_CUSOLVERMP=ON \
# ... other optionsMost of the OneAPI problem arise from the newer version of Intel-OneAPI. For users who encounter OneAPI problem, one can get Intel-OneAPI in QE-managed website, and use this code to get Intel oneAPI Base Toolkit and HPC Toolkit:
wget https://registrationcenter-download.intel.com/akdlm/IRC_NAS/992857b9-624c-45de-9701-f6445d845359/l_BaseKit_p_2023.2.0.49397_offline.sh
wget https://registrationcenter-download.intel.com/akdlm/IRC_NAS/0722521a-34b5-4c41-af3f-d5d14e88248d/l_HPCKit_p_2023.2.0.49440_offline.shRelated discussion here #4976
OneAPI 2025.0 Compatibility:
ELPA on AMD servers with Intel compilers:
# Use Intel classic compilers instead
./toolchain_intel.sh --with-intel-classic=yesNotice: icc and icpc from Intel Classic Compiler of Intel-oneAPI are not supported for 2024.0 and newer version. And Intel-OneAPI 2023.2.0 can be found in QE website. You need to download Base-toolkit for MKL and HPC-toolkit for MPi and compiler for Intel-OneAPI 2023.2.0, while in Intel-OneAPI 2024.x, only the HPC-toolkit is needed.
Use AOCC-AOCL to compile dependencies is permitted and usually get boosting in ABACUS efficiency. But you need to get rid of flang while compiling ELPA. Toolchain itself helps you make this flang shade in default of aocc-aocl toolchain, and you can manually use flang by setting --with-flang=yes in toolchain_aocc-aocl.sh to have a try, while toolchain helps you to bypass the possible errors in compiling ELPA with AOCC-AOCL, but the computing efficiency will be relatively lower compared to gnu or gcc-aocl toolchain. There are some issues related to the numeric instability of ABACUS compiled by AOCC-AOCL toolchain, see #6420
The gcc-aocl toolchain will have no problem above for aocc-dependent aocl. However, the gcc-dependent aocl will have some package linking problem related to OpenMPI. Take it with caution.
Version 5 compatibility problems:
# Use OpenMPI v4 instead
./toolchain_gnu.sh --package-version openmpi:alt
# an deprecated option, but still works
./toolchain_gnu.sh --with-openmpi-4th=yesLibComm compilation with OpenMPI:
Line ending problems:
./pre_set.sh # Fixes line endings and permissions
# Or manually:
dos2unix *.sh
chmod +x *.shLibTorch GLIBC errors:
DeepMD GLIBC errors:
# Use Intel MKL instead of installing OpenBLAS
./toolchain_gnu.sh --with-mkl=system
# Use system FFTW instead of installing
./toolchain_gnu.sh --with-fftw=system
# Specify custom package installation path
./toolchain_gnu.sh --with-fftw=/path/to/custom/fftw# Test configuration without actual installation (recommended for first run)
./toolchain_gnu.sh --dry-run
# Only download packages without building (useful for offline preparation)
./toolchain_gnu.sh --pack-runThe toolchain supports several environment variables for advanced configuration:
Control SSL/TLS certificate verification during package downloads:
# Strict mode: Always verify certificates (secure)
export DOWNLOAD_CERT_POLICY=strict
./toolchain_gnu.sh
# Smart mode: Try secure first, fallback if needed (default)
export DOWNLOAD_CERT_POLICY=smart # or leave unset
./toolchain_gnu.sh
# Skip mode: Skip certificate verification (legacy compatibility)
export DOWNLOAD_CERT_POLICY=skip
./toolchain_gnu.shSmart Mode Behavior: The default smart mode first attempts secure downloads with certificate verification. If this fails (e.g., due to corporate firewalls or outdated certificates), it automatically falls back to skipping certificate verification while providing clear user feedback.
Override the automatic CPU core detection for compilation:
# Use 8 cores for compilation (useful for resource-limited systems)
export NPROCS_OVERWRITE=8
./toolchain_gnu.sh
# Use single core for debugging compilation issues
export NPROCS_OVERWRITE=1
./toolchain_gnu.sh
# Or specify inline
NPROCS_OVERWRITE=4 ./toolchain_gnu.sh --with-gcc --with-openmpiUse Cases:
The toolchain generates several setup files:
The toolchain follows a modular design with staged dependency installation:
scripts/ ├── stage0/ # Compilers and build tools ├── stage1/ # MPI implementations ├── stage2/ # Math libraries (BLAS, LAPACK) ├── stage3/ # Scientific libraries (FFTW, LibXC, ELPA) ├── stage4/ # Advanced features (LibTorch, LibRI) └── lib/ # Core toolchain libraries
| File | Purpose |
|---|---|
| install_abacus_toolchain_new.sh | Main orchestration script (new version) |
| toolchain_*.sh | Frontend scripts for specific toolchains |
| scripts/lib/config_manager.sh | Configuration management |
| scripts/lib/package_manager.sh | Package installation logic |
| scripts/lib/user_interface.sh | User interaction and output |
| scripts/common_vars.sh | Shared variables and defaults |
| scripts/tool_kit.sh | Utility functions and macros |
| scripts/parse_if.py | Parser for IF_XYZ constructs |
| install/<pkg>/install_successful | Per-package install lock/checksum file generated by write_checksums |
Individual Package Scripts: Each scripts/stage*/install_PKG.sh script is relatively independent and should:
Generate setup files: Write to both build/setup_PKG and install/setup
Handle dependencies: May depend on other libraries being installed with correct environment variables
Use toolkit macros: Leverage functionality from scripts/tool_kit.sh for common operations
Each scripts/stage*/install_PKG.sh script:
The --with-PKG options control how a package is going to be installed:
System Search Paths: When using system mode, the installation script searches in:
Troubleshooting System Libraries: If --with-PKG=system cannot find the library:
The --enable-FEATURE options control whether optional features are enabled:
For packages serving the same purpose, mode variables act as selectors:
Note: While --with-PKG controls the installation method, the PKG_MODE variable picks which package to actually use, providing maximum flexibility.
The toolchain uses a special syntax construct for conditional compilation flags:
IF_XYZ(A | B)This construct is parsed by scripts/parse_if.py:
Nested Constructs: The IF_XYZ(A|B) construct can be nested:
IF_XYZ(IF_ABC(flag1|flag2) | flag3)This parses to:
Compiler Flag Filtering: Always pass compiler flags through compatibility filters:
# Filter flags for GCC compatibility
CFLAGS="$(allowed_gcc_flags $CFLAGS)"
FCFLAGS="$(allowed_gfortran_flags $FCFLAGS)"IF_XYZ with Flag Filtering: Since filters don't work with IF_XYZ constructs, break them down:
# Instead of: FCFLAGS="IF_XYZ(flag1 flag2 | flag3 flag4)"
XYZ_TRUE_FLAGS="flag1 flag2"
XYZ_FALSE_FLAGS="flag3 flag4"
# Apply filtering
XYZ_TRUE_FLAGS="$(allowed_gcc_flags $XYZ_TRUE_FLAGS)"
XYZ_FALSE_FLAGS="$(allowed_gcc_flags $XYZ_FALSE_FLAGS)"
# Reconstruct
FCFLAGS="IF_XYZ($XYZ_TRUE_FLAGS | $XYZ_FALSE_FLAGS)"Fortran Module Checking: Check intrinsic Fortran modules with:
check_gfortran_module module_nameAvoid Hard Coding: Use common variables instead of hard-coded paths:
# Good practice
./configure --prefix=some_dir CC=${MPICC} FC=${MPIFC}
# Avoid
./configure --prefix=some_dir CC=mpicc FC=mpif90The ABACUS Toolchain downloads and installs only GPL-compatible packages. All included packages maintain their original licenses as listed in the Dependencies section above.
License Compatibility: All packages use GPL-compatible licenses including BSD, MIT, LGPL, MPL-2.0, and GPL variants, ensuring seamless integration with GPL-licensed software.
Note: Proprietary packages like Intel OneAPI (MKL/Compiler/MPI) and AMD AOCC/AOCL are supported but must be installed separately by the user.
We welcome contributions to improve the ABACUS Toolchain! Here's how you can help:
# Clone the repository
git clone https://github.com/deepmodeling/abacus-develop.git
cd abacus-develop/toolchain
# Test your changes
./toolchain_gnu.sh --dry-runFor questions, issues, or contributions, please visit the ABACUS GitHub repository.
| Back | FazBrowse Home | New Git URL |