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

Conversation

skarppinen
Copy link
Contributor

@skarppinen skarppinen commented Dec 22, 2023

Hello.

This PR includes two minor bugfixes for GlobalVarOffloadTransformation that came up when I used it with the ACRANEB2 dwarf. I discuss the changes in comments below.

… error over nonetype and prepend new imports to avoid imports after implicit none statement
@@ -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

Comment on lines -432 to -439
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)
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.

Copy link

codecov bot commented Dec 22, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5c0f821) 92.26% compared to head (6e64a1c) 92.26%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #204   +/-   ##
=======================================
  Coverage   92.26%   92.26%           
=======================================
  Files          96       96           
  Lines       17092    17087    -5     
=======================================
- Hits        15770    15766    -4     
+ Misses       1322     1321    -1     
Flag Coverage Δ
lint_rules 96.22% <ø> (ø)
loki 92.24% <ø> (ø)
transformations 91.51% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@reuterbal
Copy link
Collaborator

Hi Santeri,

many thanks, these changes look good. Unfortunately, I had to undertake a refactoring of the entire transformation, which has been submitted in #207. Would you mind confirming that the refactored transformation works as expected on ACRANEB2?

@skarppinen
Copy link
Contributor Author

skarppinen commented Jan 15, 2024

@reuterbal, great, thanks!

I will check what happens with your PR and let you know the results (EDIT: I encountered no issues with your PR!).
Please, just close this PR once yours has been merged.

@reuterbal
Copy link
Collaborator

Closing this, issue has been resolved as part of the refactoring in #207

@reuterbal reuterbal closed this Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants