PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgomp / testsuite / libgomp.fortran / target6.f90
blob82f49e2b9c871d1869d309a11d4e72b642fa5238
1 ! { dg-do run }
3 module target6
4 contains
5 subroutine foo (p, v, w, n)
6 double precision, pointer :: p(:), v(:), w(:)
7 double precision :: q(n)
8 integer :: i, n
9 !$omp target data if (n > 256) map (to: v(1:n), w(:n)) map (from: p(1:n), q)
10 !$omp target if (n > 256)
11 !$omp parallel do simd
12 do i = 1, n
13 p(i) = v(i) * w(i)
14 q(i) = p(i)
15 end do
16 !$omp end target
17 !$omp target update if (n > 256) from (p)
18 do i = 1, n
19 if (p(i) /= i * iand (i, 63)) STOP 1
20 v(i) = v(i) + 1
21 end do
22 !$omp target update if (n > 256) to (v(1:n))
23 !$omp target if (n > 256)
24 !$omp parallel do simd
25 do i = 1, n
26 p(i) = v(i) * w(i)
27 end do
28 !$omp end target
29 !$omp end target data
30 do i = 1, n
31 if (q(i) /= (v(i) - 1) * w(i)) STOP 2
32 if (p(i) /= q(i) + w(i)) STOP 3
33 end do
34 end subroutine
35 end module target6
36 use target6, only : foo
37 integer :: n, i
38 double precision, pointer :: p(:), v(:), w(:)
39 n = 10000
40 allocate (p(n), v(n), w(n))
41 do i = 1, n
42 v(i) = i
43 w(i) = iand (i, 63)
44 end do
45 call foo (p, v, w, n)
46 do i = 1, n
47 if (p(i) /= (i + 1) * iand (i, 63)) STOP 4
48 end do
49 deallocate (p, v, w)
50 end