Skip to content

Commit 013b2dc

Browse files
authored
Merge pull request #2838 from devitocodes/multi-cond-buffering
compiler: add rudimentary support for multi-cond buffering
2 parents 1c65e48 + 8304fdb commit 013b2dc

9 files changed

Lines changed: 387 additions & 42 deletions

File tree

.github/workflows/docker-bases.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
############## Basic gcc CPU ##########################
4141
#######################################################
4242
deploy-cpu-bases:
43-
if: inputs.cpu
43+
if: ${{ github.event_name != 'workflow_dispatch' || inputs.cpu }}
4444
name: "cpu-base-${{ matrix.arch }}-gcc${{ matrix.gcc }}"
4545
runs-on: ${{ matrix.runner }}
4646
env:
@@ -88,7 +88,7 @@ jobs:
8888
tags: "devitocodes/bases:cpu-gcc${{ matrix.gcc }}-${{ matrix.arch }}"
8989

9090
deploy-cpu-bases-manifest:
91-
if: inputs.cpu
91+
if: ${{ github.event_name != 'workflow_dispatch' || inputs.cpu }}
9292
name: "cpu-base-manifest"
9393
runs-on: ubuntu-latest
9494
needs: deploy-cpu-bases
@@ -123,7 +123,7 @@ jobs:
123123
############## Intel OneApi CPU #######################
124124
#######################################################
125125
deploy-oneapi-bases:
126-
if: inputs.intel
126+
if: ${{ github.event_name != 'workflow_dispatch' || inputs.intel }}
127127
name: "oneapi-base"
128128
runs-on: ubuntu-latest
129129
env:
@@ -181,7 +181,7 @@ jobs:
181181
################### Nvidia nvhpc ######################
182182
#######################################################
183183
deploy-nvidia-bases:
184-
if: inputs.nvidia
184+
if: ${{ github.event_name != 'workflow_dispatch' || inputs.nvidia }}
185185
name: "nvidia-bases-${{ matrix.arch }}"
186186
runs-on: ${{ matrix.runner }}
187187
env:
@@ -270,7 +270,7 @@ jobs:
270270
tags: "devitocodes/bases:cpu-nvc${{ matrix.extra_tag }}-${{ matrix.arch }}"
271271

272272
deploy-nvidia-bases-manifest:
273-
if: inputs.nvidia
273+
if: ${{ github.event_name != 'workflow_dispatch' || inputs.nvidia }}
274274
name: "nvidia-base-manifest"
275275
runs-on: ubuntu-latest
276276
needs: deploy-nvidia-bases
@@ -305,7 +305,7 @@ jobs:
305305
##################### AMD #############################
306306
#######################################################
307307
deploy-amd-bases:
308-
if: inputs.amd
308+
if: ${{ github.event_name != 'workflow_dispatch' || inputs.amd }}
309309
name: "amd-base"
310310
runs-on: ["self-hosted", "amdgpu"]
311311
env:

devito/ir/clusters/algorithms.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ def guard(clusters):
254254

255255
# Chain together all `cds` conditions from all expressions in `c`
256256
guards = {}
257+
mode = sympy.Or
257258
for cd in cds:
258259
# `BOTTOM` parent implies a guard that lives outside of
259260
# any iteration space, which corresponds to the placeholder None
@@ -270,6 +271,7 @@ def guard(clusters):
270271

271272
# Pull `cd` from any expr
272273
condition = guards.setdefault(k, [])
274+
mode = mode and cd.relation
273275
for e in exprs:
274276
try:
275277
condition.append(e.conditionals[cd])
@@ -284,7 +286,9 @@ def guard(clusters):
284286
conditionals.pop(cd, None)
285287
exprs[i] = e.func(*e.args, conditionals=conditionals)
286288

287-
guards = {d: sympy.And(*v, evaluate=False) for d, v in guards.items()}
289+
# Combination `mode` is And by default.
290+
# If all conditions are Or then Or combination `mode` is used.
291+
guards = {d: mode(*v, evaluate=False) for d, v in guards.items()}
288292

289293
# Construct a guarded Cluster
290294
processed.append(c.rebuild(exprs=exprs, guards=guards))

devito/ir/equations/equation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def __new__(cls, *args, **kwargs):
223223
else:
224224
cond = diff2sympy(lower_exprs(d.condition))
225225
if d._factor is not None:
226-
cond = sympy.And(cond, GuardFactor(d))
226+
cond = d.relation(cond, GuardFactor(d))
227227
conditionals[d] = cond
228228
# Replace dimension with index
229229
index = d.index

