Add CMake support for libsmeagol

This commit is contained in:
Rocco Meli 2025-01-29 17:56:23 +01:00 committed by GitHub
parent 4c325a8b0d
commit 4e1a1e240b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 76 additions and 5 deletions

View file

@ -119,6 +119,7 @@ option(
"Use DLA-Future for Cholesky decompositions and the solution of eigenvalue problems"
OFF)
option(CP2K_USE_LIBXSMM "Use libxsmm for small gemms" OFF)
option(CP2K_USE_LIBSMEAGOL "Enable libsmeagol support" OFF)
# option(CP2K_USE_LIBGRPP "Use libgrpp" OFF)
option(BUILD_SHARED_LIBS "Build cp2k shared library" ON)
option(
@ -671,6 +672,10 @@ if(CP2K_USE_SPGLIB)
find_package(Spglib CONFIG REQUIRED)
endif()
if(CP2K_USE_LIBSMEAGOL)
find_package(libsmeagol REQUIRED)
endif()
if(CP2K_USE_SPLA)
find_package(SPLA REQUIRED)
get_target_property(SPLA_INCLUDE_DIRS SPLA::spla
@ -860,6 +865,12 @@ if(CP2K_USE_DFTD4)
)
endif()
if(CP2K_USE_LIBSMEAGOL)
message(" - LIBSMEAGOL :\n"
" - include directories : ${CP2K_LIBSMEAGOL_INCLUDE_DIRS}\n"
" - libraries : ${CP2K_LIBSMEAGOL_LINK_LIBRARIES}\n\n")
endif()
if(CP2K_USE_SIRIUS)
message(" - SIRIUS")
endif()
@ -916,6 +927,10 @@ if(NOT CP2K_USE_SPGLIB)
message(" - SPGLIB")
endif()
if(NOT CP2K_USE_LIBSMEAGOL)
message(" - libSMEAGOL")
endif()
if(NOT CP2K_USE_COSMA)
message(" - COSMA")
endif()

View file

@ -0,0 +1,40 @@
#!-------------------------------------------------------------------------------------------------!
#! CP2K: A general program to perform molecular dynamics simulations !
#! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
#! !
#! SPDX-License-Identifier: GPL-2.0-or-later !
#!-------------------------------------------------------------------------------------------------!
# Copyright (c) 2025- ETH Zurich
#
# author: Rocco Meli
include(FindPackageHandleStandardArgs)
include(cp2k_utils)
cp2k_find_libraries(LIBSMEAGOL "smeagol")
cp2k_include_dirs(LIBSMEAGOL "negfmod.mod")
if(CP2K_LIBSMEAGOL_INCLUDE_DIRS)
find_package_handle_standard_args(
libsmeagol DEFAULT_MSG CP2K_LIBSMEAGOL_LINK_LIBRARIES
CP2K_LIBSMEAGOL_INCLUDE_DIRS)
else()
find_package_handle_standard_args(libsmeagol DEFAULT_MSG
CP2K_LIBSMEAGOL_LINK_LIBRARIES)
endif()
if(NOT TARGET cp2k::libsmeagol::smeagol)
add_library(cp2k::libsmeagol::smeagol INTERFACE IMPORTED)
set_target_properties(
cp2k::libsmeagol::smeagol PROPERTIES INTERFACE_LINK_LIBRARIES
"${CP2K_LIBSMEAGOL_LINK_LIBRARIES}")
if(CP2K_LIBSMEAGOL_INCLUDE_DIRS)
set_target_properties(
cp2k::libsmeagol::smeagol PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${CP2K_LIBSMEAGOL_INCLUDE_DIRS}")
endif()
endif()
mark_as_advanced(CP2K_LIBSMEAGOL_ROOT CP2K_LIBSMEAGOL_INCLUDE_DIRS
CP2K_LIBSMEAGOL_LINK_LIBRARIES CP2K_LIBSMEAGOL_LIBRARIES)

View file

@ -1608,6 +1608,7 @@ target_link_libraries(
$<$<BOOL:${CP2K_USE_SIRIUS}>:sirius::sirius>
$<$<BOOL:${CP2K_USE_VORI}>:cp2k::VORI::vori>
$<$<BOOL:${CP2K_USE_SPGLIB}>:Spglib::symspg>
$<$<BOOL:${CP2K_USE_LIBSMEAGOL}>:cp2k::libsmeagol::smeagol>
$<$<BOOL:${CP2K_USE_LIBXC}>:cp2k::Libxc::xc>
$<$<BOOL:${CP2K_USE_ELPA}>:cp2k::ELPA::elpa>
$<$<BOOL:${CP2K_USE_PLUMED}>:cp2k::plumed::plumed>
@ -1649,6 +1650,7 @@ target_compile_definitions(
$<$<BOOL:${CP2K_USE_MAXWELL}>:__LIBMAXWELL>
$<$<BOOL:${CP2K_USE_VORI}>:__LIBVORI>
$<$<BOOL:${CP2K_USE_SPGLIB}>:__SPGLIB>
$<$<BOOL:${CP2K_USE_LIBSMEAGOL}>:__SMEAGOL>
$<$<BOOL:${CP2K_USE_DFTD4}>:__DFTD4>
$<$<BOOL:${CP2K_USE_SIRIUS}>:__SIRIUS>
$<$<BOOL:${CP2K_USE_SPLA}>:__SPLA>

View file

@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--with-gcc=system \
--with-libsmeagol \
--dry-run
# Dry-run leaves behind config files for the followup install scripts.

View file

@ -42,7 +42,7 @@ RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
# Install a recent developer version of Spack.
WORKDIR /opt/spack
ARG SPACK_VERSION=56495a8cd81640302a9d3a22249ce42bc4698a38
ARG SPACK_VERSION=0f54995e53d48095a30f1d0203e4f9bdb95e29fa
RUN git init --quiet && \
git remote add origin https://github.com/spack/spack.git && \
git fetch --quiet --depth 1 origin ${SPACK_VERSION} --no-tags && \

View file

@ -17,8 +17,11 @@ def main() -> None:
for version in "sdbg", "ssmp", "pdbg", "psmp":
with OutputFile(f"Dockerfile.test_{version}", args.check) as f:
if version in ("ssmp", "psmp"):
kwargs = {}
if version == "psmp":
kwargs = {"with_libsmeagol": ""}
# Use ssmp/psmp as guinea pigs
f.write(toolchain_full(with_dbcsr=True))
f.write(toolchain_full(with_dbcsr=True, **kwargs))
f.write(install_dbcsr("toolchain", version))
f.write(regtest_cmake("toolchain", version))
else:
@ -850,7 +853,7 @@ RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
# Install a recent developer version of Spack.
WORKDIR /opt/spack
ARG SPACK_VERSION=56495a8cd81640302a9d3a22249ce42bc4698a38
ARG SPACK_VERSION=0f54995e53d48095a30f1d0203e4f9bdb95e29fa
RUN git init --quiet && \
git remote add origin https://github.com/spack/spack.git && \
git fetch --quiet --depth 1 origin ${{SPACK_VERSION}} --no-tags && \

View file

@ -85,6 +85,7 @@ if [[ "${PROFILE}" == "spack" ]] && [[ "${VERSION}" == "psmp" ]]; then
-DCP2K_USE_LIBTORCH=OFF \
-DCP2K_USE_DLAF=ON \
-DCP2K_USE_DFTD4=ON \
-DCP2K_USE_LIBSMEAGOL=OFF \
.. |& tee ./cmake.log
CMAKE_EXIT_CODE=$?
@ -144,6 +145,7 @@ elif [[ "${PROFILE}" == "toolchain" ]] && [[ "${VERSION}" == "psmp" ]]; then
-DCP2K_USE_ELPA=ON \
-DCP2K_USE_FFTW3=ON \
-DCP2K_USE_LIBINT2=ON \
-DCP2K_USE_LIBSMEAGOL=ON \
-DCP2K_USE_LIBTORCH=ON \
-DCP2K_USE_LIBXC=ON \
-DCP2K_USE_LIBXSMM=ON \

View file

@ -19,6 +19,7 @@ spack:
- "libvori@220621"
- "spla@1.6.1 +fortran"
- "dftd4@3.6.0 build_system=cmake"
# - "libsmeagol@1.2"
# Unfortunately, ScaLAPACK 2.2.1 has not yet been packaged by Spack.
# https://github.com/Reference-ScaLAPACK/scalapack/tree/v2.2.1
# which contains https://github.com/Reference-ScaLAPACK/scalapack/pull/26

View file

@ -39,11 +39,18 @@ case "${with_libsmeagol}" in
[ -d libsmeagol-${libsmeagol_ver} ] && rm -rf libsmeagol-${libsmeagol_ver}
tar -xzf libsmeagol-${libsmeagol_ver}.tar.gz
cd libsmeagol-${libsmeagol_ver}
if ("${FC}" --version | grep -q 'GNU'); then
FCFLAGS_FIX="-ffixed-form"
FCFLAGS_FREE="-ffree-form -ffree-line-length-none"
else
FCFLAGS_FIX=""
FCFLAGS_FREE=""
fi
make -j $(get_nprocs) \
FC=${MPIFC} \
FCFLAGS="-DMPI -fallow-argument-mismatch ${FCFLAGS}" \
FCFLAGS_FIXEDFORM="" \
FCFLAGS_FREEFORM="" \
FCFLAGS_FIXEDFORM="${FCFLAGS_FIX}" \
FCFLAGS_FREEFORM="${FCFLAGS_FREE}" \
> make.log 2>&1 || tail -n ${LOG_LINES} make.log
# The libsmeagol makefile does not provide an install target
[ -d ${pkg_install_dir} ] && rm -rf ${pkg_install_dir}