-
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
Add transformation generated imports to driver or after inlining #321
Conversation
Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/321/index.html |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #321 +/- ##
=======================================
Coverage 95.15% 95.16%
=======================================
Files 168 168
Lines 35454 35503 +49
=======================================
+ Hits 33737 33786 +49
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. |
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, looks great! Some small implementation pointers but otherwise all good.
item.trafo_data[self._key]["imported_sizes"] = [(d.type.module, d) for d in dims | ||
if str(d) in routine.import_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.
This rebuilds the import_map in every iteration. Better to cache it before the list comprehension.
item.trafo_data[self._key]["imported_sizes"] = [(d.type.module, d) for d in dims | |
if str(d) in routine.import_map] | |
import_map = routine.import_map | |
item.trafo_data[self._key]["imported_sizes"] = [(d.type.module, d) for d in dims | |
if d.name in import_map] |
# Add imports used to define hoisted | ||
missing_imports_map = defaultdict(set) | ||
for module, var in item.trafo_data[self._key]["imported_sizes"]: | ||
if not var.name in routine.import_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.
Same comment as above about caching import_map
loki/transformations/inline.py
Outdated
Resolve sequence association in calls to all member procedures (if `inline_internals = True`) | ||
or in calls to procedures that have been marked with an inline pragma (if `inline_marked = True`). |
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.
Resolve sequence association in calls to all member procedures (if `inline_internals = True`) | |
or in calls to procedures that have been marked with an inline pragma (if `inline_marked = True`). | |
Resolve sequence association in calls to all member procedures (if ``inline_internals = True``) | |
or in calls to procedures that have been marked with an inline pragma (if ``inline_marked = True``). |
RST syntax...
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.
Oops, not sure how that ended up here, thanks for spotting!
loki/transformations/inline.py
Outdated
for b in intf.body: | ||
s = getattr(b, 'procedure_symbol', 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.
Can we not use intf.symbols
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.
Interface.body
comprises of Subroutine
objects and not just the symbols, so I did it like this to capture the whole Subroutine
object. If using intf.symbols
, I would have to add symbol.type.dtype.procedure
to the body rather than the symbol. Either is fine by me, please let me know if you would like me to update to the latter.
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, I'm aware - but you're only inspecting the procedure symbols of these subroutines not the objects themselves, which is what intf.symbols
should give you. Have a look at the implementation of Interface.symbols
, which should be essentially the same as what you do here, but also includes the case of named interfaces etc:
Lines 700 to 710 in 77114a9
def symbols(self): | |
""" | |
The list of symbol names declared by this interface | |
""" | |
symbols = as_tuple(flatten( | |
getattr(node, 'procedure_symbol', getattr(node, 'symbols', ())) | |
for node in self.body # pylint: disable=not-an-iterable | |
)) | |
if self.spec: | |
return (self.spec,) + symbols | |
return symbols |
Many thanks @reuterbal for the super prompt review and feedback 🙏 I've addressed all your comments, please have another look whenever you can! |
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 for the quick implementation of changes! Looks good to me
611c17c
to
0b99f61
Compare
Apologies, this has accrued conflicts now - @awnawab, would you mind rebasing this over main? |
0b99f61
to
78d9f45
Compare
This PR provides the following fixes:
TemporariesPoolAllocator
transformation now adds global variable imports to the driver for variables used to define array sizes.HoistArraysTransformation
adds imports used to define the sizes of hoisted variables.InlineTransformation
is fixed.InlineTransformation
now also adds any explicit interfaces from inlined children.