New transformation: SanitiseUnusedRoutineTransformation.#693
Open
MichaelSt98 wants to merge 1 commit into
Open
New transformation: SanitiseUnusedRoutineTransformation.#693MichaelSt98 wants to merge 1 commit into
SanitiseUnusedRoutineTransformation.#693MichaelSt98 wants to merge 1 commit into
Conversation
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.
|
Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/693/index.html |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #693 +/- ##
==========================================
+ Coverage 94.19% 94.21% +0.01%
==========================================
Files 288 290 +2
Lines 47496 47744 +248
==========================================
+ Hits 44741 44983 +242
- Misses 2755 2761 +6
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:
|
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.
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.
Description
This pull request introduces the new
SanitiseUnusedRoutineTransformationtransformation to the codebase, which allows configured routines that are no longer used to be sanitized for compilation. The transformation rewrites array declarations to use deferred shapes, removes unnecessary local arrays, and replaces the routine body with either an error-stop or an empty stub, depending on configuration. Comprehensive tests are added to verify its behavior.New transformation for sanitizing unused routines:
SanitiseUnusedRoutineTransformationclass inloki/transformations/sanitise/unused_routines.py, which supports rewriting array declarations to deferred shapes, removing unused local arrays, and replacing the body with a configurable stub (error_stoporempty).loki.transformations.sanitisepackage by importing it in__init__.py.Testing and validation:
test_unused_routines.pywith comprehensive tests for the new transformation, covering deferred shape rewriting, qualified routine name matching, stub kind selection, non-matching routines, and error handling for invalid stub kinds.Contributor Declaration
By opening this pull request, I affirm the following: