Skip to content

Commit

Permalink
Update docker files for Intel
Browse files Browse the repository at this point in the history
- Exclude SIRIUS and libtorch from toolchain build
- Prepare for automatic Intel arch file generation
  • Loading branch information
mkrack committed Mar 7, 2023
1 parent acdfcf0 commit 96c0780
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
2 changes: 2 additions & 0 deletions tools/docker/Dockerfile.prod_intel_psmp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ RUN ./install_cp2k_toolchain.sh \
--install-all \
--with-intelmpi \
--with-mkl \
--with-libtorch=no \
--with-sirius=no \
--dry-run

# Dry-run leaves behind config files for the followup install scripts.
Expand Down
12 changes: 7 additions & 5 deletions tools/docker/Dockerfile.test_intel-psmp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ RUN ./install_cp2k_toolchain.sh \
--install-all \
--with-intelmpi \
--with-mkl \
--with-libtorch=no \
--with-sirius=no \
--dry-run

# Dry-run leaves behind config files for the followup install scripts.
Expand Down Expand Up @@ -60,18 +62,18 @@ COPY ./tools/toolchain/scripts/arch_base.tmpl \
./scripts/
RUN ./scripts/generate_arch_files.sh && rm -rf ./build

# Install CP2K using Linux-intel-x86_64.psmp.
# Install CP2K using local.psmp.
WORKDIR /opt/cp2k
COPY ./Makefile .
COPY ./src ./src
COPY ./exts ./exts
COPY ./tools/build_utils ./tools/build_utils
COPY ./arch/Linux-intel-x86_64.psmp /opt/cp2k/arch/
RUN /bin/bash -c " \
ln -s /opt/cp2k-toolchain /opt/cp2k/tools/toolchain && \
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=Linux-intel-x86_64 VERSION=psmp &> /dev/null || true ) && \
( make -j ARCH=local VERSION=psmp &> /dev/null || true ) && \
rm -rf lib obj"
COPY ./data ./data
COPY ./tests ./tests
Expand All @@ -82,7 +84,7 @@ ARG TESTOPTS=""
COPY ./tools/docker/scripts/test_regtest.sh ./
RUN /bin/bash -o pipefail -c " \
TESTOPTS="${TESTOPTS}" \
./test_regtest.sh 'Linux-intel-x86_64' 'psmp' |& tee report.log && \
./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.
Expand Down
26 changes: 18 additions & 8 deletions tools/docker/generate_dockerfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ def main() -> None:
f.write(regtest("psmp"))

with OutputFile(f"Dockerfile.test_intel-psmp", args.check) as f:
f.write(toolchain_intel() + regtest("psmp", "Linux-intel-x86_64"))
f.write(toolchain_intel() + regtest("psmp", intel=True))

with OutputFile(f"Dockerfile.prod_intel_psmp", args.check) as f:
f.write(toolchain_intel() + production("psmp", "Linux-intel-x86_64"))
f.write(
toolchain_intel() + production("psmp", "Linux-intel-x86_64", intel=True)
)

with OutputFile(f"Dockerfile.test_nvhpc", args.check) as f:
f.write(toolchain_nvhpc())
Expand Down Expand Up @@ -119,9 +121,11 @@ def main() -> None:


# ======================================================================================
def regtest(version: str, arch: str = "local", testopts: str = "") -> str:
def regtest(
version: str, arch: str = "local", testopts: str = "", intel: bool = False
) -> str:
return (
install_cp2k(version=version, arch=arch)
install_cp2k(version=version, arch=arch, intel=intel)
+ rf"""
# Run regression tests.
ARG TESTOPTS="{testopts}"
Expand Down Expand Up @@ -307,9 +311,9 @@ def print_cached_report() -> str:


# ======================================================================================
def production(version: str, arch: str = "local") -> str:
def production(version: str, arch: str = "local", intel: bool = False) -> str:
return (
install_cp2k(version=version, arch=arch, revision=True, prod=True)
install_cp2k(version=version, arch=arch, revision=True, prod=True, intel=intel)
+ rf"""
# Run regression tests.
ARG TESTOPTS
Expand All @@ -331,7 +335,11 @@ def production(version: str, arch: str = "local") -> str:

# ======================================================================================
def install_cp2k(
version: str, arch: str, revision: bool = False, prod: bool = False
version: str,
arch: str,
revision: bool = False,
prod: bool = False,
intel: bool = False,
) -> str:
input_lines = []
run_lines = []
Expand Down Expand Up @@ -373,7 +381,7 @@ def install_cp2k(
run_lines.append(f"rm -rf lib obj")

# Ensure MPI is dynamically linked, which is needed e.g. for Shifter.
if version.startswith("p") and not "intel" in arch:
if version.startswith("p") and not intel:
binary = f"./exe/{arch}/cp2k.{version}"
run_lines.append(f"( [ ! -f {binary} ] || ldd {binary} | grep -q libmpi )")

Expand Down Expand Up @@ -490,6 +498,8 @@ def toolchain_intel() -> str:
install_all="",
with_intelmpi="",
with_mkl="",
with_libtorch="no",
with_sirius="no",
)


Expand Down

0 comments on commit 96c0780

Please sign in to comment.