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

Minor bugfixes for GlobalVarOffloadTransformation #204

Closed
Closed
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
14 changes: 4 additions & 10 deletions transformations/transformations/data_offload.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ def process_driver(self, routine, successors):
"""
Add offload and/or copy-back directives for the imported variables.
"""

update_device = ()
update_host = ()

Expand All @@ -370,7 +369,7 @@ def process_driver(self, routine, successors):
'enter_data_create': 'enter data create',
}
for key, directive in key_directive_map.items():
variables = set.union(*[s.trafo_data.get(self._key, {}).get(key) for s in successors], set())
variables = set.union(*[s.trafo_data.get(self._key, {}).get(key, {}) for s in successors], set())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change avoids an iteration error over Nones, since in the original version, the get(key) can return a None

if variables:
update_device += (Pragma(keyword='acc', content=f'{directive}({",".join(variables)})'),)

Expand All @@ -379,7 +378,7 @@ def process_driver(self, routine, successors):
'acc_copyout': 'update self'
}
for key, directive in key_directive_map.items():
variables = set.union(*[s.trafo_data.get(self._key, {}).get(key) for s in successors], set())
variables = set.union(*[s.trafo_data.get(self._key, {}).get(key, {}) for s in successors], set())
if variables:
update_host += (Pragma(keyword='acc', content=f'{directive}({",".join(variables)})'),)

Expand Down Expand Up @@ -429,14 +428,9 @@ def process_driver(self, routine, successors):
new_imports += as_tuple(Import(k, symbols=tuple(Variable(name=s, scope=routine) for s in v)))

# add new imports to driver subroutine sepcification
import_pos = 0
if (old_imports := FindNodes(Import).visit(routine.spec)):
import_pos = routine.spec.body.index(old_imports[-1]) + 1
if new_imports:
routine.spec.insert(import_pos, Comment(text=
routine.spec.prepend(new_imports)
routine.spec.prepend(Comment(text=
'![Loki::GlobalVarOffload].....Adding global variables to driver symbol table for offload instructions'))
import_pos += 1
routine.spec.insert(import_pos, new_imports)
Comment on lines -432 to -439
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change modifies the way the module variable imports are added to the driver routine. The original inserts them to the specification part. The problem with this is that it may add the imports after IMPLICIT NONE, which results in errors when compiling the transformed code. The suggested code avoids this by prepending the imports.


def process_kernel(self, routine, successors, item):
"""
Expand Down
Loading