Skip to content

Commit

Permalink
arch: add few missing configs to new amd docker and arch detection
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Apr 17, 2023
1 parent 15c4b1b commit adbf4d9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
6 changes: 5 additions & 1 deletion devito/arch/archinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,12 @@ def march(cls):
# mygpu will only print values accepted by cuda clang in
# the clang argument --cuda-gpu-arch.
try:
p1 = Popen(['mygpu', '-d', 'gfx900'], stdout=PIPE, stderr=PIPE)
p1 = Popen(['offload-arch'], stdout=PIPE, stderr=PIPE)
except OSError:
try:
p1 = Popen(['mygpu', '-d', fallback], stdout=PIPE, stderr=PIPE)
except OSError:
pass
return fallback

output, _ = p1.communicate()
Expand Down
31 changes: 24 additions & 7 deletions docker/Dockerfile.amd
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# This Dockerfile contains AMD compilers
##############################################################

ARG IMAGE="rocm/dev-ubuntu-22.04:5.4.2-complete"
ARG ROCM_VERSION=5.4.2
ARG arch="aomp"

FROM ${IMAGE} as sdk-base
FROM rocm/dev-ubuntu-22.04:${ROCM_VERSION}-complete as sdk-base

ARG UCX_BRANCH="v1.13.1"
ARG OMPI_BRANCH="v4.1.4"
Expand Down Expand Up @@ -35,8 +35,10 @@ RUN rm /etc/apt/sources.list.d/* \
gfortran \
flex \
hwloc \
&& apt-get clean \
&& ln -s /opt/rocm/llvm/bin/offload-arch /opt/rocm/bin/offload-arch
&& apt-get clean

# Until rocm base has it fixed
RUN ln -s /opt/rocm/llvm/bin/offload-arch /opt/rocm/bin/offload-arch

# Requires cmake > 3.22
RUN mkdir -p /opt/cmake \
Expand All @@ -46,6 +48,9 @@ ENV ROCM_HOME=/opt/rocm \
UCX_HOME=/opt/ucx \
OMPI_HOME=/opt/ompi

# Install tmpi
RUN curl https://raw.githubusercontent.com/Azrael3000/tmpi/master/tmpi -o /usr/local/bin/tmpi

# Adding rocm/cmake to the Environment
ENV PATH=$ROCM_HOME/bin:$ROCM_HOME/profiler/bin:$ROCM_HOME/opencl/bin:/opt/cmake/bin:$PATH \
LD_LIBRARY_PATH=$ROCM_HOME/lib:$ROCM_HOME/lib64:$ROCM_HOME/llvm/lib:$LD_LIBRARY_PATH \
Expand Down Expand Up @@ -73,8 +78,8 @@ RUN cd /tmp/ \
--disable-logging \
--disable-debug \
--disable-examples \
&& make -j $(nproc) \
&& make install
&& make -j $(( $(lscpu | awk '/^Socket\(s\)/{ print $2 }') * $(lscpu | awk '/^Core\(s\) per socket/{ print $4 }') )) \
&& make install \

# Install OpenMPI
RUN cd /tmp \
Expand All @@ -90,9 +95,13 @@ RUN cd /tmp \
--enable-mpi \
--enable-mpi-fortran=yes \
--disable-debug \
&& make -j $(nproc) \
&& make -j $(( $(lscpu | awk '/^Socket\(s\)/{ print $2 }') * $(lscpu | awk '/^Core\(s\) per socket/{ print $4 }') )) \
&& make install

# Cleanup
RUN rm -rf /tmp/ompi && rm -rf /tmp/ucx


# Adding OpenMPI and UCX to Environment
ENV PATH=$OMPI_HOME/bin:$UCX_HOME/bin:$PATH \
LD_LIBRARY_PATH=$OMPI_HOME/lib:$UCX_HOME/lib:$LD_LIBRARY_PATH \
Expand Down Expand Up @@ -131,6 +140,10 @@ RUN which mpicc && \
# This will only trigger if arch is aomp since the final stage depends on it
FROM sdk-base as aomp

# MPI env
ENV OMPI_CC="amdclang"
ENV OMPI_CXX="amdclang++"

# Devito env
ENV DEVITO_ARCH="aomp"
ENV DEVITO_PLATFORM="amdgpuX"
Expand All @@ -143,6 +156,10 @@ ENV DEVITO_LANGUAGE="openmp"
# This will only trigger if arch is hip since the final stage depends on it
FROM sdk-base as hip

# MPI env
ENV OMPI_CC="hipcc"
ENV OMPI_CXX="hipcc"

# Devito env
ENV DEVITO_ARCH="hip"
ENV DEVITO_PLATFORM="amdgpuX"
Expand Down

0 comments on commit adbf4d9

Please sign in to comment.