-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Flang][OpenMP][MLIR] Implement close, present and ompx_hold modifiers for Flang maps #129586
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=51 %s -o - | FileCheck %s | ||
|
||
subroutine map_present_target_data | ||
integer :: x | ||
!CHECK: %[[MAP:.*]] = omp.map.info {{.*}} map_clauses(present, to) {{.*}} {name = "x"} | ||
!CHECK: omp.target_data map_entries(%[[MAP]] : {{.*}}) { | ||
!$omp target data map(present, to: x) | ||
!$omp end target data | ||
end subroutine | ||
|
||
subroutine map_present_update | ||
integer :: x | ||
!CHECK: %[[MAP:.*]] = omp.map.info {{.*}} map_clauses(present, to) {{.*}} {name = "x"} | ||
!CHECK: omp.target_update map_entries(%[[MAP]] : {{.*}}) | ||
!$omp target update to(present: x) | ||
end subroutine | ||
|
||
subroutine map_close | ||
integer :: x | ||
!CHECK: %[[MAP:.*]] = omp.map.info {{.*}} map_clauses(close, tofrom) {{.*}} {name = "x"} | ||
!CHECK: omp.target_data map_entries(%[[MAP]] : {{.*}}) { | ||
!$omp target data map(close, tofrom: x) | ||
!$omp end target data | ||
end subroutine | ||
|
||
subroutine map_ompx_hold | ||
integer :: x | ||
!CHECK: %[[MAP:.*]] = omp.map.info {{.*}} map_clauses(ompx_hold, tofrom) {{.*}} {name = "x"} | ||
!CHECK: omp.target_data map_entries(%[[MAP]] : {{.*}}) { | ||
!$omp target data map(ompx_hold, tofrom: x) | ||
!$omp end target data | ||
end subroutine |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
! Basic test that checks that when ompx_hold is in use we cannot delete the data | ||
! until the ompx_hold falls out of scope, and verifies this via the utilisation of | ||
! present. | ||
! REQUIRES: flang, amdgpu | ||
! RUN: %libomptarget-compile-fortran-generic | ||
! RUN: %libomptarget-run-fail-generic 2>&1 \ | ||
! RUN: | %fcheck-generic | ||
|
||
program ompx_hold | ||
implicit none | ||
integer :: presence_check | ||
|
||
!CHECK-NOT: omptarget message: device mapping required by 'present' map type modifier does not exist for host address{{.*}} | ||
!$omp target data map(ompx_hold, tofrom: presence_check) | ||
!$omp target exit data map(delete: presence_check) | ||
!$omp target map(present, tofrom: presence_check) | ||
presence_check = 10 | ||
!$omp end target | ||
!$omp end target data | ||
|
||
!CHECK: omptarget message: device mapping required by 'present' map type modifier does not exist for host address{{.*}} | ||
!$omp target data map(tofrom: presence_check) | ||
!$omp target exit data map(delete: presence_check) | ||
!$omp target map(present, tofrom: presence_check) | ||
presence_check = 20 | ||
!$omp end target | ||
!$omp end target data | ||
|
||
end program |
36 changes: 36 additions & 0 deletions
36
offload/test/offloading/fortran/target_map_present_fail.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,36 @@ | ||
! This checks that the basic functionality of map type present functions as | ||
! expected, emitting an omptarget error when the data is not present. | ||
! REQUIRES: flang, amdgpu | ||
! RUN: %libomptarget-compile-fortran-generic | ||
! RUN: %libomptarget-run-fail-generic 2>&1 \ | ||
! RUN: | %fcheck-generic | ||
|
||
! NOTE: This should intentionally fatal error in omptarget as it's not | ||
! present, as is intended. | ||
subroutine target_data_not_present() | ||
double precision, dimension(:), allocatable :: arr | ||
integer, parameter :: N = 16 | ||
integer :: i | ||
|
||
allocate(arr(N)) | ||
|
||
!$omp target data map(present,alloc:arr) | ||
|
||
!$omp target | ||
do i = 1,N | ||
arr(i) = 42.0d0 | ||
end do | ||
!$omp end target | ||
|
||
!$omp end target data | ||
|
||
deallocate(arr) | ||
return | ||
end subroutine | ||
|
||
program map_present | ||
implicit none | ||
call target_data_not_present() | ||
end program | ||
|
||
!CHECK: omptarget message: device mapping required by 'present' map type modifier does not exist for host address{{.*}} |
41 changes: 41 additions & 0 deletions
41
offload/test/offloading/fortran/target_map_present_success.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,41 @@ | ||
! This checks that the basic functionality of map type present functions as | ||
! expected, no-op'ng when present | ||
! REQUIRES: flang, amdgpu | ||
! RUN: %libomptarget-compile-fortran-run-and-check-generic | ||
|
||
subroutine target_data_present() | ||
double precision, dimension(:), allocatable :: arr | ||
integer, parameter :: N = 16 | ||
integer :: i | ||
|
||
allocate(arr(N)) | ||
|
||
arr(:) = 10.0d0 | ||
|
||
!$omp target data map(tofrom:arr) | ||
|
||
!$omp target data map(present,alloc:arr) | ||
|
||
!$omp target | ||
do i = 1,N | ||
arr(i) = 42.0d0 | ||
end do | ||
!$omp end target | ||
|
||
!$omp end target data | ||
|
||
!$omp end target data | ||
|
||
print *, arr | ||
|
||
deallocate(arr) | ||
|
||
return | ||
end subroutine | ||
|
||
program map_present | ||
implicit none | ||
call target_data_present() | ||
end program | ||
|
||
!CHECK: 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. 42. |
Oops, something went wrong.
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.