From 9a4037812a90fa1e8be54872a901ec6142adc4d3 Mon Sep 17 00:00:00 2001 From: Matthias Krack Date: Sun, 8 Mar 2026 06:44:57 +0100 Subject: [PATCH] Use pre-built libint archive with spack (2.11.2 -> 2.13.1) (#4923) --- make_cp2k.sh | 4 +- tools/spack/cp2k_deps_p.yaml | 3 +- tools/spack/cp2k_deps_s-static.yaml | 3 +- tools/spack/cp2k_deps_s.yaml | 3 +- .../cp2k_dev/packages/libint/package.py | 67 +++++++++++++++++++ 5 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 tools/spack/spack_repo/cp2k_dev/packages/libint/package.py diff --git a/make_cp2k.sh b/make_cp2k.sh index a371375c34..bc49e55169 100755 --- a/make_cp2k.sh +++ b/make_cp2k.sh @@ -160,7 +160,7 @@ else MAX_PROCS=-1 NUM_PROCS=${NUM_PROCS:-8} fi -NUM_PACKAGES=4 +NUM_PACKAGES=2 NVCC_VERSION=0 REBUILD_CP2K="no" RUN_TEST="no" @@ -1032,7 +1032,7 @@ if [[ ! -d "${SPACK_BUILD_PATH}" ]]; then fi # Disable PEXSI because of an issue with SuperLU using recent GCC versions - if ((CUDA_SM_CODE > 0)) || ((GCC_VERSION_NEWEST > 14)); then + if ((CUDA_SM_CODE > 0)) || ([[ "${GCC_VERSION}" == "auto" ]] && ((GCC_VERSION_NEWEST > 14))); then sed -E -e '/\s*-\s+"pexsi@/ s/^ /#/' -i "${CP2K_CONFIG_FILE}" echo "INFO: PEXSI has been disabled because CUDA or GCC 15 is used" fi diff --git a/tools/spack/cp2k_deps_p.yaml b/tools/spack/cp2k_deps_p.yaml index a0d3de8337..6d38cbfa5a 100644 --- a/tools/spack/cp2k_deps_p.yaml +++ b/tools/spack/cp2k_deps_p.yaml @@ -120,7 +120,6 @@ spack: libint: require: - "+fortran" - - "tune=cp2k-lmax-5" libxc: require: @@ -192,7 +191,7 @@ spack: - "greenx@2.2" - "hdf5@1.14.6" - "libfabric@2.4.0" - - "libint@2.11.2" + - "libint@2.13.1-cp2k-lmax-5" - "libsmeagol@1.2" - "libvdwxc@0.5.0" - "libvori@220621" diff --git a/tools/spack/cp2k_deps_s-static.yaml b/tools/spack/cp2k_deps_s-static.yaml index 032a0ec18c..809542a343 100644 --- a/tools/spack/cp2k_deps_s-static.yaml +++ b/tools/spack/cp2k_deps_s-static.yaml @@ -75,7 +75,6 @@ spack: require: - "+fortran" - "~shared" - - "tune=cp2k-lmax-5" libxc: require: @@ -102,7 +101,7 @@ spack: - "dftd4@3.7.0" - "fftw@3.3.10" # - "hdf5@1.14.6" - - "libint@2.11.2" + - "libint@2.13.1-cp2k-lmax-5" - "libvori@220621" - "libxc@7.0.0" - "libxsmm@1.17-cp2k" diff --git a/tools/spack/cp2k_deps_s.yaml b/tools/spack/cp2k_deps_s.yaml index 19e326549b..fa03565341 100644 --- a/tools/spack/cp2k_deps_s.yaml +++ b/tools/spack/cp2k_deps_s.yaml @@ -79,7 +79,6 @@ spack: libint: require: - "+fortran" - - "tune=cp2k-lmax-5" libxc: require: @@ -117,7 +116,7 @@ spack: - "fftw@3.3.10" - "greenx@2.2" - "hdf5@1.14.6" - - "libint@2.11.2" + - "libint@2.13.1-cp2k-lmax-5" - "libvori@220621" - "libxc@7.0.0" - "libxsmm@1.17-cp2k" diff --git a/tools/spack/spack_repo/cp2k_dev/packages/libint/package.py b/tools/spack/spack_repo/cp2k_dev/packages/libint/package.py new file mode 100644 index 0000000000..5b66fda53f --- /dev/null +++ b/tools/spack/spack_repo/cp2k_dev/packages/libint/package.py @@ -0,0 +1,67 @@ +# Copyright Spack Project Developers. See COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +import os + +from spack_repo.builtin.build_systems.cmake import CMakePackage + +from spack.package import * + + +class Libint(CMakePackage): + """Libint is a high-performance library for computing Gaussian integrals in quantum mechanics. + This recipe is tailored for CP2K and requires a pre-built libint archive with the source code + generated for a specific maximum l value. + """ + + homepage = "https://github.com/evaleev/libint" + url = "https://www.cp2k.org/static/downloads/libint-v2.13.1.tar.xz" + + maintainers("mkrack") + + license("LGPL-3.0-only") + + version( + "2.13.1-cp2k-lmax-7", + sha256="ba19571deefa5c3063e620210c87cf706ef8d75b47f3b0d66547f889f906b3dd", + ) + version( + "2.13.1-cp2k-lmax-6", + sha256="a7990c4862d549e6328596f20b8a7ece40ded396b953d5d5d7c3200f13e37429", + ) + version( + "2.13.1-cp2k-lmax-5", + sha256="527000f915bea9879391273b96689a8c2b98beeec37cb64637e3c11dd421a5e8", + ) + version( + "2.13.1-cp2k-lmax-4", + sha256="8ff388fbf171635420fdfdbafc7dc949e9cf4c0b6a62f23dac3af8b1c942d407", + ) + + variant("fortran", default=True, description="Build Fortran interface") + variant("pic", default=True, description="Build position independent code") + variant("shared", default=False, description="Build shared library") + + # Build dependencies + depends_on("c", type="build") + depends_on("cxx", type="build") + depends_on("fortran", type="build", when="+fortran") + + depends_on("boost", type="build") + depends_on("eigen", type="build") + + def setup_build_environment(self, env): + env.append_flags("CXXFLAGS", "-g1") + + def cmake_args(self): + args = [ + self.define_from_variant("BUILD_SHARED_LIBS", "shared"), + self.define_from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"), + self.define_from_variant("LIBINT2_ENABLE_FORTRAN", "fortran"), + ] + return args + + @property + def libs(self): + return find_libraries("libint2", self.spec.prefix, shared=True, recursive=True)