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

compiler: prevent radius dependent temps for sparse operations #2216

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion devito/ir/clusters/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def normalize_reductions(cluster, sregistry, options):

processed = []
for e in cluster.exprs:
if e.is_Reduction and e.lhs.is_Indexed and cluster.is_sparse:
if e.is_Reduction and (e.lhs.is_Indexed or cluster.is_sparse):
# Transform `e` such that we reduce into a scalar (ultimately via
# atomic ops, though this part is carried out by a much later pass)
# For example, given `i = m[p_src]` (i.e., indirection array), turn:
Expand Down
14 changes: 13 additions & 1 deletion tests/test_dse.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
IndexedPointer, Keyword, SizeOf, estimate_cost,
pow_to_mul, indexify)
from devito.tools import as_tuple, generator
from devito.types import Array, Scalar, Symbol
from devito.types import Array, Scalar, Symbol, PrecomputedSparseTimeFunction

from examples.seismic.acoustic import AcousticWaveSolver
from examples.seismic import demo_model, AcquisitionGeometry
Expand Down Expand Up @@ -2664,6 +2664,18 @@ def test_dtype_aliases(self):
assert FindNodes(Expression).visit(op)[0].dtype == np.float32
assert np.all(fo.data[:-1, :-1] == 8)

def test_sparse_const(self):
grid = Grid((11, 11, 11))

u = TimeFunction(name="u", grid=grid)
src = PrecomputedSparseTimeFunction(name="src", grid=grid, npoint=1, nt=11,
r=2, interpolation_coeffs=np.ones((1, 3, 2)))
op = Operator(src.interpolate(u))

cond = FindNodes(Conditional).visit(op)
assert len(cond) == 1
assert all(e.is_scalar for e in cond[0].args['then_body'][0].exprs)


class TestIsoAcoustic(object):

Expand Down
Loading