-
Notifications
You must be signed in to change notification settings - Fork 231
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 race conditions due to storage-related dependencies #1903
Changes from 3 commits
57b6ca3
9912123
7681225
0781498
f55e68a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,8 +100,6 @@ def aindices(self): | |
retval.append(dims.pop()) | ||
elif isinstance(i, Dimension): | ||
retval.append(i) | ||
elif q_constant(i): | ||
retval.append(fi) | ||
else: | ||
retval.append(None) | ||
return DimensionTuple(*retval, getters=self.findices) | ||
|
@@ -262,10 +260,14 @@ def is_regular(self): | |
# space Dimensions | ||
positions = [] | ||
for d in self.aindices: | ||
for n, i in enumerate(self.intervals): | ||
if i.dim._defines & d._defines: | ||
positions.append(n) | ||
break | ||
try: | ||
for n, i in enumerate(self.intervals): | ||
if i.dim._defines & d._defines: | ||
positions.append(n) | ||
break | ||
except AttributeError: | ||
# `d is None` due to e.g. constant access | ||
continue | ||
return positions == sorted(positions) | ||
|
||
def __lt__(self, other): | ||
|
@@ -548,6 +550,15 @@ def is_cross(self): | |
def is_local(self): | ||
return self.function.is_Symbol | ||
|
||
@memoized_meth | ||
def is_const(self, dim): | ||
""" | ||
True if a constant depedence, that is no Dimensions involved, False otherwise. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo depedence There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
""" | ||
return (self.source.aindices[dim] is None and | ||
self.sink.aindices[dim] is None and | ||
self.distance_mapper[dim] == 0) | ||
|
||
@memoized_meth | ||
def is_carried(self, dim=None): | ||
"""Return True if definitely a dimension-carried dependence, False otherwise.""" | ||
|
@@ -623,9 +634,10 @@ def is_storage_related(self, dims=None): | |
cause the access of the same memory location, False otherwise. | ||
""" | ||
for d in self.findices: | ||
if (d._defines & set(as_tuple(dims)) and | ||
any(i.is_NonlinearDerived for i in d._defines)): | ||
return True | ||
if d._defines & set(as_tuple(dims)): | ||
if any(i.is_NonlinearDerived for i in d._defines) or \ | ||
self.is_const(d): | ||
return True | ||
return False | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -603,6 +603,25 @@ def test_multi_access(): | |
assert np.all(w.data == w1.data) | ||
|
||
|
||
def test_issue_1901(): | ||
grid = Grid(shape=(2, 2)) | ||
time = grid.time_dim | ||
x, y = grid.dimensions | ||
|
||
usave = TimeFunction(name='usave', grid=grid, save=10) | ||
v = TimeFunction(name='v', grid=grid) | ||
|
||
eq = [Eq(v[time, x, y], usave)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpicking: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that's fin,e I meant having There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, I see what you mean now... |
||
|
||
op = Operator(eq, opt='buffering') | ||
|
||
trees = retrieve_iteration_tree(op) | ||
assert len(trees) == 2 | ||
assert trees[1].root.dim is time | ||
assert not trees[1].root.is_Parallel | ||
assert trees[1].root.is_Sequential # Obv | ||
|
||
|
||
def test_everything(): | ||
nt = 50 | ||
grid = Grid(shape=(6, 6)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: not for here but long run, should be gather all of these into a
CompilerOptions
class to avoid carrying all these multiple arguments everywhere.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a fair point, but I actually don't mind supplying the passes only the strict necessary rather than a big batch of things