Skip to content

Commit

Permalink
Docker: Migrate ssmp test to CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
oschuett committed May 15, 2024
1 parent 3ae08ec commit c5411e0
Show file tree
Hide file tree
Showing 9 changed files with 221 additions and 100 deletions.
22 changes: 11 additions & 11 deletions tools/docker/Dockerfile.test_ssmp
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,25 @@ COPY ./tools/toolchain/scripts/arch_base.tmpl \
./scripts/
RUN ./scripts/generate_arch_files.sh && rm -rf ./build

# Install CP2K using local.ssmp.
# Install DBCSR
COPY ./tools/docker/scripts/install_dbcsr.sh ./
RUN /bin/bash -o pipefail -c "source /opt/cp2k-toolchain/install/setup; ./install_dbcsr.sh"

# Install CP2K sources.
WORKDIR /opt/cp2k
COPY ./Makefile .
COPY ./src ./src
COPY ./exts ./exts
COPY ./tools/build_utils ./tools/build_utils
RUN /bin/bash -c " \
mkdir -p arch && \
ln -vs /opt/cp2k-toolchain/install/arch/local.ssmp ./arch/"
COPY ./data ./data
COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting
COPY ./tools/build_utils ./tools/build_utils
COPY ./cmake ./cmake
COPY ./CMakeLists.txt .

# Run regression tests.
# Build CP2K with CMake and run regression tests.
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
COPY ./tools/docker/scripts/build_cp2k_cmake.sh ./tools/docker/scripts/test_regtest_cmake.sh ./
RUN /bin/bash -o pipefail -c " \
TESTOPTS='${TESTOPTS}' \
./test_regtest.sh 'local' 'ssmp' |& tee report.log && \
./test_regtest_cmake.sh toolchain ssmp |& tee report.log && \
rm -rf regtesting"

# Output the report if the image is old and was therefore pulled from the build cache.
Expand Down
26 changes: 21 additions & 5 deletions tools/docker/generate_dockerfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ def main() -> None:

for version in "sdbg", "ssmp", "pdbg", "psmp":
with OutputFile(f"Dockerfile.test_{version}", args.check) as f:
f.write(toolchain_full() + regtest(version))
if version == "ssmp":
# Use ssmp as guinea pig
f.write(toolchain_full(with_dbcsr=True))
f.write(regtest_cmake("toolchain", version))
else:
f.write(toolchain_full() + regtest(version))

