mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-28 22:25:32 -04:00
Docker: Add regtests to CMake test
This commit is contained in:
parent
b85a701a21
commit
aa8cc80eb7
6 changed files with 155 additions and 201 deletions
|
|
@ -300,14 +300,14 @@ else()
|
|||
set(__cp2k_ext "ssmp")
|
||||
endif()
|
||||
|
||||
set(__cp2k_cmake_name "cmake_build_cpu")
|
||||
set(__cp2k_cmake_name "local")
|
||||
|
||||
if(CP2K_USE_ACCEL MATCHES "CUDA")
|
||||
set(__cp2k_cmake_name "cmake_build_cuda")
|
||||
set(__cp2k_cmake_name "local_cuda")
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_ACCEL MATCHES "HIP")
|
||||
set(__cp2k_cmake_name "cmake_build_hip")
|
||||
set(__cp2k_cmake_name "local_hip")
|
||||
endif()
|
||||
|
||||
# we can run the src consistency checks without actually searching for any
|
||||
|
|
@ -931,12 +931,9 @@ if(NOT CP2K_USE_LIBTORCH)
|
|||
endif()
|
||||
|
||||
if(CP2K_ENABLE_REGTESTS OR cp2k_TESTS)
|
||||
message(
|
||||
"\n\n"
|
||||
"To run the regtests you need to run the following commands\n"
|
||||
"\n\n cd ..\n"
|
||||
"tests/do_regtest.py -cp2kdir . -nobuild -version ${__cp2k_cmake_exts} -arch ${__cp2k_cmake_name}\n\n"
|
||||
)
|
||||
message("\n\n" "To run the regtests you need to run the following commands\n"
|
||||
"\n\n cd ..\n"
|
||||
"./tests/do_regtest.py ${__cp2k_cmake_name} ${__cp2k_cmake_exts}\n\n")
|
||||
endif()
|
||||
|
||||
# files needed for cmake
|
||||
|
|
|
|||
|
|
@ -59,17 +59,27 @@ COPY ./tools/toolchain/scripts/arch_base.tmpl \
|
|||
./scripts/
|
||||
RUN ./scripts/generate_arch_files.sh && rm -rf ./build
|
||||
|
||||
# Install DBCSR.
|
||||
WORKDIR /opt/dbcsr
|
||||
COPY ./tools/docker/scripts/install_dbcsr.sh .
|
||||
RUN ./install_dbcsr.sh
|
||||
|
||||
# Install CP2K using CMake.
|
||||
# Install CP2K sources.
|
||||
WORKDIR /opt/cp2k
|
||||
COPY ./src ./src
|
||||
COPY ./exts ./exts
|
||||
COPY ./data ./data
|
||||
COPY ./tests ./tests
|
||||
COPY ./tools/build_utils ./tools/build_utils
|
||||
COPY ./cmake ./cmake
|
||||
COPY ./CMakeLists.txt .
|
||||
|
||||
COPY ./tools/docker/scripts/test_cmake.sh .
|
||||
RUN ./test_cmake.sh 2>&1 | tee report.log
|
||||
# Build CP2K with CMake and run regression tests.
|
||||
ARG TESTOPTS=""
|
||||
COPY ./tools/docker/scripts/test_regtest_cmake.sh ./
|
||||
RUN /bin/bash -o pipefail -c " \
|
||||
TESTOPTS='${TESTOPTS}' \
|
||||
./test_regtest_cmake.sh |& tee report.log && \
|
||||
rm -rf regtesting"
|
||||
|
||||
# Output the report if the image is old and was therefore pulled from the build cache.
|
||||
CMD cat $(find ./report.log -mmin +10) | sed '/^Summary:/ s/$/ (cached)/'
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ def main() -> None:
|
|||
f.write(toolchain_full() + regtest("sdbg", "minimal"))
|
||||
|
||||
with OutputFile(f"Dockerfile.test_cmake", args.check) as f:
|
||||
f.write(toolchain_full() + install_cp2k_cmake())
|
||||
f.write(toolchain_full() + regtest_cmake())
|
||||
|
||||
for version in "ssmp", "psmp":
|
||||
with OutputFile(f"Dockerfile.test_asan-{version}", args.check) as f:
|
||||
|
|
@ -153,6 +153,36 @@ RUN /bin/bash -o pipefail -c " \
|
|||
)
|
||||
|
||||
|
||||
# ======================================================================================
|
||||
def regtest_cmake(testopts: str = "") -> str:
|
||||
return (
|
||||
rf"""
|
||||
# Install DBCSR.
|
||||
WORKDIR /opt/dbcsr
|
||||
COPY ./tools/docker/scripts/install_dbcsr.sh .
|
||||
RUN ./install_dbcsr.sh
|
||||
|
||||
# Install CP2K sources.
|
||||
WORKDIR /opt/cp2k
|
||||
COPY ./src ./src
|
||||
COPY ./data ./data
|
||||
COPY ./tests ./tests
|
||||
COPY ./tools/build_utils ./tools/build_utils
|
||||
COPY ./cmake ./cmake
|
||||
COPY ./CMakeLists.txt .
|
||||
|
||||
# Build CP2K with CMake and run regression tests.
|
||||
ARG TESTOPTS="{testopts}"
|
||||
COPY ./tools/docker/scripts/test_regtest_cmake.sh ./
|
||||
RUN /bin/bash -o pipefail -c " \
|
||||
TESTOPTS='${{TESTOPTS}}' \
|
||||
./test_regtest_cmake.sh |& tee report.log && \
|
||||
rm -rf regtesting"
|
||||
"""
|
||||
+ print_cached_report()
|
||||
)
|
||||
|
||||
|
||||
# ======================================================================================
|
||||
def regtest_postponed(version: str, arch: str = "local") -> str:
|
||||
return (
|
||||
|
|
@ -413,26 +443,6 @@ COPY ./tools/regtesting ./tools/regtesting
|
|||
"""
|
||||
|
||||
|
||||
# ======================================================================================
|
||||
def install_cp2k_cmake() -> str:
|
||||
return (
|
||||
rf"""
|
||||
|
||||
# Install CP2K using CMake.
|
||||
WORKDIR /opt/cp2k
|
||||
COPY ./src ./src
|
||||
COPY ./exts ./exts
|
||||
COPY ./tools/build_utils ./tools/build_utils
|
||||
COPY ./cmake ./cmake
|
||||
COPY ./CMakeLists.txt .
|
||||
|
||||
COPY ./tools/docker/scripts/test_cmake.sh .
|
||||
RUN ./test_cmake.sh 2>&1 | tee report.log
|
||||
"""
|
||||
+ print_cached_report()
|
||||
)
|
||||
|
||||
|
||||
# ======================================================================================
|
||||
def toolchain_full(
|
||||
base_image: str = "ubuntu:22.04", with_gcc: str = "system", **kwargs: str
|
||||
|
|
|
|||
|
|
@ -1,119 +1,38 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
# TODO: Review and if possible fix shellcheck errors.
|
||||
# shellcheck disable=all
|
||||
# shellcheck disable=SC1091
|
||||
source /opt/cp2k-toolchain/install/setup
|
||||
|
||||
[ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=$0
|
||||
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")" && pwd -P)"
|
||||
DBCSR_ver="2.6.0"
|
||||
DBCSR_sha256="c67b02ff9abc7c1f529af446a9f01f3ef9e5b0574f220259128da8d5ca7e9dc6"
|
||||
|
||||
DBCSR_ver="2.5.0"
|
||||
DBCSR_sha256="e5c545ec16688027537f7865976b905c0783d038ec289e65635e63e961330601"
|
||||
source "${SCRIPT_DIR}"/common_vars.sh
|
||||
source "${SCRIPT_DIR}"/tool_kit.sh
|
||||
source "${SCRIPT_DIR}"/signal_trap.sh
|
||||
source "${INSTALLDIR}"/toolchain.conf
|
||||
source "${INSTALLDIR}"/toolchain.env
|
||||
|
||||
[ -f "${BUILDDIR}/setup_dbcsr" ] && rm "${BUILDDIR}/setup_dbcsr"
|
||||
|
||||
DBCSR_CFLAGS=''
|
||||
DBCSR_LDFLAGS=''
|
||||
DBCSR_LIBS=''
|
||||
! [ -d "${BUILDDIR}" ] && mkdir -p "${BUILDDIR}"
|
||||
cd "${BUILDDIR}"
|
||||
|
||||
####case "$with_dbcsr" in
|
||||
#### __INSTALL__)
|
||||
echo "==================== Installing DBCSR ===================="
|
||||
#
|
||||
# to be restored to the right value when this script is included in the toolchain
|
||||
pkg_install_dir="${INSTALLDIR}/DBCSR"
|
||||
install_lock_file="$pkg_install_dir/install_successful"
|
||||
if verify_checksums "${install_lock_file}"; then
|
||||
echo "DBCSR-${DBCSR_ver} is already installed, skipping it."
|
||||
else
|
||||
if [ -f dbcsr-${DBCSR_ver}.tar.gz ]; then
|
||||
echo "dbcsr-${DBCSR_ver}.tar.gz is found"
|
||||
else
|
||||
wget -q "https://github.com/cp2k/dbcsr/archive/refs/tags/v${DBCSR_ver}.tar.gz" -O "dbcsr-${DBCSR_ver}.tar.gz"
|
||||
fi
|
||||
echo "Installing from scratch into ${pkg_install_dir}"
|
||||
[ -d dbcsr-${DBCSR_ver} ] && rm -rf dbcsr-${DBCSR_ver}
|
||||
tar xzf dbcsr-${DBCSR_ver}.tar.gz
|
||||
cd dbcsr-${DBCSR_ver}
|
||||
mkdir build
|
||||
cd build
|
||||
# build compilation option list
|
||||
|
||||
COMPILATION_OPTIONS="-DCMAKE_INSTALL_PREFIX=${pkg_install_dir} -DUSE_OPENMP=ON -DBUILD_TESTING=NO -DWITH_EXAMPLES=NO"
|
||||
if [ "$MPI_MODE" == "no" ]; then
|
||||
COMPILATION_OPTIONS="${COMPILATION_OPTIONS} -DUSE_MPI=no"
|
||||
fi
|
||||
if [ "$ENABLE_CUDA" == "__TRUE__" ]; then
|
||||
COMPILATION_OPTIONS="${COMPILATION_OPTIONS} -DUSE_ACCEL=nvidia -DWITH_GPU=P100"
|
||||
fi
|
||||
if [ "$ENABLE_HIP" == "__TRUE__" ]; then
|
||||
COMPILATION_OPTIONS="${COMPILATION_OPTIONS} -DUSE_ACCEL=hip -DWITH_GPU=Mi250"
|
||||
fi
|
||||
cmake $COMPILATION_OPTIONS ..
|
||||
make -j $(get_nprocs) #> make.log 2>&1
|
||||
make install #> install.log 2>&1
|
||||
cd ..
|
||||
write_checksums "${install_lock_file}" "${SCRIPT_DIR}/$(basename ${SCRIPT_NAME})"
|
||||
DBCSR_CFLAGS="-I'${pkg_install_dir}/include'"
|
||||
DBCSR_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'"
|
||||
wget -q "https://github.com/cp2k/dbcsr/releases/download/v${DBCSR_ver}/dbcsr-${DBCSR_ver}.tar.gz"
|
||||
echo "${DBCSR_sha256} dbcsr-${DBCSR_ver}.tar.gz" | sha256sum --check > /dev/null
|
||||
|
||||
tar xzf dbcsr-${DBCSR_ver}.tar.gz
|
||||
cd dbcsr-${DBCSR_ver}
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
if ! cmake -DCMAKE_INSTALL_PREFIX=/opt/dbcsr -DUSE_MPI=ON -DUSE_OPENMP=ON -DUSE_SMM=blas .. &> cmake.log; then
|
||||
cat cmake.log
|
||||
exit 1
|
||||
fi
|
||||
### ;;
|
||||
### __SYSTEM__)
|
||||
### echo "==================== Finding DBCSR from system paths ===================="
|
||||
### check_lib -ldbcsr "dbcsr"
|
||||
### add_include_from_paths DBCSR_CFLAGS "dbcsr.h" $INCLUDE_PATHS
|
||||
### add_lib_from_paths DBCSR_LDFLAGS "dbcsr.*" $LIB_PATHS
|
||||
### ;;
|
||||
### __DONTUSE__)
|
||||
### report_error ${LINENO} "It is not possible to compile cp2k without dbcsr"
|
||||
### ;;
|
||||
### *)
|
||||
echo "==================== Linking DBCSR to user paths ===================="
|
||||
#####pkg_install_dir="$with_dbcsr"
|
||||
check_dir "${pkg_install_dir}/lib"
|
||||
check_dir "${pkg_install_dir}/include"
|
||||
DBCSR_CFLAGS="-I'${pkg_install_dir}/include'"
|
||||
DBCSR_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'"
|
||||
##;;
|
||||
##esac
|
||||
##if [ "$with_dbcsr" != "__DONTUSE__" ]; then
|
||||
DBCSR_LIBS="-ldbcsr"
|
||||
## if [ "$with_dbscr" != "__SYSTEM__" ]; then
|
||||
cat << EOF > "${BUILDDIR}/setup_dbcsr"
|
||||
prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib"
|
||||
prepend_path LD_RUN_PATH "$pkg_install_dir/lib"
|
||||
prepend_path LIBRARY_PATH "$pkg_install_dir/lib"
|
||||
prepend_path CPATH "$pkg_install_dir/include"
|
||||
prepend_path CMAKE_INSTALL_PREFIX "${pkg_install_dir}"
|
||||
EOF
|
||||
## cat "${BUILDDIR}/setup_dbcsr" >> $SETUPFILE
|
||||
## fi
|
||||
cat << EOF >> "${BUILDDIR}/setup_dbcsr"
|
||||
export DBCSR_CFLAGS="${DBCSR_CFLAGS}"
|
||||
export DBCSR_LDFLAGS="${DBCSR_LDFLAGS}"
|
||||
export DBCSR_LIBS="${DBCSR_LIBS}"
|
||||
export CP_DFLAGS="\${CP_DFLAGS} IF_CUDA(-D__DBCSR_ACC -D__DBCSR|IF_HIP(-D__DBCSR_ACC -D__DBCSR|-D__DBCSR))"
|
||||
export CP_CFLAGS="\${CP_CFLAGS} ${DBCSR_CFLAGS}"
|
||||
export CP_LDFLAGS="\${CP_LDFLAGS} ${DBCSR_LDFLAGS}"
|
||||
export CP_LIBS="${DBCSR_LIBS} \${CP_LIBS}"
|
||||
export DBCSR_ROOT="$pkg_install_dir"
|
||||
EOF
|
||||
|
||||
cat "${BUILDDIR}/setup_dbcsr" >> $SETUPFILE
|
||||
if ! make -j &> make.log; then
|
||||
cat make.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#else
|
||||
# echo "DBCSR is a hard dependency for cp2k"
|
||||
# exit 1
|
||||
#fi
|
||||
if ! make install VERBOSE=1 &> install.log; then
|
||||
cat install.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
load "${BUILDDIR}/setup_dbcsr"
|
||||
write_toolchain_env "${INSTALLDIR}"
|
||||
cd ..
|
||||
rm -rf build "dbcsr-${DBCSR_ver}" "dbcsr-${DBCSR_ver}.tar.gz"
|
||||
|
||||
cd "${ROOTDIR}"
|
||||
report_timing "DBCSR"
|
||||
#EOF
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
source /opt/cp2k-toolchain/install/setup
|
||||
|
||||
ln -s /opt/cp2k/tools/build_utils/fypp /bin/fypp
|
||||
|
||||
DBCSR_ver="2.6.0"
|
||||
|
||||
if [ -f dbcsr-${DBCSR_ver}.tar.gz ]; then
|
||||
echo "dbcsr-${DBCSR_ver}.tar.gz is found"
|
||||
else
|
||||
wget -q "https://github.com/cp2k/dbcsr/archive/refs/tags/v${DBCSR_ver}.tar.gz" -O "dbcsr-${DBCSR_ver}.tar.gz"
|
||||
fi
|
||||
|
||||
[ -d dbcsr-${DBCSR_ver} ] && rm -rf dbcsr-${DBCSR_ver}
|
||||
tar xzf dbcsr-${DBCSR_ver}.tar.gz > dbcsr-build.log 2>&1
|
||||
cd dbcsr-${DBCSR_ver}
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/opt/cp2k -DUSE_MPI=ON -DUSE_OPENMP=ON -DUSE_SMM=blas .. > dbcsr-build.log 2>&1
|
||||
make > dbcsr-build.log 2>&1 && make install > dbcsr-build.log 2>&1
|
||||
cd ../..
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
if ! cmake \
|
||||
-DCMAKE_INSTALL_PREFIX=/opt/cp2k \
|
||||
-Werror=dev \
|
||||
-DCP2K_USE_VORI=ON \
|
||||
-DCP2K_USE_COSMA=NO \
|
||||
-DCP2K_BLAS_VENDOR=OpenBLAS \
|
||||
-DCP2K_USE_SPGLIB=ON \
|
||||
-DCP2K_USE_LIBINT2=ON \
|
||||
-DCP2K_USE_LIBXC=ON \
|
||||
-DCP2K_USE_LIBTORCH=OFF \
|
||||
-DCP2K_USE_MPI=ON \
|
||||
-DCP2K_USE_MPI_F08=ON \
|
||||
-DCP2K_ENABLE_REGTESTS=ON \
|
||||
.. |& tee ./cmake.log; then
|
||||
echo -e "\nSummary: CMake failed."
|
||||
echo -e "Status: FAILED\n"
|
||||
fi
|
||||
|
||||
if grep -A5 'CMake Warning' ./cmake.log; then
|
||||
echo -e "\nSummary: Found CMake warnings."
|
||||
echo -e "Status: FAILED\n"
|
||||
fi
|
||||
|
||||
echo -e '\n\nCompiling cp2k...'
|
||||
if make -j; then
|
||||
echo -e "\nSummary: Compilation works fine."
|
||||
echo -e "Status: OK\n"
|
||||
else
|
||||
echo -e "\nSummary: Compilation failed."
|
||||
echo -e "Status: FAILED\n"
|
||||
fi
|
||||
|
||||
#EOF
|
||||
77
tools/docker/scripts/test_regtest_cmake.sh
Executable file
77
tools/docker/scripts/test_regtest_cmake.sh
Executable file
|
|
@ -0,0 +1,77 @@
|
|||
#!/bin/bash
|
||||
|
||||
# author: Ole Schuett
|
||||
|
||||
ulimit -c 0 # Disable core dumps as they can take a very long time to write.
|
||||
|
||||
# Check available shared memory - needed for MPI inter-process communication.
|
||||
SHM_AVAIL=$(df --output=avail -m /dev/shm | tail -1)
|
||||
if ((SHM_AVAIL < 1024)); then
|
||||
echo "ERROR: Not enough shared memory. If you're running docker use --shm-size=1g."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
source /opt/cp2k-toolchain/install/setup
|
||||
|
||||
# Run CMake.
|
||||
mkdir build
|
||||
cd build || exit 1
|
||||
if ! cmake \
|
||||
-DCMAKE_INSTALL_PREFIX=/opt/cp2k \
|
||||
-Werror=dev \
|
||||
-DCP2K_USE_VORI=ON \
|
||||
-DCP2K_USE_COSMA=NO \
|
||||
-DCP2K_BLAS_VENDOR=OpenBLAS \
|
||||
-DCP2K_USE_SPGLIB=ON \
|
||||
-DCP2K_USE_LIBINT2=ON \
|
||||
-DCP2K_USE_LIBXC=ON \
|
||||
-DCP2K_USE_LIBTORCH=OFF \
|
||||
-DCP2K_USE_MPI=ON \
|
||||
-DCP2K_USE_MPI_F08=ON \
|
||||
-DCP2K_ENABLE_REGTESTS=ON \
|
||||
.. &> ./cmake.log; then
|
||||
tail -n 100 cmake.log
|
||||
echo -e "\nSummary: CMake failed."
|
||||
echo -e "Status: FAILED\n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check for CMake warnings.
|
||||
if grep -A5 'CMake Warning' ./cmake.log; then
|
||||
echo -e "\nSummary: Found CMake warnings."
|
||||
echo -e "Status: FAILED\n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Compile CP2K.
|
||||
echo -n 'Compiling cp2k...'
|
||||
if make -j &> make.log; then
|
||||
echo "done."
|
||||
else
|
||||
echo -e "failed.\n\n"
|
||||
tail -n 100 make.log
|
||||
echo -e "\nSummary: Compilation failed."
|
||||
echo -e "Status: FAILED\n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Fake installation of data files.
|
||||
cd ..
|
||||
mkdir -p ./share/cp2k
|
||||
ln -s ../../data ./share/cp2k/data
|
||||
|
||||
# Improve code coverage on COSMA.
|
||||
export COSMA_DIM_THRESHOLD=0
|
||||
|
||||
ulimit -s unlimited
|
||||
export OMP_STACKSIZE=64m
|
||||
|
||||
# Run regtests.
|
||||
echo -e "\n========== Running Regtests =========="
|
||||
set -x
|
||||
./tests/do_regtest.py local psmp ${TESTOPTS:+""}
|
||||
|
||||
exit 0 # Prevent CI from overwriting do_regtest's summary message.
|
||||
|
||||
#EOF
|
||||
Loading…
Add table
Add a link
Reference in a new issue