Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCC: Better logging and warning for "bad" code constructs #125

Merged
merged 3 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion loki/transform/transform_array_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}')
23 changes: 18 additions & 5 deletions transformations/transformations/single_column_coalesced.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -359,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):
"""
Expand All @@ -382,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)
Expand Down Expand Up @@ -712,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)
Expand Down