From df5ca37596270633c0b8875f6d9aad55193d14bd Mon Sep 17 00:00:00 2001 From: Santeri Karppinen Date: Thu, 21 Dec 2023 16:55:03 +0200 Subject: [PATCH 1/2] add small bugfixes to GlobalVarOffloadTransformation. avoid iteration error over nonetype and prepend new imports to avoid imports after implicit none statement --- .../transformations/data_offload.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/transformations/transformations/data_offload.py b/transformations/transformations/data_offload.py index 5759b432b..d74d94df1 100644 --- a/transformations/transformations/data_offload.py +++ b/transformations/transformations/data_offload.py @@ -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 = () @@ -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()) if variables: update_device += (Pragma(keyword='acc', content=f'{directive}({",".join(variables)})'),) @@ -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)})'),) @@ -429,14 +428,17 @@ 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= + #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= + # '![Loki::GlobalVarOffload].....Adding global variables to driver symbol table for offload instructions')) + # import_pos += 1 + # routine.spec.insert(import_pos, new_imports) + 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) def process_kernel(self, routine, successors, item): """ From 6e64a1ca4d0d1081eaa364a9a78812fe8741d8f5 Mon Sep 17 00:00:00 2001 From: Santeri Karppinen Date: Fri, 22 Dec 2023 09:26:56 +0200 Subject: [PATCH 2/2] remove old comments --- transformations/transformations/data_offload.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/transformations/transformations/data_offload.py b/transformations/transformations/data_offload.py index d74d94df1..2481c04b6 100644 --- a/transformations/transformations/data_offload.py +++ b/transformations/transformations/data_offload.py @@ -428,14 +428,6 @@ 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= - # '![Loki::GlobalVarOffload].....Adding global variables to driver symbol table for offload instructions')) - # import_pos += 1 - # routine.spec.insert(import_pos, new_imports) routine.spec.prepend(new_imports) routine.spec.prepend(Comment(text= '![Loki::GlobalVarOffload].....Adding global variables to driver symbol table for offload instructions'))