-
Notifications
You must be signed in to change notification settings - Fork 16.1k
[flang][OpenMP] Support custom mappers in target update to/from clauses #169673
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
Open
KrxGu
wants to merge
12
commits into
llvm:main
Choose a base branch
from
KrxGu:fix-issue-168701-target-update-mapper
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+228
−52
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6a8024f
[flang][OpenMP] Support mappers in target update to/from
1822144
[flang][OpenMP] Implement mapper lowering for target update
36d9284
[flang][OpenMP] Refactor mapper resolution per review
8d4ffd2
[flang] Fix clang-format issues
816356c
[flang] Fix test expectations for program-scoped mapper names
481c8ee
[flang] Extract mapper resolution into helper function
9be3148
Refactor mapper code based on review feedback
KrxGu e5a71f3
Remove unnecessary const_cast for mutable symbol member
KrxGu 519db70
Merge branch 'main' into fix-issue-168701-target-update-mapper
KrxGu e09e918
Add offloading test for target update with custom mappers
KrxGu 5dc4a9f
Fix parser API usage: type.derived.t -> type.v.t
KrxGu b248611
Remove unrelated formatting changes from rebase
KrxGu 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
KrxGu marked this conversation as resolved.
Show resolved
Hide resolved
|
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,30 @@ | ||
| ! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=52 | ||
|
|
||
| ! Test mapper name resolution in target update to/from clauses | ||
|
|
||
| program target_update_mapper | ||
| type :: typ | ||
| integer :: a | ||
| end type typ | ||
|
|
||
| !$omp declare mapper(custom: typ :: t) map(t%a) | ||
|
|
||
| type(typ) :: t | ||
| integer :: not_a_mapper | ||
|
|
||
| ! Valid: using custom mapper | ||
| !$omp target update to(mapper(custom): t) | ||
| !$omp target update from(mapper(custom): t) | ||
|
|
||
| ! Valid: using default mapper | ||
| !$omp target update to(mapper(default): t) | ||
|
|
||
| ! Error: undefined mapper | ||
| !ERROR: 'undefined_mapper' not declared | ||
| !$omp target update to(mapper(undefined_mapper): t) | ||
|
|
||
| ! Error: wrong kind of symbol | ||
| !ERROR: Name 'not_a_mapper' should be a mapper name | ||
| !$omp target update from(mapper(not_a_mapper): t) | ||
|
|
||
| end program target_update_mapper |
85 changes: 85 additions & 0 deletions
85
offload/test/offloading/fortran/target-update-custom-mapper.f90
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,85 @@ | ||
| ! Test custom mappers with target update to/from clauses | ||
| ! REQUIRES: flang, amdgpu | ||
|
|
||
| ! RUN: %libomptarget-compile-fortran-run-and-check-generic | ||
|
|
||
| program target_update_mapper_test | ||
| implicit none | ||
| integer, parameter :: n = 100 | ||
|
|
||
| type :: my_type | ||
| integer :: a(n) | ||
| integer :: b(n) | ||
| end type my_type | ||
|
|
||
| ! Declare custom mapper that only maps field 'a' | ||
| !$omp declare mapper(custom : my_type :: t) map(t%a) | ||
|
|
||
| ! Declare default mapper that maps both fields | ||
| !$omp declare mapper(my_type :: t) map(t%a, t%b) | ||
|
|
||
| type(my_type) :: obj1, obj2 | ||
| integer :: i, sum_a, sum_b | ||
|
|
||
| ! ========== Test 1: Custom mapper (field 'a' only) ========== | ||
|
|
||
| ! Initialize data on host | ||
| do i = 1, n | ||
| obj1%a(i) = i | ||
| obj1%b(i) = i * 2 | ||
| end do | ||
|
|
||
| ! Allocate and update using custom mapper (only 'a') | ||
| !$omp target enter data map(mapper(custom), alloc: obj1) | ||
|
|
||
| obj1%a = 10 | ||
| !$omp target update to(mapper(custom): obj1) | ||
|
|
||
| obj1%a = 0 | ||
| !$omp target update from(mapper(custom): obj1) | ||
|
|
||
| sum_a = sum(obj1%a) | ||
| sum_b = sum(obj1%b) | ||
|
|
||
| ! CHECK: Sum of a (custom mapper): 1000 | ||
| print *, "Sum of a (custom mapper):", sum_a | ||
|
|
||
| ! Field 'b' was never mapped with custom mapper | ||
| ! CHECK: Sum of b (never mapped): 10100 | ||
| print *, "Sum of b (never mapped):", sum_b | ||
|
|
||
| !$omp target exit data map(mapper(custom), delete: obj1) | ||
|
|
||
| ! ========== Test 2: Default mapper (both fields) ========== | ||
|
|
||
| ! Initialize separate object for default mapper test | ||
| do i = 1, n | ||
| obj2%a(i) = 20 | ||
| obj2%b(i) = 30 | ||
| end do | ||
|
|
||
| ! Allocate and update using default mapper (both 'a' and 'b') | ||
| !$omp target enter data map(mapper(default), alloc: obj2) | ||
|
|
||
| !$omp target update to(mapper(default): obj2) | ||
|
|
||
| obj2%a = 0 | ||
| obj2%b = 0 | ||
|
|
||
| !$omp target update from(mapper(default): obj2) | ||
|
|
||
| sum_a = sum(obj2%a) | ||
| sum_b = sum(obj2%b) | ||
|
|
||
| ! CHECK: Sum of a (default mapper): 2000 | ||
| print *, "Sum of a (default mapper):", sum_a | ||
|
|
||
| ! CHECK: Sum of b (default mapper): 3000 | ||
| print *, "Sum of b (default mapper):", sum_b | ||
|
|
||
| !$omp target exit data map(mapper(default), delete: obj2) | ||
|
|
||
| ! CHECK: Test passed! | ||
| print *, "Test passed!" | ||
|
|
||
| end program target_update_mapper_test |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.