devito/types/dimension.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,11 @@ class ConditionalDimension(DerivedDimension):
860860
If True, use `self`, rather than the parent Dimension, to
861861
index into arrays. A typical use case is when arrays are accessed
862862
indirectly via the ``condition`` expression.
863+
relation: Or/And, default=And
864+
How this ConditionalDimension will be combined with other ones during
865+
lowering for example combining Function's ConditionalDimension with
866+
an Equation's implicit_dim. All Dimensions within an equation
867+
must have `Or` relation for the final combined condition to be Or.
863868
864869
Examples
865870
--------
@@ -913,10 +918,10 @@ class ConditionalDimension(DerivedDimension):
913918
is_Conditional = True
914919

915920
__rkwargs__ = DerivedDimension.__rkwargs__ + \
916-
('factor', 'condition', 'indirect')
921+
('factor', 'condition', 'indirect', 'relation')
917922

918923
def __init_finalize__(self, name, parent=None, factor=None, condition=None,
919-
indirect=False, **kwargs):
924+
indirect=False, relation=sympy.And, **kwargs):
920925
# `parent=None` degenerates to a ConditionalDimension outside of
921926
# any iteration space
922927
if parent is None:
@@ -937,6 +942,7 @@ def __init_finalize__(self, name, parent=None, factor=None, condition=None,
937942

938943
self._condition = condition
939944
self._indirect = indirect
945+
self._relation = relation
940946

941947
@property
942948
def uses_symbolic_factor(self):
@@ -978,6 +984,10 @@ def condition(self):
978984
def indirect(self):
979985
return self._indirect
980986

987+
@property
988+
def relation(self):
989+
return self._relation
990+
981991
@cached_property
982992
def free_symbols(self):
983993
retval = set(super().free_symbols)

docker/Dockerfile.intel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ FROM base AS oneapi
2626

2727
# Download the key to system keyring
2828
# https://www.intel.com/content/www/us/en/develop/documentation/installation-guide-for-intel-oneapi-toolkits-linux/top/installation/install-using-package-managers/apt.html#apt
29-
SHELL /bin/bash -o pipefail
29+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
3030
RUN wget --progress=dot:giga -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor > /usr/share/keyrings/oneapi-archive-keyring.gpg
3131
RUN echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" > /etc/apt/sources.list.d/oneAPI.list
3232

@@ -37,7 +37,7 @@ RUN apt-get update -y && \
3737

3838
# Drivers mandatory for intel gpu
3939
# https://dgpu-docs.intel.com/driver/installation.html#ubuntu-install-steps
40-
SHELL /bin/bash -o pipefail
40+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
4141
RUN wget -qO - https://repositories.intel.com/graphics/intel-graphics.key | gpg --dearmor > /usr/share/keyrings/intel-graphics.gpg
4242
RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/graphics/ubuntu jammy unified" > /etc/apt/sources.list.d/intel-gpu-jammy.list
4343

docker/Dockerfile.nvidia

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ RUN apt-get update && \
1919
dh-autoreconf python3-venv python3-dev python3-pip
2020

2121
# nodesource: nvdashboard requires nodejs>=10
22-
SHELL /bin/bash -o pipefail
22+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
2323
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
2424
RUN arch="$(uname -m)" && \
2525
case "$arch" in \
@@ -92,7 +92,7 @@ ENV UCX_TLS=cuda,cuda_copy,cuda_ipc,sm,shm,self
9292
#ENV UCX_TLS=cuda,cuda_copy,cuda_ipc,sm,shm,self,rc_x,gdr_copy
9393

9494
# Make simlink for path setup since ENV doesn't accept shell commands.
95-
SHELL /bin/bash -o pipefail
95+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
9696
RUN arch="$(uname -m)" && \
9797
case "$arch" in \
9898
x86_64) linux=Linux_x86_64 ;; \

examples/seismic/tutorials/02_rtm.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
" return demo_model('marmousi2d-isotropic', data_path='../../../../data/',\n",
8888
" grid=grid, nbl=20)\n",
8989
" filter_sigma = (6, 6)\n",
90-
" nshots = 301 # Need good covergae in shots, one every two grid points\n",
90+
" nshots = 301 # Need good coverage in shots, one every two grid points\n",
9191
" nreceivers = 601 # One receiver every grid point\n",
9292
" t0 = 0.\n",
9393
" tn = 3500. # Simulation last 3.5 second (3500 ms)\n",

0 commit comments

Comments
 (0)