Skip to content
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

Merged
merged 3 commits into from
Apr 30, 2024

Conversation

georgebisbas
Copy link
Contributor

No description provided.

@georgebisbas georgebisbas self-assigned this Jan 23, 2023
@georgebisbas georgebisbas changed the title [RFC] compiler: Fix issue 2049 [RFC] compiler: Fix placement of ConditionalDimension in subdomain Jan 23, 2023
@codecov
Copy link

codecov bot commented Jan 23, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.75%. Comparing base (cafebc1) to head (c35a0c1).

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.
📢 Have feedback on the report? Share it here.

Comment on lines 209 to 220
# 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))
Copy link
Contributor Author

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))

Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor

@FabioLuporini FabioLuporini left a 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?


assert_structure(op, ['i1x'], 'i1x')

def test_condition_w_subdomain_II(self):
Copy link
Contributor

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])
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@georgebisbas
Copy link
Contributor Author

Do the new tests actually fail under master?

Yes, they fail in the current master with the python-land exception
(I guess the same you think of here: https://devitocodes.slack.com/archives/C7JMLMSG0/p1674301184495359?thread_ts=1674231704.845469&cid=C7JMLMSG0)

@georgebisbas georgebisbas changed the title [RFC] compiler: Fix placement of ConditionalDimension in subdomain compiler: Fix placement of ConditionalDimension in subdomain Mar 17, 2023
@georgebisbas
Copy link
Contributor Author

@FabioLuporini plans for this?

@FabioLuporini
Copy link
Contributor

@georgebisbas plan imho is to find a neater/simpler/better way

@georgebisbas georgebisbas force-pushed the cond_subd branch 2 times, most recently from 02a8511 to 9eb007d Compare May 17, 2023 15:29
@mloubout
Copy link
Contributor

What's the status on this?

@georgebisbas
Copy link
Contributor Author

@FabioLuporini requested a better solution on this.
Any ides?

@mloubout
Copy link
Contributor

As per my comment above, I don't think it's an issue anymore and should work without the change

@georgebisbas
Copy link
Contributor Author

@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

@EdCaunt
Copy link
Contributor

EdCaunt commented Apr 17, 2024

Can we resurrect this? It fixes an issue which still exists (I accidentally replicated the fix in #2357)

Copy link
Contributor

@FabioLuporini FabioLuporini left a 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

Copy link
Contributor

@mloubout mloubout left a 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

@georgebisbas georgebisbas linked an issue Apr 19, 2024 that may be closed by this pull request
@@ -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)
Copy link
Contributor

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):
Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor Author

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):
Copy link
Contributor

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

@georgebisbas georgebisbas force-pushed the cond_subd branch 2 times, most recently from e7fcd2d to ba08fa7 Compare April 25, 2024 16:40
@mloubout mloubout merged commit daf782e into master Apr 30, 2024
31 checks passed
@mloubout mloubout deleted the cond_subd branch April 30, 2024 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Combination of Subdomain and ConditionalDimension
4 participants