with OutputFile(f"Dockerfile.test_generic_{version}", args.check) as f:
f.write(toolchain_full(target_cpu="generic") + regtest(version))
Expand Down Expand Up @@ -135,7 +140,7 @@ def regtest(


# ======================================================================================
def regtest_cmake(arch: str, version: str, testopts: str = "") -> str:
def regtest_cmake(profile: str, version: str, testopts: str = "") -> str:
return (
rf"""
# Install CP2K sources.
Expand All @@ -152,7 +157,7 @@ def regtest_cmake(arch: str, version: str, testopts: str = "") -> str:
COPY ./tools/docker/scripts/build_cp2k_cmake.sh ./tools/docker/scripts/test_regtest_cmake.sh ./
RUN /bin/bash -o pipefail -c " \
TESTOPTS='${{TESTOPTS}}' \
./test_regtest_cmake.sh {arch} {version} |& tee report.log && \
./test_regtest_cmake.sh {profile} {version} |& tee report.log && \
rm -rf regtesting"
"""
+ print_cached_report()
Expand Down Expand Up @@ -390,11 +395,22 @@ def install_cp2k(

# ======================================================================================
def toolchain_full(
base_image: str = "ubuntu:24.04", with_gcc: str = "system", **kwargs: str
base_image: str = "ubuntu:24.04",
with_gcc: str = "system",
with_dbcsr: bool = False,
**kwargs: str,
) -> str:
return f"\nFROM {base_image}\n\n" + install_toolchain(
output = f"\nFROM {base_image}\n\n"
output += install_toolchain(
base_image=base_image, install_all="", with_gcc=with_gcc, **kwargs
)
if with_dbcsr:
output += r"""
# Install DBCSR
COPY ./tools/docker/scripts/install_dbcsr.sh ./
RUN /bin/bash -o pipefail -c "source /opt/cp2k-toolchain/install/setup; ./install_dbcsr.sh"
"""
return output


# ======================================================================================
Expand Down
251 changes: 175 additions & 76 deletions tools/docker/scripts/build_cp2k_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

# author: Ole Schuett

if (($# != 1)); then
echo "Usage: build_cp2k_cmake.sh <PROFILE>"
if (($# != 2)); then
echo "Usage: build_cp2k_cmake.sh <PROFILE> <VERSION>"
exit 1
fi

PROFILE=$1
VERSION=$2

echo "==================== Building CP2K ===================="

Expand All @@ -17,89 +18,187 @@ echo "==================== Building CP2K ===================="
mkdir build
cd build || exit 1

# TODO: Reconcile PROFILE with CP2K_BUILD_OPTIONS in CMakeLists.txt.
case ${PROFILE} in
spack)
eval "$(spack env activate myenv --sh)"
cmake \
-GNinja \
-DCMAKE_C_FLAGS="-fno-lto" \
-DCMAKE_Fortran_FLAGS="-fno-lto" \
-DCMAKE_INSTALL_PREFIX=/opt/cp2k \
-Werror=dev \
-DCP2K_USE_VORI=OFF \
-DCP2K_USE_COSMA=OFF \
-DCP2K_USE_DLAF=ON \
-DCP2K_BLAS_VENDOR=OpenBLAS \
-DCP2K_USE_SPGLIB=ON \
-DCP2K_USE_LIBINT2=OFF \
-DCP2K_USE_LIBXC=ON \
-DCP2K_USE_LIBTORCH=OFF \
-DCP2K_USE_MPI=ON \
-DCP2K_USE_MPI_F08=ON \
-DCP2K_ENABLE_REGTESTS=ON \
.. |& tee ./cmake.log
CMAKE_EXIT_CODE=$?
;;
ubuntu)
# TODO fix spglib https://github.com/cp2k/cp2k/issues/3414
cmake \
-GNinja \
-DCMAKE_INSTALL_PREFIX=/opt/cp2k \
-Werror=dev \
-DCP2K_ENABLE_REGTESTS=ON \
-DCP2K_BLAS_VENDOR=OpenBLAS \
-DCP2K_USE_LIBINT2=ON \
-DCP2K_USE_LIBXC=ON \
-DCP2K_USE_FFTW3=ON \
-DCP2K_USE_LIBXSMM=ON \
-DCP2K_USE_SPGLIB=OFF \
-DCP2K_USE_MPI=OFF \
-DCP2K_USE_MPI_F08=OFF \
-DCP2K_USE_VORI=OFF \
-DCP2K_USE_COSMA=OFF \
-DCP2K_USE_DLAF=OFF \
-DCP2K_USE_LIBTORCH=OFF \
.. |& tee ./cmake.log
CMAKE_EXIT_CODE=$?
;;
minimal)
cmake \
-GNinja \
-DCMAKE_INSTALL_PREFIX=/opt/cp2k \
-Werror=dev \
-DCP2K_ENABLE_REGTESTS=ON \
-DCP2K_BLAS_VENDOR=OpenBLAS \
-DCP2K_USE_LIBINT2=OFF \
-DCP2K_USE_LIBXC=OFF \
-DCP2K_USE_FFTW3=OFF \
-DCP2K_USE_MPI=OFF \
-DCP2K_USE_MPI_F08=OFF \
-DCP2K_USE_VORI=OFF \
-DCP2K_USE_COSMA=OFF \
-DCP2K_USE_DLAF=OFF \
-DCP2K_USE_SPGLIB=OFF \
-DCP2K_USE_LIBTORCH=OFF \
.. |& tee ./cmake.log
CMAKE_EXIT_CODE=$?
;;
*)
echo "Unknown profile ${PROFILE}."
exit 1
;;
esac
if [[ "${PROFILE}" == "spack" ]]; then
eval "$(spack env activate myenv --sh)"
elif [[ "${PROFILE}" == "toolchain" ]]; then
# shellcheck disable=SC1091
source /opt/cp2k-toolchain/install/setup
fi

# TODO: Reconcile PROFILE/VERSION with CP2K_BUILD_OPTIONS in CMakeLists.txt.
if [[ "${PROFILE}" == "spack" ]] && [[ "${VERSION}" == "psmp" ]]; then
cmake \
-GNinja \
-DCMAKE_C_FLAGS="-fno-lto" \
-DCMAKE_Fortran_FLAGS="-fno-lto" \
-DCMAKE_INSTALL_PREFIX=/opt/cp2k \
-Werror=dev \
-DCP2K_USE_VORI=OFF \
-DCP2K_USE_COSMA=OFF \
-DCP2K_USE_DLAF=ON \
-DCP2K_BLAS_VENDOR=OpenBLAS \
-DCP2K_USE_SPGLIB=ON \
-DCP2K_USE_LIBINT2=OFF \
-DCP2K_USE_LIBXC=ON \
-DCP2K_USE_LIBTORCH=OFF \
-DCP2K_USE_MPI=ON \
-DCP2K_USE_MPI_F08=ON \
-DCP2K_ENABLE_REGTESTS=ON \
.. |& tee ./cmake.log
CMAKE_EXIT_CODE=$?

elif [[ "${PROFILE}" == "toolchain" ]] && [[ "${VERSION}" == "ssmp" ]]; then
cmake \
-GNinja \
-DCMAKE_INSTALL_PREFIX=/opt/cp2k \
-Werror=dev \
-DCP2K_ENABLE_REGTESTS=ON \
-DCP2K_BLAS_VENDOR=OpenBLAS \
-DCP2K_USE_LIBINT2=ON \
-DCP2K_USE_LIBXC=ON \
-DCP2K_USE_FFTW3=ON \
-DCP2K_USE_SPGLIB=ON \
-DCP2K_USE_VORI=ON \
-DCP2K_USE_MPI=OFF \
-DCP2K_USE_MPI_F08=OFF \
-DCP2K_USE_COSMA=OFF \
-DCP2K_USE_DLAF=OFF \
-DCP2K_USE_LIBTORCH=OFF \
.. |& tee ./cmake.log
CMAKE_EXIT_CODE=$?

elif [[ "${PROFILE}" == "toolchain" ]] && [[ "${VERSION}" == "sdbg" ]]; then
cmake \
-GNinja \
-DCMAKE_INSTALL_PREFIX=/opt/cp2k \
-Werror=dev \
-DCP2K_DEBUG_MODE=ON \
-DCP2K_ENABLE_REGTESTS=ON \
-DCP2K_BLAS_VENDOR=OpenBLAS \
-DCP2K_USE_LIBINT2=ON \
-DCP2K_USE_LIBXC=ON \
-DCP2K_USE_FFTW3=ON \
-DCP2K_USE_SPGLIB=ON \
-DCP2K_USE_VORI=ON \
-DCP2K_USE_MPI=OFF \
-DCP2K_USE_MPI_F08=OFF \
-DCP2K_USE_COSMA=OFF \
-DCP2K_USE_DLAF=OFF \
-DCP2K_USE_LIBTORCH=OFF \
.. |& tee ./cmake.log
CMAKE_EXIT_CODE=$?

elif [[ "${PROFILE}" == "toolchain" ]] && [[ "${VERSION}" == "psmp" ]]; then
# TODO Fix ELPA, COSMA, SIRIUS, QUIP, PEXSI, and Torch.
# https://github.com/cp2k/cp2k/issues/3416
cmake \
-GNinja \
-DCMAKE_INSTALL_PREFIX=/opt/cp2k \
-Werror=dev \
-DCP2K_ENABLE_REGTESTS=ON \
-DCP2K_BLAS_VENDOR=OpenBLAS \
-DCP2K_USE_LIBINT2=ON \
-DCP2K_USE_LIBXC=ON \
-DCP2K_USE_FFTW3=ON \
-DCP2K_USE_SPGLIB=ON \
-DCP2K_USE_VORI=ON \
-DCP2K_USE_MPI=ON \
-DCP2K_USE_MPI_F08=ON \
-DCP2K_USE_LIBXSMM=ON \
-DCP2K_USE_SUPERLU=ON \
-DCP2K_USE_PLUMED=ON \
-DCP2K_USE_PEXSI=ON \
-DCP2K_USE_SPLA=ON \
-DCP2K_USE_METIS=ON \
-DCP2K_USE_ELPA=OFF \
-DCP2K_USE_COSMA=OFF \
-DCP2K_USE_SIRIUS=OFF \
-DCP2K_USE_QUIP=OFF \
-DCP2K_USE_PEXSI=OFF \
-DCP2K_USE_LIBTORCH=OFF \
-DCP2K_USE_DLAF=OFF \
.. |& tee ./cmake.log
CMAKE_EXIT_CODE=$?

elif [[ "${PROFILE}" == "toolchain" ]] && [[ "${VERSION}" == "pdbg" ]]; then
cmake \
-GNinja \
-DCMAKE_INSTALL_PREFIX=/opt/cp2k \
-Werror=dev \
-DCP2K_DEBUG_MODE=ON \
-DCP2K_ENABLE_REGTESTS=ON \
-DCP2K_BLAS_VENDOR=OpenBLAS \
-DCP2K_USE_LIBINT2=ON \
-DCP2K_USE_LIBXC=ON \
-DCP2K_USE_FFTW3=ON \
-DCP2K_USE_MPI=ON \
-DCP2K_USE_MPI_F08=ON \
-DCP2K_USE_SPGLIB=ON \
-DCP2K_USE_VORI=ON \
-DCP2K_USE_COSMA=OFF \
-DCP2K_USE_DLAF=OFF \
-DCP2K_USE_LIBTORCH=OFF \
.. |& tee ./cmake.log
CMAKE_EXIT_CODE=$?

elif [[ "${PROFILE}" == "ubuntu" ]] && [[ "${VERSION}" == "ssmp" ]]; then
# TODO fix spglib https://github.com/cp2k/cp2k/issues/3414
cmake \
-GNinja \
-DCMAKE_INSTALL_PREFIX=/opt/cp2k \
-Werror=dev \
-DCP2K_ENABLE_REGTESTS=ON \
-DCP2K_BLAS_VENDOR=OpenBLAS \
-DCP2K_USE_LIBINT2=ON \
-DCP2K_USE_LIBXC=ON \
-DCP2K_USE_FFTW3=ON \
-DCP2K_USE_LIBXSMM=ON \
-DCP2K_USE_SPGLIB=OFF \
-DCP2K_USE_MPI=OFF \
-DCP2K_USE_MPI_F08=OFF \
-DCP2K_USE_VORI=OFF \
-DCP2K_USE_COSMA=OFF \
-DCP2K_USE_DLAF=OFF \
-DCP2K_USE_LIBTORCH=OFF \
.. |& tee ./cmake.log
CMAKE_EXIT_CODE=$?

elif [[ "${PROFILE}" == "minimal" ]] && [[ "${VERSION}" == "ssmp" ]]; then
cmake \
-GNinja \
-DCMAKE_INSTALL_PREFIX=/opt/cp2k \
-Werror=dev \
-DCP2K_ENABLE_REGTESTS=ON \
-DCP2K_BLAS_VENDOR=OpenBLAS \
-DCP2K_USE_LIBINT2=OFF \
-DCP2K_USE_LIBXC=OFF \
-DCP2K_USE_FFTW3=OFF \
-DCP2K_USE_MPI=OFF \
-DCP2K_USE_MPI_F08=OFF \
-DCP2K_USE_VORI=OFF \
-DCP2K_USE_COSMA=OFF \
-DCP2K_USE_DLAF=OFF \
-DCP2K_USE_SPGLIB=OFF \
-DCP2K_USE_LIBTORCH=OFF \
.. |& tee ./cmake.log
CMAKE_EXIT_CODE=$?

else
echo "Unknown combination profile: ${PROFILE} version: ${VERSION}."
exit 1
fi

if [ $CMAKE_EXIT_CODE -ne 0 ]; then
echo -e "\nSummary: CMake failed."
echo -e "Status: FAILED\n"
exit 0
exit 1
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
exit 1
fi

# Compile CP2K.
Expand All @@ -113,7 +212,7 @@ else
cp ninja.log /workspace/artifacts/
echo -e "\nSummary: Compilation failed."
echo -e "Status: FAILED\n"
exit 0
exit 1
fi

#EOF
2 changes: 1 addition & 1 deletion tools/docker/scripts/test_aiida.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# author: Ole Schuett

# Compile CP2K.
./build_cp2k_cmake.sh "ubuntu" || exit 0
./build_cp2k_cmake.sh "ubuntu" "ssmp" || exit 0

echo -e "\n========== Installing Dependencies =========="
apt-get update -qq
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/scripts/test_ase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# author: Ole Schuett

# Compile CP2K.
./build_cp2k_cmake.sh "ubuntu" || exit 0
./build_cp2k_cmake.sh "ubuntu" "ssmp" || exit 0

# Fake installation of data files.
mkdir -p ./share/cp2k
Expand Down
Loading

0 comments on commit c5411e0

Please sign in to comment.