-
Notifications
You must be signed in to change notification settings - Fork 13
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
HoistVariablesAnalysis
: remove unused explicit interfaces after inlining
#319
Conversation
Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/319/index.html |
067b768
to
a66737f
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #319 +/- ##
==========================================
+ Coverage 95.15% 95.16% +0.01%
==========================================
Files 168 168
Lines 35454 35538 +84
==========================================
+ Hits 33737 33821 +84
Misses 1717 1717
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Hi. Can I push a small update here? |
a66737f
to
be5a4f9
Compare
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.
Thanks, this looks really great! Three small comments/questions regarding implementation details but nothing too important really.
@@ -152,6 +152,11 @@ def transform_subroutine(self, routine, **kwargs): | |||
for child in successors: | |||
if not isinstance(child, ProcedureItem): | |||
continue | |||
|
|||
# skip successors that might have been inlined | |||
if not call_map.get(child.local_name, None): |
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.
Shouldn't that simply be
if not call_map.get(child.local_name, None): | |
if child.local_name not in call_map: |
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.
As discussed offline, this can be dropped now because InlineTransformation.creates_items = True
if inline_marked = True
.
loki/transformations/inline.py
Outdated
@@ -606,6 +606,18 @@ def inline_marked_subroutines(routine, allowed_aliases=None, adjust_imports=True | |||
# Remove import if no further symbols used, otherwise clone with new symbols | |||
import_map[impt] = impt.clone(symbols=new_symbols) if new_symbols else None | |||
|
|||
# Remove explicit interfaces of inlined routines | |||
for intf in FindNodes(Interface).visit(routine.ir): |
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 we really need to go over routine.ir
here? Or couldn't we simply use
for intf in FindNodes(Interface).visit(routine.ir): | |
for intf in routine.interfaces: |
loki/transformations/inline.py
Outdated
_body = [] | ||
for s in intf.symbols: | ||
if s.name not in callees or s.name in not_inlined: | ||
_body += [s.type.dtype.procedure,] |
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 could be done with a list comprehension:
_body = [] | |
for s in intf.symbols: | |
if s.name not in callees or s.name in not_inlined: | |
_body += [s.type.dtype.procedure,] | |
_body = tuple( | |
s.type.dtype.procedure for s in intf.symbols | |
if s.name not in callees or s.name in not_inlined | |
) |
Also allows to directly build a tuple, avoiding the as_tuple
further down.
410e3c5
to
714075a
Compare
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.
Many thanks, all good for me now!
HoistVariablesAnalysis
and remove unused explicit interfaces after inliningHoistVariablesAnalysis
: remove unused explicit interfaces after inlining
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.
Very nice! Clean and well tested, GTG from me.
This small PR implements two bug fixes:
HoistVariablesAnalysis
now skips successors that might no longer be present (e.g. they were inlined)