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: Patch cluster.is_sparse #2232

Merged
merged 1 commit into from
Oct 12, 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
13 changes: 3 additions & 10 deletions devito/ir/clusters/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,10 @@ def is_dense(self):
@cached_property
def is_sparse(self):
"""
A cluster is sparse if it represent a sparse operation i.e if both

* The cluster contains sparse functions
* The cluster uses dense functions

If only the first case is true, the cluster only contains operation on the sparse
function itself without indirection and therefore only contains dense operations.
A Cluster is sparse if it represents a sparse operation, i.e iff
There's at least one irregular access.
"""
return (any(f.is_SparseFunction for f in self.functions) and
len([f for f in self.functions
if (f.is_Function and not f.is_SparseFunction)]) > 0)
return any(a.is_irregular for a in self.scope.accesses)

@property
def is_halo_touch(self):
Expand Down
18 changes: 18 additions & 0 deletions tests/test_lower_clusters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from devito import Grid, SparseTimeFunction, TimeFunction, Operator
from devito.ir.iet import FindSymbols


class TestLowerReductions(object):

def test_no_temp_upon_reduce_expansion(self):
grid = Grid(shape=(10, 10, 10))

u = TimeFunction(name='u', grid=grid)
sf = SparseTimeFunction(name='sf', grid=grid, npoint=1, nt=5)

rec_term = sf.interpolate(expr=u)

op = Operator(rec_term, opt=('advanced', {'mapify-reduce': True}))

arrays = [i for i in FindSymbols().visit(op) if i.is_Array]
assert len([i for i in arrays if i.ndim == grid.dim]) == 0
Loading