Skip to content

Commit 6cb6906

Browse files
committed
comiler: better handle buffer ispace
1 parent a75cbf7 commit 6cb6906

3 files changed

Lines changed: 52 additions & 31 deletions

File tree

.github/workflows/docker-bases.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ on:
1818
inputs:
1919
cpu:
2020
type: boolean
21-
default: false
21+
default: true
2222
nvidia:
2323
type: boolean
24-
default: false
24+
default: true
2525
amd:
2626
type: boolean
27-
default: false
27+
default: true
2828
intel:
2929
type: boolean
30-
default: false
30+
default: true
3131

3232
tags:
3333
description: "Build compiler bases"

devito/passes/clusters/buffering.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -461,12 +461,13 @@ def itdims(self):
461461
@cached_property
462462
def ispace(self):
463463
# The IterationSpace within which the buffer will be accessed
464+
464465
# NOTE: The `key` is to avoid Clusters including `f` but not directly
465466
# using it in an expression, such as HaloTouch Clusters
466467
def key(c):
467468
bufferdim = any(i in c.ispace.dimensions for i in self.bdims)
468-
timeonly = all(d.is_Time for d in c.ispace.dimensions)
469-
return bufferdim or timeonly
469+
xd_only = all(d._defines & self.xd._defines for d in c.ispace.dimensions)
470+
return bufferdim or xd_only
470471

471472
ispaces = set()
472473
for c in self.clusters:
@@ -478,14 +479,13 @@ def key(c):
478479
continue
479480

480481
# Iterations space and buffering dims
481-
ispace = c.ispace
482-
edims = [d for d in self.bdims if d not in ispace.dimensions]
482+
edims = [d for d in self.bdims if d not in c.ispace.dimensions]
483483
if not edims:
484-
ispaces.add(ispace)
484+
ispaces.add(c.ispace)
485485
else:
486486
# Add all missing buffering dimensions and reorder to
487487
# avoid duplicates with different ordering
488-
ispaces.add(ispace.insert(self.dim, edims).reorder())
488+
ispaces.add(c.ispace.insert(self.dim, edims).reorder())
489489

490490
if len(ispaces) > 1:
491491
# Best effort to make buffering work in the presence of multiple

docker/Dockerfile.nvidia

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ FROM ubuntu:22.04 AS sdk-base
1111

1212
SHELL ["/bin/bash", "-c"]
1313

14-
ENV DEBIAN_FRONTEND noninteractive
14+
ENV DEBIAN_FRONTEND=noninteractive
1515

1616
# Install python
1717
RUN apt-get update && \
@@ -20,20 +20,32 @@ RUN apt-get update && \
2020

2121
# nodesource: nvdashboard requires nodejs>=10
2222
RUN curl https://developer.download.nvidia.com/hpc-sdk/ubuntu/DEB-GPG-KEY-NVIDIA-HPC-SDK | gpg --yes --dearmor -o /usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg
23-
RUN echo 'deb [trusted=yes, signed-by=/usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg] https://developer.download.nvidia.com/hpc-sdk/ubuntu/amd64 /' | tee /etc/apt/sources.list.d/nvhpc.list
23+
RUN arch="$(uname -m)" && \
24+
case "$arch" in \
25+
x86_64) nvplat=amd64 ;; \
26+
aarch64|arm64) nvplat=arm64 ;; \
27+
*) echo "Unsupported architecture: $arch" >&2; exit 1 ;; \
28+
esac && \
29+
echo "deb [trusted=yes, signed-by=/usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg] https://developer.download.nvidia.com/hpc-sdk/ubuntu/${nvplat} /" | tee /etc/apt/sources.list.d/nvhpc.list
2430
RUN apt-key update *&& apt-get update -y
2531

