-
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
Transformations: Move common SCC utility routines to utilities
#354
Conversation
Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/354/index.html |
89a43b1
to
1823276
Compare
scc.util
for common utility routinesutilities
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #354 +/- ##
=======================================
Coverage 95.35% 95.36%
=======================================
Files 173 173
Lines 36835 36896 +61
=======================================
+ Hits 35124 35185 +61
Misses 1711 1711
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, this looks great and removes the indeed awkward cross-referencing to utilities in the Base class, even from outside the SCC transformations.
We should consider creating dedicated tests for these utilities at some point - not mandating this for the PR but maybe create an issue to track this?
Finally, I have paid a little more attention to the new get_local_arrays utility and noticed that we might have a case-sensitivity problem there. Would be good to resolve that (or prove me wrong) before merging.
loki/transformations/utilities.py
Outdated
Flag whether to return unique instances of each symbol; | ||
default: ``False`` | ||
""" | ||
arg_names = tuple(a.name for a in routine.arguments) |
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.
We could use routine._dummies
here as a cheaper alternative because routine.arguments
- builds
routine.symbol_map
- runs through
routine._dummies
to pick out the entries from the symbol_map in the right order
...and then we extract only the names again 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.
Yes
loki/transformations/utilities.py
Outdated
|
||
# Filter all variables by argument name to get local arrays | ||
arrays = [v for v in variables if isinstance(v, sym.Array)] | ||
arrays = [v for v in arrays if v.name not in arg_names] |
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 looks like a potential case-sensitivity issue: v.name
is a str
, therefore we don't have the benefit of the case-agnostic comparison anymore - and if argument declaration doesn't match the casing of an array use, we might run into issues 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.
Well spotted! I pushed a fix and tests for this now.
@reuterbal You are, of course, right about the testing. I've added at least rudimentary test coverage for each utility routine. As part of that I spotted an annoying inconsistency, that I also fixed: |
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, the changes look fantastic and also very much agreed on the change to the return type of get_loop_bounds! Much appreciate the additional testing!
Unless CI throws up some issues this is good to go!
Another small housekeeping change. This one adds a new sub-packagetransformations.single_column.util
sub-package for common utilities that may be used across the several SCC sub-stages.A small housekeeping change that moves utility methods from
SCCBaseTransformation
to the the commontransformations.utilities
subpackage. This primarily removes the awkward dependency on theSCCBaseTransformation
class in other SCC sub-components, which provided this previously.This change is largely cosmetic (simply copying methods over), except for the
get_local_arrays
utility, which is now used by the demotion and the annotations sub-component. This is in preparation for a more complex refactoring of the annotation sub-component to support multiple vectorisation and annotation schemes in a future PR.