2015-11-30 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / libgomp / testsuite / libgomp.fortran / target1.f90
blobc70daace497c16cd44f455a0ecff80088be3398d
1 ! { dg-do run }
3 module target1
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 if (n > 256) map (to: v(1:n), w(:n)) map (from: p(1:n), q)
10 !$omp parallel do simd
11 do i = 1, n
12 p(i) = v(i) * w(i)
13 q(i) = p(i)
14 end do
15 !$omp end target
16 if (any (p /= q)) call abort
17 do i = 1, n
18 if (p(i) /= i * iand (i, 63)) call abort
19 end do
20 !$omp target data if (n > 256) map (to: v(1:n), w) map (from: p, q)
21 !$omp target if (n > 256)
22 do i = 1, n
23 p(i) = 1.0
24 q(i) = 2.0
25 end do
26 !$omp end target
27 !$omp target if (n > 256)
28 do i = 1, n
29 p(i) = p(i) + v(i) * w(i)
30 q(i) = q(i) + v(i) * w(i)
31 end do
32 !$omp end target
33 !$omp target if (n > 256)
34 !$omp teams distribute parallel do simd linear(i:1)
35 do i = 1, n
36 p(i) = p(i) + 2.0
37 q(i) = q(i) + 3.0
38 end do
39 !$omp end target
40 !$omp end target data
41 if (any (p + 2.0 /= q)) call abort
42 end subroutine
43 end module target1
44 use target1, only : foo
45 integer :: n, i
46 double precision, pointer :: p(:), v(:), w(:)
47 n = 10000
48 allocate (p(n), v(n), w(n))
49 do i = 1, n
50 v(i) = i
51 w(i) = iand (i, 63)
52 end do
53 call foo (p, v, w, n)
54 do i = 1, n
55 if (p(i) /= i * iand (i, 63) + 3) call abort
56 end do
57 deallocate (p, v, w)
58 end