2632
# Install nvhpc. `nvhpc` is the alias for the latest avaialble version
2733
ARG ver=nvhpc
2834
# We use the standard apt-get for the default latest nvhpc. For earlier version, apt has a bug that it will always
2935
# install the latest nvhpc-x-y no matter which version nvhpc-x-z is requested which would double (extra 10Gb) the size of the image.
3036
# So for specific version we directly download the specific deb and install it.
31-
RUN if [ "$ver" = "nvhpc" ]; then \
37+
RUN arch="$(uname -m)" && \
38+
case "$arch" in \
39+
x86_64) nvplat=amd64 ;; \
40+
aarch64|arm64) nvplat=arm64 ;; \
41+
*) echo "Unsupported architecture: $arch" >&2; exit 1 ;; \
42+
esac && \
43+
if [ "$ver" = "nvhpc" ]; then \
3244
apt-get install -y -q --allow-unauthenticated ${ver}; \
3345
else \
3446
export year=$(echo $ver | cut -d "-" -f 2) && export minor=$(echo $ver | cut -d "-" -f 3) && \
35-
wget https://developer.download.nvidia.com/hpc-sdk/ubuntu/amd64/nvhpc_${year}.${minor}_amd64.deb && \
36-
apt-get install --allow-unauthenticated -y -q ./nvhpc_${year}.${minor}_amd64.deb; \
47+
wget https://developer.download.nvidia.com/hpc-sdk/ubuntu/${nvplat}/nvhpc_${year}.${minor}_${nvplat}.deb && \
48+
apt-get install --allow-unauthenticated -y -q ./nvhpc_${year}.${minor}_${nvplat}.deb; \
3749
fi;
3850

3951
# Nodejs https://github.com/nodesource/distributions
@@ -43,12 +55,15 @@ RUN apt-get update && apt-get install -y -q \
4355
liblapack-dev libblas-dev \
4456
libibverbs-dev libmlx4-1 libmlx5-1 ibutils \
4557
# Devito Jupyter Notebooks and Ux experience
46-
nodejs ffmpeg gcc-offload-nvptx \
58+
nodejs ffmpeg \
4759
texlive-latex-extra texlive-fonts-recommended dvipng cm-super
4860

61+
# nvptx only available on x86_64
62+
RUN apt-get install -y -q gcc-offload-nvptx || echo "Skipping nvptx compiler installation on non-x86_64 architecture"
63+
4964
# nvidia-container-runtime
50-
ENV NVIDIA_VISIBLE_DEVICES all
51-
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
65+
ENV NVIDIA_VISIBLE_DEVICES=all
66+
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
5267

5368
# MPI ROOT USER DEFAULTS
5469
ENV OMPI_ALLOW_RUN_AS_ROOT=1
@@ -72,13 +87,19 @@ ENV UCX_TLS=cuda,cuda_copy,cuda_ipc,sm,shm,self
7287
#ENV UCX_TLS=cuda,cuda_copy,cuda_ipc,sm,shm,self,rc_x,gdr_copy
7388

7489
# Make simlink for path setup since ENV doesn't accept shell commands.
75-
RUN export NVARCH=$(ls -1 /opt/nvidia/hpc_sdk/Linux_x86_64/ | grep '\.' | head -n 1) && \
76-
export CUDA_V=$(ls /opt/nvidia/hpc_sdk/Linux_x86_64/${NVARCH}/cuda/ | grep '\.') && \
77-
ln -sf /opt/nvidia/hpc_sdk/Linux_x86_64/${NVARCH} /opt/nvhpc && \
78-
ln -sf /opt/nvidia/hpc_sdk/Linux_x86_64/${NVARCH}/cuda/${CUDA_V}/extras/CUPTI /opt/CUPTI && \
79-
ln -sf /opt/nvidia/hpc_sdk/Linux_x86_64/comm_libs/${CUDA_V}/nvshmem /opt/nvhpc/comm_libs/nvshmem && \
80-
ln -sf /opt/nvidia/hpc_sdk/Linux_x86_64/comm_libs/${CUDA_V}/nccl /opt/nvhpc/comm_libs/nccl && \
81-
ln -sf /opt/nvidia/hpc_sdk/Linux_x86_64/${NVARCH}/cuda/${CUDA_V}/compute-sanitizer/compute-sanitizer /opt/nvhpc/compilers/bin/compute-sanitizer
90+
RUN arch="$(uname -m)" && \
91+
case "$arch" in \
92+
x86_64) linux=Linux_x86_64 ;; \
93+
aarch64|arm64) linux=Linux_aarch64 ;; \
94+
*) echo "Unsupported architecture: $arch" >&2; exit 1 ;; \
95+
esac && \
96+
export NVARCH=$(ls -1 /opt/nvidia/hpc_sdk/${linux}/ | grep '\.' | head -n 1) && \
97+
export CUDA_V=$(ls /opt/nvidia/hpc_sdk/${linux}/${NVARCH}/cuda/ | grep '\.') && \
98+
ln -sf /opt/nvidia/hpc_sdk/${linux}/${NVARCH} /opt/nvhpc && \
99+
ln -sf /opt/nvidia/hpc_sdk/${linux}/${NVARCH}/cuda/${CUDA_V}/extras/CUPTI /opt/CUPTI && \
100+
ln -sf /opt/nvidia/hpc_sdk/${linux}/comm_libs/${CUDA_V}/nvshmem /opt/nvhpc/comm_libs/nvshmem && \
101+
ln -sf /opt/nvidia/hpc_sdk/${linux}/comm_libs/${CUDA_V}/nccl /opt/nvhpc/comm_libs/nccl && \
102+
ln -sf /opt/nvidia/hpc_sdk/${linux}/${NVARCH}/cuda/${CUDA_V}/compute-sanitizer/compute-sanitizer /opt/nvhpc/compilers/bin/compute-sanitizer
82103

