-
Notifications
You must be signed in to change notification settings - Fork 246
compiler: fix buffering with multiple conditions #2826
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -182,10 +182,10 @@ def callback(self, clusters, prefix): | |
| for _, v in descriptors.items(): | ||
| if not v.is_readonly: | ||
| continue | ||
| if c is not v.firstread: | ||
| if c not in v.firstread: | ||
| continue | ||
|
|
||
| idxf = v.last_idx | ||
| idxf = v.last_idx[c] | ||
| idxb = mds[(v.xd, idxf)] | ||
|
|
||
| lhs = v.b.indexify()._subs(v.xd, idxb) | ||
|
|
@@ -225,10 +225,10 @@ def callback(self, clusters, prefix): | |
| for _, v in descriptors.items(): | ||
| if v.is_readonly: | ||
| continue | ||
| if c is not v.lastwrite: | ||
| if c not in v.lastwrite: | ||
| continue | ||
|
|
||
| idxf = v.last_idx | ||
| idxf = v.last_idx[c] | ||
| idxb = mds[(v.xd, idxf)] | ||
|
|
||
| lhs = v.f.indexify()._subs(v.dim, idxf) | ||
|
|
@@ -508,17 +508,19 @@ def subdims_mapper(self): | |
|
|
||
| @cached_property | ||
| def firstread(self): | ||
| mapper = {} | ||
| for c in self.clusters: | ||
| if c.scope.reads.get(self.f): | ||
| return c | ||
| return None | ||
| if c.scope.reads.get(self.f) and c.guards not in mapper: | ||
| mapper[c.guards] = c | ||
| return tuple(mapper.values()) | ||
|
|
||
| @cached_property | ||
| def lastwrite(self): | ||
| mapper = {} | ||
| for c in reversed(self.clusters): | ||
| if c.scope.writes.get(self.f): | ||
| return c | ||
| return None | ||
| if c.scope.writes.get(self.f) and c.guards not in mapper: | ||
| mapper[c.guards] = c | ||
| return tuple(mapper.values()) | ||
|
|
||
| @property | ||
| def is_read(self): | ||
|
|
@@ -529,7 +531,7 @@ def is_read(self): | |
|
|
||
| @property | ||
| def is_write(self): | ||
| return self.lastwrite is not None | ||
| return bool(self.lastwrite) | ||
|
|
||
| @property | ||
| def is_readonly(self): | ||
|
|
@@ -604,8 +606,14 @@ def last_idx(self): | |
| * `time-1` in the case of `foo(u[time-1], u[time], u[time+1])` | ||
| with a backwards-propagating `time` Dimension. | ||
| """ | ||
| mapper = {} | ||
| func = vmax if self.is_forward_buffering else vmin | ||
| return func(*[Vector(i) for i in self.indices])[0] | ||
| for c in self.lastwrite + self.firstread: | ||
| indices = extract_indices(self.f, self.dim, [c]) | ||
| idx = func(*[Vector(i) for i in indices])[0] | ||
| mapper[c] = idx | ||
|
|
||
| return mapper | ||
|
Contributor
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. technically if you return a frozendict it'd be better but no big deal as long as we don't do crazy things at the caller site |
||
|
|
||
| @cached_property | ||
| def first_idx(self): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
|
|
||
| from devito.exceptions import InvalidArgument | ||
| from devito.parameters import configuration | ||
| from devito.symbolics import search | ||
| from devito.tools import as_list, as_tuple, is_integer | ||
| from devito.types.array import Array, ArrayObject | ||
| from devito.types.basic import Scalar, Symbol | ||
|
|
@@ -75,8 +76,8 @@ def _arg_defaults(self, **kwargs): | |
| raise InvalidArgument("Cannot determine `npthreads`") from None | ||
|
|
||
| # If a symbolic object, it must be resolved | ||
| if isinstance(npthreads, NPThreads): | ||
| npthreads = kwargs.get(npthreads.name, npthreads.size) | ||
| for th in search(npthreads, NPThreads): | ||
|
Contributor
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. why |
||
| npthreads = npthreads._subs(th, kwargs.get(th.name, th.size)) | ||
|
Contributor
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. why
Contributor
Author
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. Can be an expression, e.g nthreads0 + nthreads1 +.... And need to replace all
Contributor
Author
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. Can be an expression, e.g nthreads0 + nthreads1 +.... And need to replace all
Contributor
Author
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. Can be an expression, e.g nthreads0 + nthreads1 +.... And need to replace all
Contributor
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. mh, what would the reproducer be? |
||
|
|
||
| return {self.name: max(base_nthreads - npthreads, 1)} | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.