PromoteLocalArrayTransformation - Add new transformation for promotion of local arrays#682
PromoteLocalArrayTransformation - Add new transformation for promotion of local arrays#682wertysas wants to merge 16 commits into
Conversation
|
Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/682/index.html |
6d8894f to
b3a0f9d
Compare
|
I have disabled the tests that are not compatible with OMNI. However, the tests does not seem to trigger for this PR anymore, after I force pushed the branch 5 days ago, and when I tried to manually re-run the failing test the actions was using the old cached checkout instead of the new updated tests. |
…ecls on the same line
617e644 to
5af87c7
Compare
|
Another rebase did not revive the tests but an additional commit on top seems to finally have done the trick... 🤷 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #682 +/- ##
==========================================
+ Coverage 94.19% 94.24% +0.04%
==========================================
Files 288 289 +1
Lines 47496 47965 +469
==========================================
+ Hits 44741 45203 +462
- Misses 2755 2762 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
reuterbal
left a comment
There was a problem hiding this comment.
Many thanks, this looks very good but I have a few remarks how to improve the implementation - see the inline comments. In addition, there's a few things that need to be added to the tests. I've marked two inline, additionally a test that specifies preserve_arrays (ideally using non-matching upper/lower case) would be ideal.
| if preserve_arrays: | ||
| to_promote = [v for v in to_promote if v.name not in preserve_arrays] |
There was a problem hiding this comment.
I think we need to be careful about ignoring case here:
| if preserve_arrays: | |
| to_promote = [v for v in to_promote if v.name not in preserve_arrays] | |
| if preserve_arrays: | |
| preserve_arrays = {arr.lower() for arr in preserve_arrays} | |
| to_promote = [v for v in to_promote if v.name.lower() not in preserve_arrays] |
| assert kernel.variable_map['tmp'].shape[1] == 'start:end' | ||
|
|
||
| assigns = FindNodes(Assignment).visit(kernel.body) | ||
| assert 'tmp(nz, start:end)' in fgen(kernel.spec).lower() |
There was a problem hiding this comment.
I'm pretty sure this ought to become tmp(start:end, nz) to be useful
|
I'll do a full review later today/tomorrow, but for now I can confirm that enabling |
Great, thank you! |
| _upper = routine.variable_map.get(u, None) | ||
| if _lower and _upper: | ||
| if lower or upper: | ||
| warning( |
There was a problem hiding this comment.
Do we really need this warning? Wouldn't it be enough to just take the first lower and upper bound present in the current symbol table? And throw an error if none of them are present?
| symbol_map = routine.symbol_map | ||
| sizes = tuple( | ||
| routine.resolve_typebound_var(size, symbol_map) for size in self.horizontal.size_expressions | ||
| routine.resolve_typebound_var(size, symbol_map) for size in self.horizontal.sizes |
There was a problem hiding this comment.
Considering that the new promotion transformation is only applied to kernels, I'm wondering why this seemingly unrelated change is needed for the driver?
Add
PromoteLocalArrayTransformationfor local array promotion in SCC pipelineThis is the first in a series of three PRs for the ecRad Loki GPU work.
This PR adds a new transformation
PromoteLocalArrayTransformationthat promotes local arrays with a horizontal dimension in the SCC pipeline. The transformation is included inSCCVVectorPipelinebut disabled by default and can be activated with the item config keypromote_locals.PromoteLocalArrayTransformationThe transformation identifies local arrays used inside vector sections (as marked by
SCCDevectorTransformation) and promotes them by appending the horizontal range dimension.It:
ridden per routine via the
promote_constant_arraysitem config key (defaultFalse)Changes to existing utilities
The declaration-update logic previously lived inside
demote_variablesbut has been extracted into a sharedupdate_variable_declarationsutility inutilities.py. This is now used in both the demotion and promotion transformations. A newpromote_variable_declarationsinpromote.pyhandles spec-only promotion and usessingle_variable_declarationto isolate each variable before modifying shapes. A helper_is_deferred_shapedecides whether promoted dimensions should also be deferred.Furthermore, the following changes have been made:
Dimension.size_expressions(loki/dimension.py): Now returns all lower/upper bounds pairs, not just the first bounds pair.SCCVVectorPipeline(loki/transformations/single_column/scc.py):PromoteLocalArrayTransformationadded betweenSCCDemoteTransformationandSCCVecRevectorTransformation. (It is off by default but is required to sit in between the devectorization and revectorization steps).Contributor Declaration
By opening this pull request, I affirm the following: