| 1 |
! { dg-additional-options "-fdump-tree-original" } |
| 2 |
|
| 3 |
! |
| 4 |
! PR fortran/108558 |
| 5 |
! |
| 6 |
|
| 7 |
! { dg-final { scan-tree-dump-times "#pragma omp target has_device_addr\\(x\\) has_device_addr\\(y\\)" 2 "original" } } |
| 8 |
! { dg-final { scan-tree-dump-times "#pragma omp target data map\\(tofrom:x\\) map\\(tofrom:y\\)" 2 "original" } } |
| 9 |
! { dg-final { scan-tree-dump-times "#pragma omp target data use_device_addr\\(x\\) use_device_addr\\(y\\)" 1 "original" } } |
| 10 |
! { dg-final { scan-tree-dump-times "#pragma omp target update from\\(y\\)" 1 "original" } } |
| 11 |
! { dg-final { scan-tree-dump-times "#pragma omp target data map\\(tofrom:x\\) map\\(tofrom:y\\) use_device_addr\\(x\\) use_device_addr\\(y\\)" 1 "original" } } |
| 12 |
! { dg-final { scan-tree-dump-times "#pragma omp teams" 2 "original" } } |
| 13 |
! { dg-final { scan-tree-dump-times "#pragma omp distribute" 2 "original" } } |
| 14 |
! { dg-final { scan-tree-dump-times "#pragma omp parallel" 2 "original" } } |
| 15 |
! { dg-final { scan-tree-dump-times "#pragma omp for nowait" 2 "original" } } |
| 16 |
|
| 17 |
module m |
| 18 |
contains |
| 19 |
subroutine vectorAdd(x, y, N) |
| 20 |
implicit none |
| 21 |
integer :: N |
| 22 |
integer(4) :: x(N), y(N) |
| 23 |
integer :: i |
| 24 |
|
| 25 |
!$omp target teams distribute parallel do has_device_addr(x, y) |
| 26 |
do i = 1, N |
| 27 |
y(i) = x(i) + y(i) |
| 28 |
end do |
| 29 |
end subroutine vectorAdd |
| 30 |
end module m |
| 31 |
|
| 32 |
program main |
| 33 |
use m |
| 34 |
implicit none |
| 35 |
integer, parameter :: N = 9876 |
| 36 |
integer(4) :: x(N), y(N) |
| 37 |
integer :: i |
| 38 |
|
| 39 |
x(:) = 1 |
| 40 |
y(:) = 2 |
| 41 |
|
| 42 |
!$omp target data map(x, y) |
| 43 |
!$omp target data use_device_addr(x, y) |
| 44 |
call vectorAdd(x, y, N) |
| 45 |
!$omp end target data |
| 46 |
!$omp target update from(y) |
| 47 |
if (any (y /= 3)) error stop |
| 48 |
!$omp end target data |
| 49 |
|
| 50 |
x = 1 |
| 51 |
y = 2 |
| 52 |
!$omp target data map(x, y) use_device_addr(x, y) |
| 53 |
!$omp target teams distribute parallel do has_device_addr(x, y) |
| 54 |
do i = 1, N |
| 55 |
y(i) = x(i) + y(i) |
| 56 |
end do |
| 57 |
!$omp end target data |
| 58 |
if (any (y /= 3)) error stop |
| 59 |
end program |