-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[Flang][OpenMP] Initial defaultmap(none) implementation #166715
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
Merged
+191
−16
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| ! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=51 | ||
|
|
||
| subroutine defaultmap_all_none_no_errors | ||
| implicit none | ||
| real :: array(10) | ||
| integer, pointer :: ptr(:) | ||
| real, allocatable :: alloca | ||
| integer :: index | ||
|
|
||
| !$omp target defaultmap(none) map(to: index, alloca) map(tofrom: array, ptr) | ||
| do index = 1, 10 | ||
| ptr(index) = array(index) + alloca | ||
| end do | ||
| !$omp end target | ||
| end subroutine defaultmap_all_none_no_errors | ||
|
|
||
| subroutine defaultmap_all_none | ||
| implicit none | ||
| real :: array(10) | ||
| integer, pointer :: ptr(:) | ||
| real, allocatable :: alloca | ||
| integer :: index | ||
| !$omp target defaultmap(none) | ||
| !ERROR: The DEFAULTMAP(NONE) clause requires that 'index' must be listed in a data-sharing attribute, data-mapping attribute, or is_device_ptr clause | ||
| do index = 1, 10 | ||
| !ERROR: The DEFAULTMAP(NONE) clause requires that 'ptr' must be listed in a data-sharing attribute, data-mapping attribute, or is_device_ptr clause | ||
| !ERROR: The DEFAULTMAP(NONE) clause requires that 'index' must be listed in a data-sharing attribute, data-mapping attribute, or is_device_ptr clause | ||
| !ERROR: The DEFAULTMAP(NONE) clause requires that 'array' must be listed in a data-sharing attribute, data-mapping attribute, or is_device_ptr clause | ||
| !ERROR: The DEFAULTMAP(NONE) clause requires that 'index' must be listed in a data-sharing attribute, data-mapping attribute, or is_device_ptr clause | ||
| !ERROR: The DEFAULTMAP(NONE) clause requires that 'alloca' must be listed in a data-sharing attribute, data-mapping attribute, or is_device_ptr clause | ||
| ptr(index) = array(index) + alloca | ||
| end do | ||
| !$omp end target | ||
| end subroutine defaultmap_all_none | ||
|
|
||
| subroutine defaultmap_scalar_none | ||
| implicit none | ||
| real :: array(10) | ||
| integer, pointer :: ptr(:) | ||
| real, allocatable :: alloca | ||
| integer :: index | ||
|
|
||
| !$omp target defaultmap(none: scalar) | ||
| !ERROR: The DEFAULTMAP(NONE) clause requires that 'index' must be listed in a data-sharing attribute, data-mapping attribute, or is_device_ptr clause | ||
| do index = 1, 10 | ||
| !ERROR: The DEFAULTMAP(NONE) clause requires that 'index' must be listed in a data-sharing attribute, data-mapping attribute, or is_device_ptr clause | ||
| !ERROR: The DEFAULTMAP(NONE) clause requires that 'index' must be listed in a data-sharing attribute, data-mapping attribute, or is_device_ptr clause | ||
| ptr(index) = array(index) + alloca | ||
| end do | ||
| !$omp end target | ||
| end subroutine defaultmap_scalar_none | ||
|
|
||
| subroutine defaultmap_pointer_none | ||
| implicit none | ||
| real :: array(10) | ||
| integer, pointer :: ptr(:) | ||
| real, allocatable :: alloca | ||
| integer :: index | ||
|
|
||
| !$omp target defaultmap(none: pointer) | ||
| do index = 1, 10 | ||
| !ERROR: The DEFAULTMAP(NONE) clause requires that 'ptr' must be listed in a data-sharing attribute, data-mapping attribute, or is_device_ptr clause | ||
| ptr(index) = array(index) + alloca | ||
| end do | ||
| !$omp end target | ||
| end subroutine defaultmap_pointer_none | ||
|
|
||
| subroutine defaultmap_allocatable_none | ||
| implicit none | ||
| real :: array(10) | ||
| integer, pointer :: ptr(:) | ||
| real, allocatable :: alloca | ||
| integer :: index | ||
|
|
||
| !$omp target defaultmap(none: allocatable) | ||
| do index = 1, 10 | ||
| !ERROR: The DEFAULTMAP(NONE) clause requires that 'alloca' must be listed in a data-sharing attribute, data-mapping attribute, or is_device_ptr clause | ||
| ptr(index) = array(index) + alloca | ||
| end do | ||
| !$omp end target | ||
| end subroutine defaultmap_allocatable_none | ||
|
|
||
| subroutine defaultmap_aggregate_none | ||
| implicit none | ||
| real :: array(10) | ||
| integer, pointer :: ptr(:) | ||
| real, allocatable :: alloca | ||
| integer :: index | ||
|
|
||
| !$omp target defaultmap(none: aggregate) | ||
| do index = 1, 10 | ||
| !ERROR: The DEFAULTMAP(NONE) clause requires that 'array' must be listed in a data-sharing attribute, data-mapping attribute, or is_device_ptr clause | ||
| ptr(index) = array(index) + alloca | ||
| end do | ||
| !$omp end target | ||
| end subroutine defaultmap_aggregate_none |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole thing above really belongs in check-omp-structure. Would it be hard to move it there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too sure, I can try to do so on Monday when I look at updating the PR! The main reason it's here is that the equivalent check for default is above, and there is some interconnection between the two clauses if they appear on the same construct that I'll need to handle in a follow up PR.
The only thing I can think of that might be a problem (aside from needing to supersede the default check above) is if check-omp-structure occurs after resolve-directives, as resolve-directives applies implicit DSAs to things almost immediately after this and from my understanding (from my admittedly shaky reading of the specification and testing with Clang at least) if you apply defaultmap(none), it'd require everything to be explicitly specified in a data sharing attribute or data mapping attribute (or use_device/has_device etc.). So the implicit application of the DSAs below would cause issues (and from last I checked they don't all get the implicit keyword applied at the moment as it impacts some other handling elsewhere, so it's likely not possible to check if all of the DSAs have appeared implicitly or if a user explicitly specified it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p.s. Thank you for the quick review!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The setting of flags on a symbol should be done here, but error reporting should go to check-omp-structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aware of that, I'd have to move the checking for default(none) as well as defaultmap(none) and we wouldn't want to set the flags on these symbols implicitly here and skip them when things are set to none, I'm not sure if there would be any fallout from here to check-omp-structure because of that, will see soon enough I suppose.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the second thought, feel free to leave it here. I'll have to investigate a bit more closely how we handle DSA and mapping attributes here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good @kparzysz thank you very much. I'm a little sparse on knowledge for it myself, other than having worked with this segment of code a little bit when adding the implicit firstprivate DSA, from what I recollect the segment directly after this applies implicit DSA's (firstprivate etc.), but we don't mark every implicitly applied DSA with implicit, if this was fixed I imagine moving both the defaultmap/default segments to check-omp-structure would be fairly easy (if it isn't already and I'm overthinking it) as we could just check if the DSA's are implicitly generated and error out if they are. I recall there being an issue that the implicit flag was tied to some other CodeGen related things, making it not quite possible to tag everything that's implicit with it currently. Perhaps a new flag could be used in its place but that doesn't seem like the most elegant solution.