Skip gnat.dg/prot7.adb on hppa.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-fortran / common-block-3.f90
blob3c59b66246be4a4337347b95672976aeb9a1ee54
1 ! { dg-do run }
3 ! Test data located inside common blocks. This test does not exercise
4 ! ACC DECLARE. Most of the data clauses are implicit.
6 module consts
7 integer, parameter :: n = 100
8 end module consts
10 subroutine validate
11 use consts
13 implicit none
14 integer i, j
15 real*4 x(n), y(n), z
16 common /BLOCK/ x, y, z, j
18 do i = 1, n
19 if (abs(x(i) - i - z) .ge. 0.0001) stop 1
20 end do
21 end subroutine validate
23 subroutine incr_parallel
24 use consts
26 implicit none
27 integer i, j
28 real*4 x(n), y(n), z
29 common /BLOCK/ x, y, z, j
31 !$acc parallel loop
32 do i = 1, n
33 x(i) = x(i) + z
34 end do
35 !$acc end parallel loop
36 end subroutine incr_parallel
38 subroutine incr_kernels
39 use consts
41 implicit none
42 integer i, j
43 real*4 x(n), y(n), z
44 common /BLOCK/ x, y, z, j
46 !$acc kernels
47 do i = 1, n
48 x(i) = x(i) + z
49 end do
50 !$acc end kernels
51 end subroutine incr_kernels
53 program main
54 use consts
56 implicit none
57 integer i, j
58 real*4 a(n), b(n), c
59 common /BLOCK/ a, b, c, j
61 !$acc data copyout(a, c)
63 c = 1.0
65 !$acc update device(c)
67 !$acc parallel loop
68 do i = 1, n
69 a(i) = i
70 end do
71 !$acc end parallel loop
73 call incr_parallel
74 call incr_parallel
75 call incr_parallel
76 !$acc end data
78 c = 3.0
79 call validate
81 ! Test pcopy without copyout
83 c = 2.0
84 call incr_kernels
85 c = 5.0
86 call validate
88 !$acc kernels
89 do i = 1, n
90 b(i) = i
91 end do
92 !$acc end kernels
94 !$acc parallel loop
95 do i = 1, n
96 a(i) = b(i) + c
97 end do
98 !$acc end parallel loop
100 call validate
102 a(:) = b(:)
103 c = 0.0
104 call validate
106 ! Test copy
108 c = 1.0
109 !$acc parallel loop
110 do i = 1, n
111 a(i) = b(i) + c
112 end do
113 !$acc end parallel loop
115 call validate
117 c = 2.0
118 !$acc data copyin(b, c) copyout(a)
120 !$acc kernels
121 do i = 1, n
122 a(i) = b(i) + c
123 end do
124 !$acc end kernels
126 !$acc end data
128 call validate
130 j = 0
132 !$acc parallel loop reduction(+:j)
133 do i = 1, n
134 j = j + 1
135 end do
136 !$acc end parallel loop
138 if (j .ne. n) stop 2
139 end program main