-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[openmp][flang] Add tests for map clause #70394
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
! REQUIRES: flang, amdgcn-amd-amdhsa | ||
! UNSUPPORTED: nvptx64-nvidia-cuda | ||
! UNSUPPORTED: nvptx64-nvidia-cuda-LTO | ||
! UNSUPPORTED: aarch64-unknown-linux-gnu | ||
! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO | ||
! UNSUPPORTED: x86_64-pc-linux-gnu | ||
! UNSUPPORTED: x86_64-pc-linux-gnu-LTO | ||
|
||
! RUN: %libomptarget-compile-fortran-run-and-check-generic | ||
! XFAIL: * | ||
|
||
program main | ||
use omp_lib | ||
integer :: devices(2), var1 | ||
common var1 | ||
var1 = 10 | ||
print *, "var1 before target = ", var1 | ||
devices(1) = omp_get_device_num() | ||
!$omp target map(tofrom:devices) map(tofrom:var1) | ||
var1 = 20 | ||
devices(2) = omp_get_device_num() | ||
!$omp end target | ||
print *, "var1 after target = ", var1 | ||
print *, "devices: ", devices | ||
end program | ||
|
||
! CHECK: var1 before target = 10 | ||
! CHECK: var1 after target = 20 | ||
! CHECK: devices: 1 0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
! REQUIRES: flang, amdgcn-amd-amdhsa | ||
! UNSUPPORTED: nvptx64-nvidia-cuda | ||
! UNSUPPORTED: nvptx64-nvidia-cuda-LTO | ||
! UNSUPPORTED: aarch64-unknown-linux-gnu | ||
! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO | ||
! UNSUPPORTED: x86_64-pc-linux-gnu | ||
! UNSUPPORTED: x86_64-pc-linux-gnu-LTO | ||
|
||
! RUN: %libomptarget-compile-fortran-run-and-check-generic | ||
! XFAIL: * | ||
|
||
program main | ||
use omp_lib | ||
integer :: tmp, var4 | ||
common var4 | ||
var4 = 24 | ||
tmp = 12 | ||
print *, "var4 before target = ", var4 | ||
!$omp target map(tofrom:var4) | ||
var4 = tmp | ||
!$omp end target | ||
print *, "var4 after target = ", var4 | ||
end program | ||
|
||
! CHECK: var4 before target = 24 | ||
! CHECK: var4 after target = 12 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
! Basic offloading test with a target region | ||
! REQUIRES: flang, amdgcn-amd-amdhsa | ||
! UNSUPPORTED: nvptx64-nvidia-cuda | ||
! UNSUPPORTED: nvptx64-nvidia-cuda-LTO | ||
! UNSUPPORTED: aarch64-unknown-linux-gnu | ||
! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO | ||
! UNSUPPORTED: x86_64-pc-linux-gnu | ||
! UNSUPPORTED: x86_64-pc-linux-gnu-LTO | ||
|
||
! RUN: %libomptarget-compile-fortran-run-and-check-generic | ||
|
||
! Testing simple variables in common block. | ||
program main | ||
call check_device | ||
call commonblock_simple_with_implicit_type | ||
call commonblock_simple_with_integer | ||
call commonblock_simple_with_real | ||
end program main | ||
|
||
!----- | ||
|
||
subroutine check_device | ||
use omp_lib | ||
integer :: devices(2) | ||
devices(1) = omp_get_device_num() | ||
!$omp target map(tofrom:devices) | ||
devices(2) = omp_get_device_num() | ||
!$omp end target | ||
print *, "devices: ", devices | ||
end subroutine check_device | ||
|
||
!CHECK: devices: 1 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, this will sooner or later blow up. You assume there is only one GPU. I'd recommend to do something like:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing this out. If possible, I'd like to do something like this, and make sure this runs only if there is a device. Is it possible to do this with LIT directives to ensure this test runs when there is atleast one device, and doesn't run (unsupported) otherwise?
|
||
|
||
!----- | ||
|
||
subroutine commonblock_simple_with_implicit_type | ||
use omp_lib | ||
common var1 | ||
var1 = 10 | ||
print *, "var1 before target = ", var1 | ||
!$omp target map(tofrom:var1) | ||
var1 = 20 | ||
!$omp end target | ||
print *, "var1 after target = ", var1 | ||
end subroutine | ||
|
||
! CHECK: var1 before target = 10 | ||
! CHECK: var1 after target = 20 | ||
|
||
! ----- | ||
|
||
subroutine commonblock_simple_with_integer | ||
use omp_lib | ||
integer :: var2 | ||
common var2 | ||
var2 = 10 | ||
print *, "var2 before target = ", var2 | ||
!$omp target map(tofrom:var2) | ||
var2 = 20 | ||
!$omp end target | ||
print *, "var2 after target = ", var2 | ||
end subroutine | ||
|
||
! CHECK: var2 before target = 10 | ||
! CHECK: var2 after target = 20 | ||
|
||
! ----- | ||
|
||
subroutine commonblock_simple_with_real | ||
use omp_lib | ||
real :: var3 | ||
common var3 | ||
var3 = 12.5 | ||
print *, "var3 before target = ", var3 | ||
!$omp target map(tofrom:var3) | ||
var3 = 14.5 | ||
!$omp end target | ||
print *, "var3 after target = ", var3 | ||
end subroutine | ||
|
||
! CHECK: var3 before target = 12.5 | ||
! CHECK: var3 after target = 14.5 |
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.
awesome to see this working! :D admittedly have never tried it