* function.c (dump_stack_clash_frame_info): New function.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-fortran / asyncwait-1.f90
blob01728bd3f6c8d89d22cbc084881235ffea52b2cc
1 ! { dg-do run }
3 program asyncwait
4 integer, parameter :: N = 64
5 real, allocatable :: a(:), b(:), c(:), d(:), e(:)
6 integer i
8 allocate (a(N))
9 allocate (b(N))
10 allocate (c(N))
11 allocate (d(N))
12 allocate (e(N))
14 a(:) = 3.0
15 b(:) = 0.0
17 !$acc data copy (a(1:N)) copy (b(1:N))
19 !$acc parallel async
20 !$acc loop
21 do i = 1, N
22 b(i) = a(i)
23 end do
24 !$acc end parallel
26 !$acc wait
27 !$acc end data
29 do i = 1, N
30 if (a(i) .ne. 3.0) call abort
31 if (b(i) .ne. 3.0) call abort
32 end do
34 a(:) = 2.0
35 b(:) = 0.0
37 !$acc data copy (a(1:N)) copy (b(1:N))
39 !$acc parallel async (1)
40 !$acc loop
41 do i = 1, N
42 b(i) = a(i)
43 end do
44 !$acc end parallel
46 !$acc wait (1)
47 !$acc end data
49 do i = 1, N
50 if (a(i) .ne. 2.0) call abort
51 if (b(i) .ne. 2.0) call abort
52 end do
54 a(:) = 3.0
55 b(:) = 0.0
56 c(:) = 0.0
57 d(:) = 0.0
59 !$acc data copy (a(1:N)) copy (b(1:N)) copy (c(1:N)) copy (d(1:N))
61 !$acc parallel async (1)
62 do i = 1, N
63 b(i) = (a(i) * a(i) * a(i)) / a(i)
64 end do
65 !$acc end parallel
67 !$acc parallel async (1)
68 do i = 1, N
69 c(i) = (a(i) * 4) / a(i)
70 end do
71 !$acc end parallel
73 !$acc parallel async (1)
74 !$acc loop
75 do i = 1, N
76 d(i) = ((a(i) * a(i) + a(i)) / a(i)) - a(i)
77 end do
78 !$acc end parallel
80 !$acc wait (1)
81 !$acc end data
83 do i = 1, N
84 if (a(i) .ne. 3.0) call abort
85 if (b(i) .ne. 9.0) call abort
86 if (c(i) .ne. 4.0) call abort
87 if (d(i) .ne. 1.0) call abort
88 end do
90 a(:) = 2.0
91 b(:) = 0.0
92 c(:) = 0.0
93 d(:) = 0.0
94 e(:) = 0.0
96 !$acc data copy (a(1:N), b(1:N), c(1:N), d(1:N), e(1:N))
98 !$acc parallel async (1)
99 do i = 1, N
100 b(i) = (a(i) * a(i) * a(i)) / a(i)
101 end do
102 !$acc end parallel
104 !$acc parallel async (1)
105 !$acc loop
106 do i = 1, N
107 c(i) = (a(i) * 4) / a(i)
108 end do
109 !$acc end parallel
111 !$acc parallel async (1)
112 !$acc loop
113 do i = 1, N
114 d(i) = ((a(i) * a(i) + a(i)) / a(i)) - a(i)
115 end do
116 !$acc end parallel
118 !$acc parallel wait (1) async (1)
119 !$acc loop
120 do i = 1, N
121 e(i) = a(i) + b(i) + c(i) + d(i)
122 end do
123 !$acc end parallel
125 !$acc wait (1)
126 !$acc end data
128 do i = 1, N
129 if (a(i) .ne. 2.0) call abort
130 if (b(i) .ne. 4.0) call abort
131 if (c(i) .ne. 4.0) call abort
132 if (d(i) .ne. 1.0) call abort
133 if (e(i) .ne. 11.0) call abort
134 end do
136 a(:) = 3.0
137 b(:) = 0.0
139 !$acc data copy (a(1:N)) copy (b(1:N))
141 !$acc kernels async
142 !$acc loop
143 do i = 1, N
144 b(i) = a(i)
145 end do
146 !$acc end kernels
148 !$acc wait
149 !$acc end data
151 do i = 1, N
152 if (a(i) .ne. 3.0) call abort
153 if (b(i) .ne. 3.0) call abort
154 end do
156 a(:) = 2.0
157 b(:) = 0.0
159 !$acc data copy (a(1:N)) copy (b(1:N))
161 !$acc kernels async (1)
162 !$acc loop
163 do i = 1, N
164 b(i) = a(i)
165 end do
166 !$acc end kernels
168 !$acc wait (1)
169 !$acc end data
171 do i = 1, N
172 if (a(i) .ne. 2.0) call abort
173 if (b(i) .ne. 2.0) call abort
174 end do
176 a(:) = 3.0
177 b(:) = 0.0
178 c(:) = 0.0
179 d(:) = 0.0
181 !$acc data copy (a(1:N)) copy (b(1:N)) copy (c(1:N)) copy (d(1:N))
183 !$acc kernels async (1)
184 do i = 1, N
185 b(i) = (a(i) * a(i) * a(i)) / a(i)
186 end do
187 !$acc end kernels
189 !$acc kernels async (1)
190 do i = 1, N
191 c(i) = (a(i) * 4) / a(i)
192 end do
193 !$acc end kernels
195 !$acc kernels async (1)
196 !$acc loop
197 do i = 1, N
198 d(i) = ((a(i) * a(i) + a(i)) / a(i)) - a(i)
199 end do
200 !$acc end kernels
202 !$acc wait (1)
203 !$acc end data
205 do i = 1, N
206 if (a(i) .ne. 3.0) call abort
207 if (b(i) .ne. 9.0) call abort
208 if (c(i) .ne. 4.0) call abort
209 if (d(i) .ne. 1.0) call abort
210 end do
212 a(:) = 2.0
213 b(:) = 0.0
214 c(:) = 0.0
215 d(:) = 0.0
216 e(:) = 0.0
218 !$acc data copy (a(1:N), b(1:N), c(1:N), d(1:N), e(1:N))
220 !$acc kernels async (1)
221 do i = 1, N
222 b(i) = (a(i) * a(i) * a(i)) / a(i)
223 end do
224 !$acc end kernels
226 !$acc kernels async (1)
227 !$acc loop
228 do i = 1, N
229 c(i) = (a(i) * 4) / a(i)
230 end do
231 !$acc end kernels
233 !$acc kernels async (1)
234 !$acc loop
235 do i = 1, N
236 d(i) = ((a(i) * a(i) + a(i)) / a(i)) - a(i)
237 end do
238 !$acc end kernels
240 !$acc kernels wait (1) async (1)
241 !$acc loop
242 do i = 1, N
243 e(i) = a(i) + b(i) + c(i) + d(i)
244 end do
245 !$acc end kernels
247 !$acc wait (1)
248 !$acc end data
250 do i = 1, N
251 if (a(i) .ne. 2.0) call abort
252 if (b(i) .ne. 4.0) call abort
253 if (c(i) .ne. 4.0) call abort
254 if (d(i) .ne. 1.0) call abort
255 if (e(i) .ne. 11.0) call abort
256 end do
257 end program asyncwait