Skip to content

Commit

Permalink
compiler: fix dimension sort determinism
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Sep 5, 2023
1 parent 92a60b8 commit 6014418
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion devito/ir/equations/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def handle_indexed(indexed):
# 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
for i in relations:
dims = [di for d in i for di in (d.index, d)]
dims = [di for d in i for di in (d.root, d)]
implicit_relations.update({tuple(filter_ordered(dims))})

ordering = PartialOrderTuple(extra, relations=(relations | implicit_relations))
Expand Down
11 changes: 7 additions & 4 deletions devito/operations/interpolators.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,22 +176,25 @@ def _interp_idx(self, variables, implicit_dims=None):
"""
mapper = {}
pos = self.sfunction._position_map.values()
# Temporaries for the position
temps = self._positions(implicit_dims)

# Coefficient symbol expression
temps.extend(self._coeff_temps(implicit_dims))
for ((di, d), rd, p) in zip(enumerate(self._gdims), self._rdim, pos):
# Add conditional to avoid OOB
lb = sympy.And(rd + p >= d.symbolic_min - self.r, evaluate=False)
ub = sympy.And(rd + p <= d.symbolic_max + self.r, evaluate=False)
cond = sympy.And(lb, ub, evaluate=False)
mapper[d] = ConditionalDimension(rd.name, rd, condition=cond, indirect=True)

# Temporaries for the position
temps = self._positions(implicit_dims)

# Coefficient symbol expression
temps.extend(self._coeff_temps(implicit_dims))

# Substitution mapper for variables
idx_subs = {v: v.subs({k: c - v.origin.get(k, 0) + p
for ((k, c), p) in zip(mapper.items(), pos)})
for v in variables}
idx_subs.update(dict(zip(self._rdim, mapper.values())))

return idx_subs, temps

Expand Down

0 comments on commit 6014418

Please sign in to comment.