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

fix scoping for global var hoisting #293

Merged
merged 1 commit into from
Apr 19, 2024
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: 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
Loading