Skip to content

Commit

Permalink
fix scoping for 'GlobalVarHoistTransformation'
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSt98 committed Apr 19, 2024
1 parent 102655b commit a0caaa1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions transformations/tests/test_data_offload.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ def test_transformation_global_var_hoist(here, config, frontend, hoist_parameter
assert [arg.name for arg in kernel0.variables] == sorted(expected_vars)
for var in kernel0.arguments:
assert kernel0.variable_map[var.name.lower()].type.intent == var_intent_map[var.name.lower()]
assert var.scope == kernel0
kernel0_inline_calls = FindInlineCalls().visit(kernel0.body)
for inline_call in kernel0_inline_calls:
if ignore_modules is None:
Expand Down Expand Up @@ -752,6 +753,7 @@ def test_transformation_global_var_hoist(here, config, frontend, hoist_parameter
assert [arg.name for arg in kernel_map[call.routine.name].arguments] == expected_args
for var in kernel_map[call.routine.name].variables:
var_intent = kernel_map[call.routine.name].variable_map[var.name.lower()].type.intent
assert var.scope == kernel_map[call.routine.name]
assert var_intent == var_intent_map[var.name.lower()]
if call.routine.name in ['kernel1', 'kernel2']:
expected_args = ['tmp'] + expected_args
Expand Down
2 changes: 1 addition & 1 deletion transformations/transformations/data_offload.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ def _append_routine_arguments(self, routine, item):
new_arguments.append(var.parents[0] if var.parent else var)
new_arguments = set(new_arguments) # remove duplicates
new_arguments = [
arg.clone(type=arg.type.clone(
arg.clone(scope=routine, type=arg.type.clone(
intent='inout' if arg in all_defines_vars else 'in',
parameter=False, initial=None
)) for arg in new_arguments
Expand Down

0 comments on commit a0caaa1

Please sign in to comment.