Skip to content

Commit

Permalink
compiler: prevent adding breaking guard to nokey
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Jul 7, 2023
1 parent 474b10c commit 2eceda4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
13 changes: 13 additions & 0 deletions devito/ir/support/guards.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,19 @@ def andg(self, d, guard):

return Guards(m)

def xandg(self, d, guard):
m = dict(self)

if guard == true:
return Guards(m)

try:
m[d] = And(m[d], guard)
except KeyError:
pass

return Guards(m)

def impose(self, d, guard):
m = dict(self)

Expand Down
10 changes: 8 additions & 2 deletions devito/passes/clusters/buffering.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ def callback(self, clusters, prefix, cache=None):

expr = lower_exprs(Eq(lhs, rhs))
ispace = b.readfrom
guards = c.guards.andg(b.xd, GuardBound(0, b.firstidx.f))
try:
guards = c.guards.xandg(b.xd, GuardBound(0, b.firstidx.f))
except KeyError:
guards = c.guards
properties = c.properties.sequentialize(d)

processed.append(
Expand Down Expand Up @@ -262,7 +265,10 @@ def callback(self, clusters, prefix, cache=None):

expr = lower_exprs(uxreplace(Eq(lhs, rhs), b.subdims_mapper))
ispace = b.written
guards = c.guards.andg(b.xd, GuardBound(0, b.firstidx.f))
try:
guards = c.guards.xandg(b.xd, GuardBound(0, b.firstidx.f))
except KeyError:
guards = c.guards
properties = c.properties.sequentialize(d)

processed.append(
Expand Down

0 comments on commit 2eceda4

Please sign in to comment.