Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: Revamp interpolation/injection #2128

Merged
merged 47 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
25ddf55
api: Revamp PrecomputedSparseFunction
FabioLuporini May 15, 2023
d572cfe
api: Add coordinates to PrecomputedSparseFunction
FabioLuporini May 15, 2023
1381a68
api: Fix pickling for PrecomputedSparseFunction
FabioLuporini May 15, 2023
c7b9c22
types: setup_coordinates for all sparse functions
mloubout May 15, 2023
cf4ab51
api: Rework AbstractSparseFunction.__subfunc_setup__
FabioLuporini May 16, 2023
60f0fdc
types: add MPI support to PrecomputedSparseFunction
mloubout May 17, 2023
ca5b20f
mpi: rewrok interpolation to work with precomputed and mpi
mloubout May 18, 2023
f66806e
api: precomputed sparse function temps
mloubout May 18, 2023
3f096e8
tests: update test according to new sparse setup
mloubout May 19, 2023
28546b2
operator: explicit alias of arg_apply
mloubout May 19, 2023
5a0b682
api: enforce gridpoints as subfunc for precomputed
mloubout May 19, 2023
be1625d
api: revamp interpolator for better generalization
mloubout May 22, 2023
a80a069
api: cleanup hierachy and properties of sparse and interpolator
mloubout May 23, 2023
2e749f7
tests: add test for precomputed time injection that was missing (and …
mloubout May 23, 2023
424a548
api: switch interp to r dim
mloubout Jun 2, 2023
30ad100
operations: remove unused points and cleanup weights
mloubout Jun 5, 2023
f7e9556
compiler: fix dimension_sort to avoid missing indirect conditionals
mloubout Jun 8, 2023
845db23
compiler: fix dtype of aliases
mloubout Jun 9, 2023
48ab7dd
api: Revamp PrecomputedSparseFunction
FabioLuporini May 15, 2023
1ea1bac
api: Fix pickling for PrecomputedSparseFunction
FabioLuporini May 15, 2023
065222b
types: setup_coordinates for all sparse functions
mloubout May 15, 2023
c5f9541
api: Rework AbstractSparseFunction.__subfunc_setup__
FabioLuporini May 16, 2023
d495e27
sparse: add MPI support to PrecomputedSparseFunction
mloubout May 17, 2023
da695e1
mpi: rewrok interpolation to work with precomputed and mpi
mloubout May 18, 2023
45875d8
api: precomputed sparse function temps
mloubout May 18, 2023
f27de45
operator: explicit alias of arg_apply
mloubout May 19, 2023
1811ab9
api: enforce gridpoints as subfunc for precomputed
mloubout May 19, 2023
854df6c
api: revamp interpolator for better generalization
mloubout May 22, 2023
d77f6d1
api: cleanup hierachy and properties of sparse and interpolator
mloubout May 23, 2023
6696b91
tests: add test for precomputed time injection that was missing (and …
mloubout May 23, 2023
f168f30
api: switch interp to r dim
mloubout Jun 2, 2023
073bbc8
operations: remove unused points and cleanup weights
mloubout Jun 5, 2023
840e432
compiler: fix dimension_sort to avoid missing indirect conditionals
mloubout Jun 8, 2023
9b7fc38
compiler: fix dtype of aliases
mloubout Jun 9, 2023
71794b3
api: rework interpolator to avoid un-necessary temps
mloubout Jun 12, 2023
6b7fcca
api: allow to inject into multiple fields at once
mloubout Jun 15, 2023
9406262
CI: add missing test in examples.yml
mloubout Jun 15, 2023
c60318d
api: cleanup interpolator api
mloubout Jun 21, 2023
351b4c3
compiler: prevent inner custom dimension to be parallel to avoid devi…
mloubout Jun 27, 2023
b51c488
CI: add test for and fixes #920
mloubout Jun 29, 2023
f2fc9b1
mpi: drop halospots with empty iters
mloubout Jun 30, 2023
84335d6
CI: add large radius precomputed interp test
mloubout Jul 3, 2023
0abe77b
api: cleanup based on first review
mloubout Jul 24, 2023
1aa35df
api: move interp coefficient inside most inner loop
mloubout Jul 28, 2023
d7d2040
ci: new flake8 version fix
mloubout Jul 31, 2023
92a60b8
dsl: tweak reconstruction of sparse functions
mloubout Aug 25, 2023
4d9abed
compiler: fix dimension sort determinism
mloubout Sep 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/examples-mpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
run: |
pip install --upgrade pip
pip install -e .[extras,mpi,tests]
python3 scripts/clear_devito_cache.py

- name: Test mpi notebooks
continue-on-error: true
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ jobs:
pip install -e .[tests,extras]

- name: Tests in examples
run: py.test --cov --cov-config=.coveragerc --cov-report=xml examples/
run: |
py.test --cov --cov-config=.coveragerc --cov-report=xml examples/
georgebisbas marked this conversation as resolved.
Show resolved Hide resolved

- name: Seismic acoustic examples
run: |
Expand Down
35 changes: 23 additions & 12 deletions devito/ir/equations/algorithms.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from collections.abc import Iterable
from operator import attrgetter

from sympy import sympify

from devito.symbolics import retrieve_indexed, uxreplace
from devito.tools import PartialOrderTuple, as_tuple, filter_sorted, flatten
from devito.symbolics import retrieve_indexed, uxreplace, retrieve_dimensions
from devito.tools import (PartialOrderTuple, as_tuple, flatten,
filter_sorted, filter_ordered)
from devito.types import Dimension, IgnoreDimSort
from devito.types.basic import AbstractFunction

Expand Down Expand Up @@ -33,8 +33,7 @@ def handle_indexed(indexed):

# Fallback: Just insert all the Dimensions we find, regardless of
# what the user is attempting to do
relation.extend([d for d in filter_sorted(i.free_symbols)
if isinstance(d, Dimension)])
relation.extend(filter_sorted(i.atoms(Dimension)))

# StencilDimensions are lowered subsequently through special compiler
# passes, so they can be ignored here
Expand All @@ -51,30 +50,42 @@ def handle_indexed(indexed):
relations.add(expr.implicit_dims)

# Add in leftover free dimensions (not an Indexed' index)
extra = set([i for i in expr.free_symbols if isinstance(i, Dimension)])
extra = set(retrieve_dimensions(expr, deep=True))

# Add in pure data dimensions (e.g., those accessed only via explicit values,
# such as A[3])
indexeds = retrieve_indexed(expr, deep=True)
extra.update(set().union(*[set(i.function.dimensions) for i in indexeds]))
for i in indexeds:
extra.update({d for d in i.function.dimensions if i.indices[d].is_integer})

# Enforce determinism
extra = filter_sorted(extra, key=attrgetter('name'))
extra = filter_sorted(extra)

# Add in implicit relations for parent dimensions
# -----------------------------------------------
# 1) Note that (d.parent, d) is what we want, while (d, d.parent) would be
# wrong; for example, in `((t, time), (t, x, y), (x, y))`, `x` could now
# preceed `time`, while `t`, and therefore `time`, *must* appear before `x`,
# as indicated by the second relation
implicit_relations = {(d.parent, d) for d in extra if d.is_Derived}
implicit_relations = {(d.parent, d) for d in extra if d.is_Derived and not d.indirect}
FabioLuporini marked this conversation as resolved.
Show resolved Hide resolved

# 2) To handle cases such as `((time, xi), (x,))`, where `xi` a SubDimension
# of `x`, besides `(x, xi)`, we also have to add `(time, x)` so that we
# obtain the desired ordering `(time, x, xi)`. W/o `(time, x)`, the ordering
# `(x, time, xi)` might be returned instead, which would be non-sense
implicit_relations.update({tuple(d.root for d in i) for i in relations})

ordering = PartialOrderTuple(extra, relations=(relations | implicit_relations))
for i in relations:
dims = []
for d in i:
# Only add index if a different Dimension name to avoid dropping conditionals
# with the same name as the parent
if d.index.name == d.name:
dims.append(d)
else:
dims.extend([d.index, d])

implicit_relations.update({tuple(filter_ordered(dims))})

ordering = PartialOrderTuple(extra, relations=implicit_relations)

return ordering

Expand Down
8 changes: 4 additions & 4 deletions devito/ir/support/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def index_mode(self):
def aindices(self):
retval = []
for i, fi in zip(self, self.findices):
dims = {j for j in i.free_symbols if isinstance(j, Dimension)}
dims = set(d.root if d.indirect else d for d in i.atoms(Dimension))
sdims = {d for d in dims if d.is_Stencil}
candidates = dims - sdims

Expand Down Expand Up @@ -660,9 +660,9 @@ def is_const(self, dim):
"""
True if a constant dependence, that is no Dimensions involved, False otherwise.
"""
return (self.source.aindices[dim] is None and
self.sink.aindices[dim] is None and
self.distance_mapper[dim] == 0)
return (self.source.aindices.get(dim) is None and
self.sink.aindices.get(dim) is None and
self.distance_mapper.get(dim, 0) == 0)

@memoized_meth
def is_carried(self, dim=None):
Expand Down
1 change: 1 addition & 0 deletions devito/ir/support/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def detect_accesses(exprs):
for e in as_tuple(exprs):
other_dims.update(i for i in e.free_symbols if isinstance(i, Dimension))
other_dims.update(e.implicit_dims)
other_dims = filter_sorted(other_dims)
mapper[None] = Stencil([(i, 0) for i in other_dims])

return mapper
Expand Down
Loading
Loading