Add core infrastructure fixes for small-kernels pipeline - #694
Open
MichaelSt98 wants to merge 7 commits into
Open
Add core infrastructure fixes for small-kernels pipeline#694MichaelSt98 wants to merge 7 commits into
MichaelSt98 wants to merge 7 commits into
Conversation
|
Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/694/index.html |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #694 +/- ##
==========================================
- Coverage 94.16% 94.11% -0.06%
==========================================
Files 291 295 +4
Lines 48447 49017 +570
==========================================
+ Hits 45622 46130 +508
- Misses 2825 2887 +62
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… with alternative routines. Conceptually, the transformation walks each call site in the processed routine, looks for names listed in ``replace_kernels_map``, resolves the replacement routine, and reconstructs the actual argument list against the replacement signature. When the original call target is unresolved in the IR, the transformation also tries to resolve the original routine from source so that remapping can still be done against the original dummy argument names instead of the raw actual expressions. Once the replacement call has been rebuilt, the transformation updates imports/includes to match the new callee and optionally marks the replacement routine as blocked for further scheduler traversal.
Introduce a transformation that replaces the executable body of configured routines with a configurable stub while rewriting kept array declarations to fully deferred shape. This allows routines that are no longer called but must still compile to be safely reduced to minimal shells. The stub_kind parameter controls the replacement body: 'error_stop' (default) inserts a fail-loud ERROR STOP statement so accidental calls are caught at runtime, while 'empty' produces a silent no-op. Routine matching supports both plain names and fully qualified module#routine scheduler item names. Declarations with intent, pointer, or allocatable attributes are preserved with deferred shape; all other local array declarations are removed. Scalar declarations are kept unchanged.
MichaelSt98
force-pushed
the
nams-sk-infra
branch
from
June 18, 2026 12:42
f72689b to
61132bb
Compare
…ms-sk-infra-rebuilt-2
…' into nams-sk-infra-rebuilt-2
Fix SubstituteExpressionsMapper to also register the underlying VariableSymbol when the expression map key is a MetaSymbol, so that derived-type parent substitution (e.g. geom -> geom_new propagating to geom%dim%nproma) works correctly. Add a recurse_var_parent flag to LokiWalkMapper (default True, backward compatible) and a new FindUsedVariables expression finder that collects variables as they are used without decomposing derived-type parents into separate entries. Add get_block_index to TemporariesPoolAllocatorTransformation so the pool allocator can resolve derived-type block-dimension indices (e.g. geom%blk_dim%ib) instead of only matching simple variable names. Add ignore_index_undefined flag to promote_variables so callers can keep an explicit index expression even when dataflow analysis cannot prove it is live at every use site.
MichaelSt98
force-pushed
the
nams-sk-infra
branch
from
June 18, 2026 13:53
61132bb to
4c6f05c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces several enhancements and fixes to variable handling in expression mapping, array promotion, and temporary pool allocator transformations. The main changes focus on providing more precise variable collection, supporting explicit index retention in array promotions, and improving the resolution of derived-type block indices. Comprehensive tests are added to ensure the correctness of these new behaviors.
Expression mapping and variable collection:
FindUsedVariablesvisitor inloki/ir/expr_visitors.pythat collects only the used member expressions without recursing into their parent chains, improving the precision of variable usage analysis. ([loki/ir/expr_visitors.pyR187-R198](https://github.com/ecmwf-ifs/loki/pull/694/files#diff-cd38c31e937a1478653d40a9f97adea800fadd922039b18b42b013e9b2b6c4b5R187-R198))LokiWalkMapperto allow controlling recursion into parent components via a newrecurse_var_parentargument. ([loki/expression/mappers.pyR229-R236](https://github.com/ecmwf-ifs/loki/pull/694/files#diff-86dcd26846fd8111831a312d147a885c713b6397e5d43bdf4180abebdba96b11R229-R236))FindUsedVariablesskips parent components as intended. ([loki/expression/tests/test_expression.pyR1381-R1402](https://github.com/ecmwf-ifs/loki/pull/694/files#diff-edcf72b91a67e888e51fc7cabcd6cb87e6e4b561a8e2d60c38e2e3358d816025R1381-R1402))Array promotion transformation:
promote_variablesto accept anignore_index_undefinedargument, allowing explicit retention of unresolved promotion indices when requested. ([[1]](https://github.com/ecmwf-ifs/loki/pull/694/files#diff-8afd2442c2d2f132b71a1eb4c2ba566fe746d19438462919cc0cd58b67cd2f3bL30-R30),[[2]](https://github.com/ecmwf-ifs/loki/pull/694/files#diff-8afd2442c2d2f132b71a1eb4c2ba566fe746d19438462919cc0cd58b67cd2f3bR59-R61),[[3]](https://github.com/ecmwf-ifs/loki/pull/694/files#diff-8afd2442c2d2f132b71a1eb4c2ba566fe746d19438462919cc0cd58b67cd2f3bR86-R90))ignore_index_undefined=True. ([loki/transformations/array_indexing/tests/test_array_promote.pyR144-R170](https://github.com/ecmwf-ifs/loki/pull/694/files#diff-25ca74992672348eefeb9c76bc8d9a890c46cdca3bf7b08cbbce4dd035e529d5R144-R170))Temporary pool allocator transformation:
get_block_index, improving support for more complex block index forms. ([[1]](https://github.com/ecmwf-ifs/loki/pull/694/files#diff-dee9adcde30167e25ddb24c4b6de20aae9bcba38017850a137261592e44be4bcR410-R423),[[2]](https://github.com/ecmwf-ifs/loki/pull/694/files#diff-dee9adcde30167e25ddb24c4b6de20aae9bcba38017850a137261592e44be4bcL858-R872))[loki/transformations/temporaries/tests/test_pool_allocator.pyR1432-R1452](https://github.com/ecmwf-ifs/loki/pull/694/files#diff-a999af48b93ac47f0c05921f255e19c790f6e7fd1a22a9927a6addf758d93400R1432-R1452))Other improvements:
SubstituteExpressionsMapperto handleMetaSymbolkeys by also mapping their underlying symbols. ([loki/expression/mappers.pyR752-R757](https://github.com/ecmwf-ifs/loki/pull/694/files#diff-86dcd26846fd8111831a312d147a885c713b6397e5d43bdf4180abebdba96b11R752-R757))[[1]](https://github.com/ecmwf-ifs/loki/pull/694/files#diff-edcf72b91a67e888e51fc7cabcd6cb87e6e4b561a8e2d60c38e2e3358d816025L27-R27),[[2]](https://github.com/ecmwf-ifs/loki/pull/694/files#diff-cd38c31e937a1478653d40a9f97adea800fadd922039b18b42b013e9b2b6c4b5L29-R29),[[3]](https://github.com/ecmwf-ifs/loki/pull/694/files#diff-25ca74992672348eefeb9c76bc8d9a890c46cdca3bf7b08cbbce4dd035e529d5R15),[[4]](https://github.com/ecmwf-ifs/loki/pull/694/files#diff-a999af48b93ac47f0c05921f255e19c790f6e7fd1a22a9927a6addf758d93400L11-R11))Contributor Declaration
By opening this pull request, I affirm the following: