-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[OpenMP][MLIR] Preserve to/from flags in mapper base entry for mappers #159799
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
+70
−3
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
48 changes: 48 additions & 0 deletions
48
offload/test/offloading/fortran/target-declare-mapper-allocatable.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,48 @@ | ||
| ! This test validates that declare mapper for a derived type with an | ||
| ! allocatable component preserves TO/FROM semantics for the component, | ||
| ! ensuring the payload is copied back to the host on target exit. | ||
|
|
||
| ! REQUIRES: flang, amdgpu | ||
|
|
||
| ! RUN: %libomptarget-compile-fortran-run-and-check-generic | ||
|
|
||
| program target_declare_mapper_allocatable | ||
| implicit none | ||
|
|
||
| type :: real_t | ||
| real, allocatable :: real_arr(:) | ||
| end type real_t | ||
|
|
||
| ! Map the allocatable array payload via a named mapper. | ||
| !$omp declare mapper (xyz : real_t :: t) map(tofrom: t%real_arr) | ||
|
|
||
| type(real_t) :: r | ||
| integer :: i | ||
| logical :: ok | ||
|
|
||
| allocate(r%real_arr(10)) | ||
| r%real_arr = 1.0 | ||
|
|
||
| !$omp target map(mapper(xyz), tofrom: r) | ||
| do i = 1, size(r%real_arr) | ||
| r%real_arr(i) = 3.0 | ||
| end do | ||
| !$omp end target | ||
|
|
||
| ok = .true. | ||
| do i = 1, size(r%real_arr) | ||
| if (r%real_arr(i) /= 3.0) ok = .false. | ||
| end do | ||
| if (ok) then | ||
| print *, "Test passed!" | ||
| else | ||
| print *, "Test failed!" | ||
| do i = 1, size(r%real_arr) | ||
| print *, r%real_arr(i) | ||
| end do | ||
| end if | ||
|
|
||
| deallocate(r%real_arr) | ||
| end program target_declare_mapper_allocatable | ||
|
|
||
| ! CHECK: Test passed! |
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.