@@ -7,38 +7,82 @@ ARG CXX_COMPILER
77ARG FC_COMPILER
88ARG COMPILER_PATH
99ARG COMPILER_LD_LIBRARY_PATH
10+ ARG AFAR_VERSION
11+ ARG OLCF_AFAR_ROOT=""
12+
13+ ENV DEBIAN_FRONTEND=noninteractive
14+ ENV TZ=UTC
1015
1116RUN apt-get update -y && \
12- apt-get install -y software-properties-common ca-certificates gnupg && \
17+ apt-get install -y software-properties-common ca-certificates gnupg wget && \
1318 add-apt-repository ppa:deadsnakes/ppa && \
1419 apt-get update -y && \
15- if [ "$TARGET" ! = "gpu " ]; then \
20+ if [ "$TARGET" = "cpu " ]; then \
1621 apt-get install -y \
1722 build-essential git make cmake gcc g++ gfortran bc \
1823 python3.12 python3.12-venv python3-pip \
1924 openmpi-bin libopenmpi-dev libfftw3-dev \
2025 mpich libmpich-dev; \
21- else \
26+ elif [ "$TARGET" = "gpu" ]; then \
2227 apt-get install -y \
2328 build-essential git make cmake bc \
2429 python3.12 python3.12-venv python3-pip \
2530 libfftw3-dev \
2631 openmpi-bin libopenmpi-dev; \
32+ elif [ "$TARGET" = "amd" ]; then \
33+ apt-get install -y \
34+ build-essential git make gcc g++ gfortran bc \
35+ python3.12 python3.12-venv python3-pip \
36+ libfftw3-dev libnuma1 libdrm2 libdrm-amdgpu1; \
2737 fi && \
2838 update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 2 && \
2939 rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
3040
41+ # AMD: download AFAR, install cmake 3.28 (Ubuntu 22.04 ships 3.22 which doesn't
42+ # recognize amdflang as LLVMFlang), then build MPICH with amdflang so the
43+ # generated mpi.mod is compiler-compatible.
44+ RUN if [ "$TARGET" = "amd" ] && [ -n "$AFAR_VERSION" ]; then \
45+ OLCF_AFAR_ROOT="/opt/${AFAR_VERSION}" && \
46+ wget -q "https://repo.radeon.com/rocm/misc/flang/${AFAR_VERSION}-ubuntu.tar.bz2" -O /tmp/afar.tar.bz2 && \
47+ tar -xjf /tmp/afar.tar.bz2 -C /opt/ && \
48+ rm /tmp/afar.tar.bz2 && \
49+ CMAKE_VER=3.28.6 && \
50+ wget -q "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/cmake-${CMAKE_VER}-linux-x86_64.sh" \
51+ -O /tmp/cmake-install.sh && \
52+ chmod +x /tmp/cmake-install.sh && \
53+ /tmp/cmake-install.sh --prefix=/usr/local --skip-license --exclude-subdir && \
54+ rm /tmp/cmake-install.sh && \
55+ printf '#!/bin/bash\n args=()\n while [ "$#" -gt 0 ]; do\n if [ "$1" = "-soname" ]; then\n args+=("-Wl,-soname,$2"); shift 2\n else\n args+=("$1"); shift\n fi\n done\n exec ' "${OLCF_AFAR_ROOT}" '/bin/amdflang "${args[@]}"\n ' \
56+ > /usr/local/bin/amdflang-ld-wrap && \
57+ chmod +x /usr/local/bin/amdflang-ld-wrap && \
58+ MPICH_VER=3.4.3 && \
59+ wget -q "https://www.mpich.org/static/downloads/${MPICH_VER}/mpich-${MPICH_VER}.tar.gz" \
60+ -O /tmp/mpich.tar.gz && \
61+ mkdir -p /tmp/mpich-src && \
62+ tar -xzf /tmp/mpich.tar.gz -C /tmp/mpich-src --strip-components=1 && \
63+ cd /tmp/mpich-src && \
64+ FC=/usr/local/bin/amdflang-ld-wrap CC=gcc CXX=g++ \
65+ ./configure --prefix=/opt/mpich --enable-shared --disable-static \
66+ --with-device=ch3 2>&1 && \
67+ make -j$(nproc) 2>&1 && \
68+ make install 2>&1 && \
69+ cd / && \
70+ rm -rf /tmp/mpich-src /tmp/mpich.tar.gz; \
71+ fi
72+
3173ENV OMPI_ALLOW_RUN_AS_ROOT=1
3274ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
75+ ENV HYDRA_LAUNCHER=fork
3376ENV PATH="/opt/MFC:$PATH"
3477
3578COPY ../ /opt/MFC
3679
3780ENV CC=${CC_COMPILER}
3881ENV CXX=${CXX_COMPILER}
3982ENV FC=${FC_COMPILER}
40- ENV PATH="${COMPILER_PATH}:$PATH"
41- ENV LD_LIBRARY_PATH="${COMPILER_LD_LIBRARY_PATH}:${LD_LIBRARY_PATH:-}"
83+ ENV OLCF_AFAR_ROOT=${OLCF_AFAR_ROOT}
84+ ENV PATH="${COMPILER_PATH}:/opt/mpich/bin:$PATH"
85+ ENV LD_LIBRARY_PATH="${COMPILER_LD_LIBRARY_PATH}:/opt/mpich/lib:${LD_LIBRARY_PATH:-}"
4286
4387# Pre-install numpy into the venv before mfc.sh runs, as it's required at
4488# build time by several dependencies (pandas, cantera, matplotlib, etc.) that
@@ -50,14 +94,18 @@ RUN python3.12 -m venv /opt/MFC/build/venv && \
5094RUN echo "TARGET=$TARGET CC=$CC_COMPILER FC=$FC_COMPILER" && \
5195 cd /opt/MFC && \
5296 if [ "$TARGET" = "gpu" ]; then \
53- ./mfc.sh build --gpu -j $(nproc); \
97+ ./mfc.sh build --gpu acc -j $(nproc); \
98+ elif [ "$TARGET" = "amd" ]; then \
99+ ./mfc.sh build --gpu mp -j $(nproc); \
54100 else \
55101 ./mfc.sh build -j $(nproc); \
56102 fi
57103
58104RUN cd /opt/MFC && \
59105 if [ "$TARGET" = "gpu" ]; then \
60- ./mfc.sh test -a --dry-run --gpu -j $(nproc); \
106+ ./mfc.sh test -a --dry-run --gpu acc -j $(nproc); \
107+ elif [ "$TARGET" = "amd" ]; then \
108+ ./mfc.sh test -a --dry-run --gpu mp -j $(nproc); \
61109 else \
62110 ./mfc.sh test -a --dry-run -j $(nproc); \
63111 fi
0 commit comments