From 9a16efaf10d3c902a00f09967ef9b04ba09deb3d Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Fri, 11 Aug 2023 10:39:28 +0000 Subject: [PATCH 1/3] SCC: Add logging of private array markers in vector loop annotations --- transformations/transformations/single_column_coalesced.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/transformations/transformations/single_column_coalesced.py b/transformations/transformations/single_column_coalesced.py index e079b4f4f..1ee57609d 100644 --- a/transformations/transformations/single_column_coalesced.py +++ b/transformations/transformations/single_column_coalesced.py @@ -310,6 +310,13 @@ def kernel_annotate_vector_loops_openacc(cls, routine, horizontal, vertical): private_arrays = [v for v in private_arrays if not any(vertical.size in d for d in v.shape)] private_arrays = [v for v in private_arrays if not any(horizontal.size in d for d in v.shape)] + if private_arrays: + # Log private arrays in vector regions, as these can impact performance + info( + f'[Loki-SCC::Annotate] Marking private arrays in {routine.name}: ' + f'{[a.name for a in private_arrays]}' + ) + mapper = {} with pragma_regions_attached(routine): for region in FindNodes(PragmaRegion).visit(routine.body): From 351a7279768c474a9bcc40c5882c6bfbfd57dce2 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Fri, 11 Aug 2023 10:40:22 +0000 Subject: [PATCH 2/3] SCC: Add logging of vector-within-seq markers, which indicate issues --- .../transformations/single_column_coalesced.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/transformations/transformations/single_column_coalesced.py b/transformations/transformations/single_column_coalesced.py index 1ee57609d..209fd6eec 100644 --- a/transformations/transformations/single_column_coalesced.py +++ b/transformations/transformations/single_column_coalesced.py @@ -366,6 +366,12 @@ def kernel_annotate_sequential_loops_openacc(cls, routine, horizontal): # Perform pragma addition in place to avoid nested loop replacements loop._update(pragma=(ir.Pragma(keyword='acc', content='loop seq'),)) + # Warn if we detect vector insisde sequential loop nesting + nested_loops = FindNodes(ir.Loop).visit(loop.body) + loop_pragmas = flatten(as_tuple(l.pragma) for l in as_tuple(nested_loops)) + if any('loop vector' in pragma.content for pragma in loop_pragmas): + info(f'[Loki-SCC::Annotate] Detected vector loop in sequential loop in {routine.name}') + @classmethod def kernel_annotate_subroutine_present_openacc(cls, routine): """ @@ -389,12 +395,12 @@ def kernel_annotate_subroutine_present_openacc(cls, routine): @classmethod def insert_annotations(cls, routine, horizontal, vertical, hoist_column_arrays): - # Mark all non-parallel loops as `!$acc loop seq` - cls.kernel_annotate_sequential_loops_openacc(routine, horizontal) - # Mark all parallel vector loops as `!$acc loop vector` cls.kernel_annotate_vector_loops_openacc(routine, horizontal, vertical) + # Mark all non-parallel loops as `!$acc loop seq` + cls.kernel_annotate_sequential_loops_openacc(routine, horizontal) + # Wrap the routine body in `!$acc data present` markers # to ensure device-resident data is used for array and struct arguments. cls.kernel_annotate_subroutine_present_openacc(routine) From 6098cdbbcf95dbd8ea13107f819ceb914e24b417 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Fri, 11 Aug 2023 10:40:56 +0000 Subject: [PATCH 3/3] SCC/Transform: Harmonize logging nomenclature slightly... --- loki/transform/transform_array_indexing.py | 2 +- transformations/transformations/single_column_coalesced.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/loki/transform/transform_array_indexing.py b/loki/transform/transform_array_indexing.py index 78bacab56..946709ff1 100644 --- a/loki/transform/transform_array_indexing.py +++ b/loki/transform/transform_array_indexing.py @@ -495,4 +495,4 @@ def demote_variables(routine, variable_names, dimensions): ) routine.spec = Transformer(decl_map).visit(routine.spec) - info(f'[Loki] {routine.name}:: demoted variable(s): {", ".join(variable_names)}') + info(f'[Loki::Transform] Demoted variables in {routine.name}: {", ".join(variable_names)}') diff --git a/transformations/transformations/single_column_coalesced.py b/transformations/transformations/single_column_coalesced.py index 209fd6eec..0fd3d0949 100644 --- a/transformations/transformations/single_column_coalesced.py +++ b/transformations/transformations/single_column_coalesced.py @@ -725,8 +725,8 @@ def hoist_temporary_column_arrays(cls, routine, call, horizontal, vertical, bloc ) for v in column_locals] new_call = call.clone(arguments=call.arguments + as_tuple(new_args)) - info(f'[Loki-SCC] Hoisted variables in call {routine.name} => {call.name}:' - f'{[v.name for v in column_locals]}') + info(f'[Loki-SCC::Hoist] Hoisted variables in call {routine.name} => {call.name}:' + f'{", ".join(v.name for v in column_locals)}') # Find the iteration index variable for the specified horizontal v_index = SCCBaseTransformation.get_integer_variable(routine, name=horizontal.index)