-
Notifications
You must be signed in to change notification settings - Fork 12
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
Scheduler.process: apply directly to program unit corresponding to Item #137
Conversation
Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/137/index.html |
Codecov Report
@@ Coverage Diff @@
## 131-calling-a-transformation-on-a-subroutine-automatically-applies-itself-recursively-on-contained-subroutines #137 +/- ##
==================================================================================================================================================
- Coverage 92.10% 92.08% -0.03%
==================================================================================================================================================
Files 89 89
Lines 16515 16542 +27
==================================================================================================================================================
+ Hits 15211 15232 +21
- Misses 1304 1310 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
|
562c63d
to
9fd7318
Compare
… item if called via recursion
afe9431
to
03a6f97
Compare
6034412
to
0210c5b
Compare
0210c5b
to
d4c926c
Compare
Waiting for CI to confirm but I think I fixed the issue that was flagged by the ecwam regression test: The DependencyTransformation had an implicit dependency on the recursion behaviour of the Transformation class - both in terms of requiring the recursion to always start from the source file level, and trusting that recursion never actually reaches contained member procedures... I added some safe guards to the transformation that ensure existing behaviour is retained. @mlange05: Please let me know if you would like to review this as a diff to #136, or want me to merge this PR into the other and review them together? |
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, I've had a first look, and I think the final review should be on the combined PR for both. So I'm approving this now, but will take another look at the full thing.
I've already flagged a few things that strike me as odd in the dependency transform. This could very well be me not understanding some subtle detail though, so I'll need to play around with this myself a bit more.
Reading through this, I'm also not quite convinced anymore that we even need the recurse_to_contained
flag. I think the only use for this were member subroutines and the sourcefile->module->subroutine
cascade which we're trying to suprpess with this, no? For the member-routine recurision (a rare case, I guess), an explicit recurse_to_member_routines
or even a user-level recursive call to transform_subroutine
might actually be better, no?
Anyway let's merge this into #136 and see if we can whittle this down some more from there.
@@ -638,12 +652,19 @@ def process(self, transformation, reverse=False, item_filter=SubroutineItem, use | |||
# Use entry from item_map to ensure the original item is used in transformation | |||
_item = self.item_map[item.name] | |||
|
|||
# Pick out the IR node to which to apply the transformation | |||
# TODO: should this become an Item property? |
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.
[no action] Yes it should, but I think this requires the SGraph from the scheduler rewrite to be done cleanly.
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.
Indeed
is_member = isinstance(routine.parent, Subroutine) | ||
|
||
# Pick out correct item for current subroutine if processed via recursion | ||
if 'items' in kwargs: |
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 don't quite understand why this is necessary. This snippet here suggests we're updating the item
by finding the item in items
that this subroutine belongs to. I don't see why this is necessary if we only apply transform_subroutine
methods to the subroutine object associated to the given item
. Am I missing something 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.
It's due to the fact that the cleanest way of calling this transformation is via the file graph and then using the transformation's recursion to trickle down into the various nodes. However, with that the item
property isn't updated cleanly for individual program units within the source file. This leads to outdated targets
and, in a situation where driver and kernel would sit in the same module, we would assume the role of one of them for both.
35f6390
into
131-calling-a-transformation-on-a-subroutine-automatically-applies-itself-recursively-on-contained-subroutines
As requested, merged into #136 for further review. |
This is part 2 to #136 (and filed against that PR branch to allow consolidating the fix if acceptable).
The extended fix in this PR is more invasive than the minimum workaround implemented in #136 by applying transformations directly to the program unit corresponding to an item instead of relying on recursion to eventually end up at the right object. This also removes the need for the check of
item.name == routine.name
before applying transformations, because now we do actually apply transformations only directly to the subroutines that are meant to be transformed.This highlighted also a flaw in the current scheduler design which effectively preempts processing contained member routines entirely, because we can't represent contained member routines as scheduler graph nodes (the discovery mechanism is unable to find member routines), and the above mentioned name check preempts recursion into the member routine. The implementation in this PR partially resolves this by getting rid of the name check. Proper representation of contained member routines requires more changes, though, and I will create a separate issue for that.
As this change is more invasive in the scheduler, it may have unintended side-effects and therefore this fix is optional.