83104
# Starting nvhpc 23.5 and cuda 12.1, hpcx and openmpi are inside the cuda version folder, only the bin is in the comm_libs path
84105
RUN export CUDA_V=$(/opt/nvhpc/cuda/bin/nvcc --version | sed -n 's/^.*release \([0-9]\+\.[0-9]\+\).*$/\1/p') && \
@@ -102,12 +123,12 @@ RUN echo "$HPCSDK_HOME/cuda/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
102123

103124
# Compiler, CUDA, and Library paths
104125
# CUDA_HOME has been deprecated but keep for now because of other dependencies (@mloubout).
105-
ENV CUDA_HOME $HPCSDK_HOME/cuda
106-
ENV NVHPC_CUDA_HOME $HPCSDK_HOME/cuda
107-
ENV CUDA_ROOT $HPCSDK_HOME/cuda/bin
108-
ENV PATH $HPCSDK_HOME/compilers/bin:$HPCSDK_HOME/cuda/bin:$HPCSDK_HOME/comm_libs/mpi/bin:${PATH}
109-
ENV LD_LIBRARY_PATH $HPCSDK_HOME/cuda/lib:$HPCSDK_HOME/cuda/lib64:$HPCSDK_HOME/compilers/lib:$HPCSDK_HOME/math_libs/lib64:$HPCSDK_HOME/comm_libs/mpi/lib:$HPCSDK_CUPTI/lib64:bitcomp_DIR:${LD_LIBRARY_PATH}
110-
ENV CPATH $HPCSDK_HOME/comm_libs/mpi/include:$HPCSDK_HOME/comm_libs/nvshmem/include:$HPCSDK_HOME/comm_libs/nccl/include:$HPCSDK_HOME/math_libs/include:${CPATH}
126+
ENV CUDA_HOME=$HPCSDK_HOME/cuda
127+
ENV NVHPC_CUDA_HOME=$HPCSDK_HOME/cuda
128+
ENV CUDA_ROOT=$HPCSDK_HOME/cuda/bin
129+
ENV PATH=$HPCSDK_HOME/compilers/bin:$HPCSDK_HOME/cuda/bin:$HPCSDK_HOME/comm_libs/mpi/bin:${PATH}
130+
ENV LD_LIBRARY_PATH=$HPCSDK_HOME/cuda/lib:$HPCSDK_HOME/cuda/lib64:$HPCSDK_HOME/compilers/lib:$HPCSDK_HOME/math_libs/lib64:$HPCSDK_HOME/comm_libs/mpi/lib:$HPCSDK_CUPTI/lib64:bitcomp_DIR
131+
ENV CPATH=$HPCSDK_HOME/comm_libs/mpi/include:$HPCSDK_HOME/comm_libs/nvshmem/include:$HPCSDK_HOME/comm_libs/nccl/include:$HPCSDK_HOME/math_libs/include
111132

112133
# MPI
113134
RUN rm -f $HPCSDK_HOME/comm_libs/mpi && \

0 commit comments

Comments
 (0)