Skip to content

Commit

Permalink
Docker: Add test for Intel oneAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
oschuett committed May 9, 2022
1 parent ccdbba7 commit 7b909a0
Show file tree
Hide file tree
Showing 26 changed files with 176 additions and 34 deletions.
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_cuda_A100
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_cuda_P100
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_cuda_V100
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_gcc10
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_gcc7
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_gcc8
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_gcc9
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_generic_pdbg
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_generic_psmp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_generic_sdbg
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_generic_ssmp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_hip_cuda_A100
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_hip_cuda_P100
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_hip_cuda_V100
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_i386
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
104 changes: 104 additions & 0 deletions tools/docker/Dockerfile.test_intel-psmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#
# This file was created by generate_dockerfiles.py.
# Usage: docker build -f ./Dockerfile.test_intel-psmp ../../
#

FROM intel/oneapi-hpckit:2021.4-devel-ubuntu18.04

ENV PATH=/opt/intel/oneapi/compiler/2021.4.0/linux/bin/intel64:/opt/intel/oneapi/mpi/2021.4.0/bin:${PATH}
ENV LD_LIBRARY_PATH=/opt/intel/oneapi/mpi/2021.4.0/lib/release:/opt/intel/oneapi/mpi/2021.4.0/lib:/opt/intel/oneapi/mpi/2021.4.0/libfabric/lib:/opt/intel/oneapi/mkl/2021.4.0/lib/intel64:/opt/intel/oneapi/compiler/2021.4.0/linux/compiler/lib/intel64_lin:${LD_LIBRARY_PATH}
ENV MKLROOT=/opt/intel/oneapi/mkl/2021.4.0
ENV I_MPI_ROOT=/opt/intel/oneapi/mpi/2021.4.0
ENV FI_PROVIDER_PATH='/opt/intel/oneapi/mpi/2021.4.0/libfabric/lib/prov'

ENTRYPOINT []

# Install requirements for the toolchain.
WORKDIR /opt/cp2k-toolchain
COPY ./tools/toolchain/install_requirements*.sh ./
RUN ./install_requirements.sh ubuntu

# Install the toolchain.
RUN mkdir scripts
COPY ./tools/toolchain/scripts/VERSION \
./tools/toolchain/scripts/parse_if.py \
./tools/toolchain/scripts/tool_kit.sh \
./tools/toolchain/scripts/common_vars.sh \
./tools/toolchain/scripts/signal_trap.sh \
./tools/toolchain/scripts/get_openblas_arch.sh \
./scripts/
COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--with-intel \
--with-intelmpi \
--with-libint=no \
--with-elpa=no \
--with-quip=no \
--with-spfft=no \
--with-sirius=no \
--dry-run

# Dry-run leaves behind config files for the followup install scripts.
# This breaks up the lengthy installation into smaller docker build steps.
COPY ./tools/toolchain/scripts/stage0/ ./scripts/stage0/
RUN ./scripts/stage0/install_stage0.sh && rm -rf ./build

COPY ./tools/toolchain/scripts/stage1/ ./scripts/stage1/
RUN ./scripts/stage1/install_stage1.sh && rm -rf ./build

COPY ./tools/toolchain/scripts/stage2/ ./scripts/stage2/
RUN ./scripts/stage2/install_stage2.sh && rm -rf ./build

COPY ./tools/toolchain/scripts/stage3/ ./scripts/stage3/
RUN ./scripts/stage3/install_stage3.sh && rm -rf ./build

COPY ./tools/toolchain/scripts/stage4/ ./scripts/stage4/
RUN ./scripts/stage4/install_stage4.sh && rm -rf ./build

COPY ./tools/toolchain/scripts/stage5/ ./scripts/stage5/
RUN ./scripts/stage5/install_stage5.sh && rm -rf ./build

COPY ./tools/toolchain/scripts/stage6/ ./scripts/stage6/
RUN ./scripts/stage6/install_stage6.sh && rm -rf ./build

COPY ./tools/toolchain/scripts/stage7/ ./scripts/stage7/
RUN ./scripts/stage7/install_stage7.sh && rm -rf ./build

COPY ./tools/toolchain/scripts/stage8/ ./scripts/stage8/
RUN ./scripts/stage8/install_stage8.sh && rm -rf ./build

COPY ./tools/toolchain/scripts/arch_base.tmpl \
./tools/toolchain/scripts/generate_arch_files.sh \
./scripts/
RUN ./scripts/generate_arch_files.sh && rm -rf ./build

# TODO: Remove --mpiranks=1, see github.com/cp2k/cp2k/issues/2103

# Install CP2K using local.psmp.
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.psmp ./arch/ && \
echo 'Compiling cp2k...' && \
source /opt/cp2k-toolchain/install/setup && \
( make -j ARCH=local VERSION=psmp &> /dev/null || true )"
COPY ./data ./data
COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS="--mpiranks=1"
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
./test_regtest.sh 'local' 'psmp' |& 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)/'

