Skip to content

Commit

Permalink
Merge pull request #430 from ecmwf-ifs/naan-loop-transformation
Browse files Browse the repository at this point in the history
Transformation to call loop transform utilities
  • Loading branch information
reuterbal authored Nov 8, 2024
2 parents c105ed5 + d0fb253 commit 7349e2c
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 54 deletions.
6 changes: 3 additions & 3 deletions example/03_loop_fusion.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": null,
"id": "164b5054",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -982,8 +982,8 @@
}
],
"source": [
"from loki import loop_fusion\n",
"loop_fusion(routine_copy)\n",
"from loki import do_loop_fusion\n",
"do_loop_fusion(routine_copy)\n",
"pragma_map = {pragma: None for pragma in FindNodes(Pragma).visit(routine_copy.body)}\n",
"routine_copy.body = Transformer(pragma_map).visit(routine_copy.body)\n",
"print(routine_copy.to_fortran())"
Expand Down
2 changes: 1 addition & 1 deletion loki/transformations/remove_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RemoveCodeTransformation(Transformation):
"""
A :any:`Transformation` that provides named call and import
removal, code removal of pragma-marked regions and Dead Code
Elimination for batch processing vis the :any:`Scheduler`.
Elimination for batch processing via the :any:`Scheduler`.
The transformation will apply the following methods in order:
Expand Down
8 changes: 4 additions & 4 deletions loki/transformations/single_column/vertical.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
get_pragma_parameters, FindVariables
)
from loki.tools import as_tuple, CaseInsensitiveDict
from loki.transformations.transform_loop import loop_fusion, loop_interchange
from loki.transformations.transform_loop import do_loop_fusion, do_loop_interchange
from loki.transformations.array_indexing import demote_variables
from loki.transformations.utilities import get_local_arrays
from loki.logging import info
Expand Down Expand Up @@ -43,7 +43,7 @@ class SCCFuseVerticalLoops(Transformation):
:any:`Dimension` object describing the variable conventions used in code
to define the vertical data dimension and iteration space.
apply_to : list of str, optional
list of routines to apply this transformation to, if not provided or None
list of routines to apply this transformation to, if not provided or None
apply to all routines (default: None)
"""

Expand Down Expand Up @@ -85,12 +85,12 @@ def process_kernel(self, routine):
# find "multilevel" thus "jk +/- 1" arrays
multilevel_relevant_local_arrays = self.identify_multilevel_arrays(relevant_local_arrays)
# loop interchange to expose vertical loops as outermost loops
loop_interchange(routine)
do_loop_interchange(routine)
# handle initialization of arrays "jk +/- 1" arrays
multilevel_relevant_local_arrays_names = set(arr.name.lower() for arr in multilevel_relevant_local_arrays)
self.correct_init_of_multilevel_arrays(routine, multilevel_relevant_local_arrays_names)
# fuse vertical loops
loop_fusion(routine)
do_loop_fusion(routine)
# demote in vertical dimension if possible
relevant_local_arrays_names = set(arr.name.lower() for arr in relevant_local_arrays)
demote_candidates = relevant_local_arrays_names - multilevel_relevant_local_arrays_names
Expand Down
Loading

0 comments on commit 7349e2c

Please sign in to comment.