| 1 |
! { dg-do run } |
| 2 |
|
| 3 |
program test |
| 4 |
implicit none |
| 5 |
integer, parameter :: N = 100 |
| 6 |
real, parameter :: PI_CONST = 2.0*acos(0.0) |
| 7 |
real, parameter :: E_CONST = exp(1.0) |
| 8 |
real, parameter :: EPSILON = 0.001 |
| 9 |
integer :: i |
| 10 |
real :: a(N) |
| 11 |
|
| 12 |
!$omp target map(from: a) |
| 13 |
call f (a, PI_CONST) |
| 14 |
!$omp end target |
| 15 |
|
| 16 |
do i = 1, N |
| 17 |
if (abs (a(i) - (PI_CONST * i)) .gt. EPSILON) stop 1 |
| 18 |
end do |
| 19 |
|
| 20 |
call f (a, E_CONST) |
| 21 |
|
| 22 |
do i = 1, N |
| 23 |
if (abs (a(i) - (E_CONST * i)) .gt. EPSILON) stop 2 |
| 24 |
end do |
| 25 |
contains |
| 26 |
subroutine f (a, x) |
| 27 |
integer :: i |
| 28 |
real :: a(N), x |
| 29 |
!$omp declare target |
| 30 |
|
| 31 |
!$omp metadirective & |
| 32 |
!$omp& when (construct={target}: distribute parallel do ) & |
| 33 |
!$omp& default(parallel do simd) |
| 34 |
do i = 1, N |
| 35 |
a(i) = x * i |
| 36 |
end do |
| 37 |
end subroutine |
| 38 |
end program |