#EOF
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_minimal
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_openmpi-psmp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_pdbg
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_psmp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_sdbg
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_ssmp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${TESTOPTS}" \
Expand Down
42 changes: 35 additions & 7 deletions tools/docker/generate_dockerfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ def main() -> None:
# Also testing --with-gcc=install here, see github.com/cp2k/cp2k/issues/2062 .
f.write(toolchain_full(mpi_mode="openmpi", gcc="install") + regtest("psmp"))

with OutputFile(f"Dockerfile.test_fedora-psmp", args.check) as f:
f.write(toolchain_full(base_image="fedora:33") + regtest("psmp"))
with OutputFile(f"Dockerfile.test_intel-psmp", args.check) as f:
f.write(toolchain_intel())
f.write("\n# TODO: Remove --mpiranks=1, see github.com/cp2k/cp2k/issues/2103\n")
f.write(regtest("psmp", testopts="--mpiranks=1"))

with OutputFile(f"Dockerfile.test_minimal", args.check) as f:
f.write(toolchain_full() + regtest("sdbg", "minimal"))
Expand Down Expand Up @@ -97,12 +99,12 @@ def main() -> None:


# ======================================================================================
def regtest(version: str, arch: str = "local") -> str:
def regtest(version: str, arch: str = "local", testopts: str = "") -> str:
return (
install_cp2k(version=version, arch=arch)
+ fr"""
# Run regression tests.
ARG TESTOPTS
ARG TESTOPTS="{testopts}"
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -c " \
TESTOPTS="${{TESTOPTS}}" \
Expand Down Expand Up @@ -359,9 +361,9 @@ def toolchain_full(
gcc: str = "system",
generic: bool = False,
) -> str:
args = dict(install_all=None, mpi_mode=mpi_mode, with_gcc=gcc)
args = dict(install_all="", mpi_mode=mpi_mode, with_gcc=gcc)
if generic:
args["generic"] = None
args["generic"] = ""
return f"\nFROM {base_image}\n\n" + install_toolchain(base_image=base_image, **args)


Expand Down Expand Up @@ -406,6 +408,32 @@ def toolchain_ubuntu_nompi(
)


# ======================================================================================
def toolchain_intel() -> str:
# See https://github.com/cp2k/cp2k/issues/1936
return fr"""
FROM intel/oneapi-hpckit:2021.4-devel-ubuntu18.04
ENV PATH=/opt/intel/oneapi/compiler/2021.4.0/linux/bin/intel64:/opt/intel/oneapi/mpi/2021.4.0/bin:${{PATH}}
ENV LD_LIBRARY_PATH=/opt/intel/oneapi/mpi/2021.4.0/lib/release:/opt/intel/oneapi/mpi/2021.4.0/lib:/opt/intel/oneapi/mpi/2021.4.0/libfabric/lib:/opt/intel/oneapi/mkl/2021.4.0/lib/intel64:/opt/intel/oneapi/compiler/2021.4.0/linux/compiler/lib/intel64_lin:${{LD_LIBRARY_PATH}}
ENV MKLROOT=/opt/intel/oneapi/mkl/2021.4.0
ENV I_MPI_ROOT=/opt/intel/oneapi/mpi/2021.4.0
ENV FI_PROVIDER_PATH='/opt/intel/oneapi/mpi/2021.4.0/libfabric/lib/prov'
ENTRYPOINT []
""" + install_toolchain(
base_image="ubuntu",
with_intel="",
with_intelmpi="",
with_libint="no", # https://github.com/cp2k/cp2k/issues/1999
with_elpa="no", # MPI does not provide a sufficient threading level for OpenMP.
with_quip="no", # Intel compiler is currently not supported.
with_spfft="no", # Spawns infinite chain of mpiicpc sub-processes.
with_sirius="no", # Requires spfft.
)


# ======================================================================================
def toolchain_cuda(gpu_ver: str) -> str:
return fr"""
Expand Down Expand Up @@ -560,7 +588,7 @@ def install_toolchain(base_image: str, **kwargs: Optional[str]) -> str:
install_args = []
for k, v in kwargs.items():
k = k.replace("_", "-")
if v is not None:
if v != "":
install_args.append(f" --{k}={v} \\")
else:
install_args.append(f" --{k} \\")
Expand Down
11 changes: 11 additions & 0 deletions tools/docker/scripts/test_regtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ VERSION=$2

ulimit -c 0 # Disable core dumps as they can take a very long time to write.

# Extend stack size - needed when using Intel compilers.
ulimit -s unlimited
export OMP_STACKSIZE=64m

# 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

Expand Down

0 comments on commit 7b909a0

Please sign in to comment.