-
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
Static Transformation properties (manifest) #154
Conversation
Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/154/index.html |
3b7f84e
to
9a9478e
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #154 +/- ##
==========================================
- Coverage 92.21% 92.18% -0.04%
==========================================
Files 93 93
Lines 16839 16881 +42
==========================================
+ Hits 15528 15561 +33
- Misses 1311 1320 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
fab5ef8
to
7e6a44d
Compare
Ok, after quite some fixing and tweaking (some workarounds needed to be shifted, rather than resolved), the test base is now green. I've also rebased over latest main. So, I think this is worth another look @reuterbal ? |
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.
Sorry for the latency, this is really great and a huge step forward towards a more formal procedure for planning and applying transformation passes. Overall no objections to any of the changes.
I left a few remarks where I think the naming could be improved, but none of that is a hard requirement. I also noticed that we don't currently cover some of the recursion control flows in the test base but this was presumably the case already before, so not necessarily required to act on this now.
My main concern would be whether we really need the "wrong" metadata provided in the transformation invocation during file graph traversals. See inline comment for details.
loki/transform/transformation.py
Outdated
# Recursion behaviour when invoking transformations via ``trafo.apply()`` | ||
recurse_to_modules = False # Recurse from Sourcefile to Module | ||
recurse_to_subroutines = False # Recurse from Sourcefile/Module to Subroutine | ||
recurse_to_contained_procedures = False # Recurse to subroutines in ``contains`` clause |
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 would propose to use this opportunity to call this recurse_to_internal_procedures
or something like this. Module procedures are also in a contains
clause inside the module, so this might be a little counter-intuitive otherwise.
loki/transform/transformation.py
Outdated
|
||
# Recursion behaviour when invoking transformations via ``trafo.apply()`` | ||
recurse_to_modules = False # Recurse from Sourcefile to Module | ||
recurse_to_subroutines = False # Recurse from Sourcefile/Module to Subroutine |
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.
Should we call this recurse_to_procedures
? I know this is inconsistent with current API but would pre-empt another API change on this end with the planned renaming.
loki/transform/transformation.py
Outdated
how the transformations are invoked for a given type of scheduler | ||
:any:`Item`. | ||
|
||
* ``reverse_traversal`` : |
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.
Sphinx supports an Attributes
block, which I think we should use here.
loki/bulk/scheduler.py
Outdated
transformation.apply( | ||
items[0].source, role=_item.role, mode=_item.mode, | ||
item=_item, items=items, targets=_item.targets, | ||
) |
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 need to return to passing items[0]
's properties to the transformations here? I removed this not too long ago because it seemed error-prone to have a single item's properties used for the entire file, and it was not actually required by any transformation.
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.
Ah, yes you are right. This was actually a workaround for a nasty bug. I found it now and reverted this (PEBKAC!).
# Forces scheduler traversal in reverse order from the leaf nodes upwards | ||
reverse_traversal = False | ||
|
||
# Traverse a graph of Sourcefile options corresponding to scheduler items | ||
traverse_file_graph = False |
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 wonder if we may encounter additional traversal requirements in the future? In which case another variant of specifying these could be to introduce an enum.Flag
which has orthogonal traversal options REVERSE_TRAVERSAL
, FILE_GRAPH_TRAVERSAL
etc. and then allows to combine them in a single traversal
attribute on Transformation
that is queried by the scheduler. Introducing an additional traversal "mode" would then only require adding the relevant flag.
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.
Yeah, in principle I agree, but I think we might want to wait with this until the SGraph is done, as it will introduce more traversal mechanisms. For the sake of it, I gave this a quick try, but it introduces yet more circular dependencies, so I think we might want to postpone for a dedicated PR?
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.
Agreed, leave as is and we can pick this up when it actually becomes relevant.
Instead of requiring the the user to correctly flag reverse traversal with the scheduler, we now set a class attribute flag that the scheduler check for reversed traversal.
Since we potentially have a one-to-many mapping here, we simply use the first `item` to provide the meta-data. This is a bit hacky, but needs full SGraph development to be fixed "properly".
7e6a44d
to
99043a0
Compare
This now resembles the more formal nomenclature of "procedures" and "internal procedures", which we are trying to adopt throughout.
8a180bc
to
906e5d4
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, happy with the current state!
This PR changes the way we configure the
Scheduler
behaviour for individualTransformation
passes. Up until now, we rely on the user of a transformation to hand any special iteration properties (reverse graph traversal, program unit recursion, etc.) as run time argument to the scheduler, with no safeguards if the wrong behaviour is requested.This PR now changes this, so that
Transformation
objects carry a set of specific flags as class properties (the manifest) that can be overridden in the class definition. So far, this change only moves scheduler traversal behaviour and behaviour specific toapply(...)
to the manifest, but it can easily be extended to capture other static meta-information, etc.In more detail:
reverse_traversal
,traverse_file_graph
anditem_filter
properties to the static class manifest. @reuterbal Please note that these are the main "graph traversal" configuration options that should eventually be implemented via the plannedSGraph
mechanisms.DependencyTransformation
, which we can hopefully simplify once that transformation is streamlined and/or we have the SGraph (@reuterbal )DependencyTransformation
andGlobalVarTransformation