-
Notifications
You must be signed in to change notification settings - Fork 229
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: Fix placement of ConditionalDimension in subdomain #2050
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2050 +/- ##
==========================================
+ Coverage 86.73% 86.75% +0.01%
==========================================
Files 233 233
Lines 43648 43707 +59
Branches 8077 8077
==========================================
+ Hits 37859 37916 +57
- Misses 5079 5080 +1
- Partials 710 711 +1 ☔ View full report in Codecov by Sentry. |
a5e6192
to
e6d6e4f
Compare
devito/ir/clusters/algorithms.py
Outdated
# If `cd` uses more dimensions than the ispace, | ||
# stay under parent | ||
if (not dims.issubset(set(c.ispace.dimensions)) and | ||
cd.parent in dims): | ||
k = cd.parent | ||
else: | ||
k = max(dims, default=d, key=lambda i: c.ispace.index(i)) |
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.
Solution 2 with False flag
# If `cd` uses, as condition, an arbitrary SymPy expression, then
# we must ensure to nest it inside the last of the Dimensions
# appearing in `cd.condition`
if cd._factor is not None:
k = d
else:
dims = pull_dims(cd.condition, flag=False)
k = max(dims, default=d, key=lambda i: c.ispace.index(i))
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.
yeah at first glance it would appear a bit convoluted
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.
Do you also consider the second solution not good enough?
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.
It's not clear why passing flag=False
would fix the issue here?
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.
Do the new tests actually fail under master?
tests/test_subdomains.py
Outdated
|
||
assert_structure(op, ['i1x'], 'i1x') | ||
|
||
def test_condition_w_subdomain_II(self): |
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.
usually we use v0, v1, v2... instead of I, II, III
condition = Lt(sdf[mid.dimensions[0]], 1) | ||
|
||
ci = ConditionalDimension(name='ci', condition=condition, | ||
parent=mid.dimensions[0]) |
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.
mid.dimensions[0] is a root dimension already, do we actually need this test?
IOW, would this test actually fail in current master?
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.
Yes, they fail in the current master with the python-land exception |
@FabioLuporini plans for this? |
@georgebisbas plan imho is to find a neater/simpler/better way |
02a8511
to
9eb007d
Compare
9eb007d
to
d36ba9b
Compare
What's the status on this? |
d36ba9b
to
6cc3a5a
Compare
@FabioLuporini requested a better solution on this. |
As per my comment above, I don't think it's an issue anymore and should work without the change |
@mloubout I cannot see any comment of yours (?) pytest tests/test_subdomains.py::TestSubDomain_w_condition I tried to run the tests and they fail |
Can we resurrect this? It fixes an issue which still exists (I accidentally replicated the fix in #2357) |
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.
This is now good to go imho
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.
Much cleaner than before, one minro comment
@@ -238,7 +238,7 @@ def guard(clusters): | |||
if cd._factor is not None: | |||
k = d | |||
else: | |||
dims = pull_dims(cd.condition) | |||
dims = pull_dims(cd.condition, flag=False) |
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.
I think this should be flag=cd.indirect
for the case where the conditional is used as the indexing dimension
|
||
assert_structure(op, ['xy'], 'xy') | ||
|
||
def test_condition_w_subdomain_v2(self): |
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.
@mloubout could you help sketching a test about what you mention as the conditional being the indexing dimension?
or at least show me an example with some pseducode?
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.
Ok sorry after bit of digging, forgot this algorithm section is only for non indirect (see line 223 in algorithms.py)
GTG
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.
ah right, this is what happens if I have long time to see a PR
|
||
assert_structure(op, ['xy'], 'xy') | ||
|
||
def test_condition_w_subdomain_v2(self): |
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.
Ok sorry after bit of digging, forgot this algorithm section is only for non indirect (see line 223 in algorithms.py)
GTG
e7fcd2d
to
ba08fa7
Compare
No description provided.