8 integer, parameter :: n
= 10, ng
= 8, nw
= 4, vl
= 32
10 real :: vresult
, rg
, rw
, rv
, rc
11 real, parameter :: e
= 0.001
12 logical :: lrg
, lrw
, lrv
, lrc
, lvresult
13 real, dimension (n
) :: array
29 !$acc parallel num_gangs(ng) copy(rg)
30 !$acc loop reduction(+:rg) gang
36 !$acc parallel num_workers(nw) copy(rw)
37 !$acc loop reduction(+:rw) worker
43 !$acc parallel vector_length(vl) copy(rv)
44 !$acc loop reduction(+:rv) vector
50 !$acc parallel num_gangs(ng) num_workers(nw) vector_length(vl) copy(rc)
51 !$acc loop reduction(+:rc) gang worker vector
59 vresult
= vresult
+ array(i
)
62 if (rg
.ne
. vresult
) STOP 1
63 if (rw
.ne
. vresult
) STOP 2
64 if (rv
.ne
. vresult
) STOP 3
65 if (rc
.ne
. vresult
) STOP 4
77 !$acc parallel num_gangs(ng) copy(rg)
78 !$acc loop reduction(*:rg) gang
84 !$acc parallel num_workers(nw) copy(rw)
85 !$acc loop reduction(*:rw) worker
91 !$acc parallel vector_length(vl) copy(rv)
92 !$acc loop reduction(*:rv) vector
98 !$acc parallel num_gangs(ng) num_workers(nw) vector_length(vl) copy(rc)
99 !$acc loop reduction(*:rc) gang worker vector
107 vresult
= vresult
* array(i
)
110 if (abs (rg
- vresult
) .ge
. e
) STOP 5
111 if (abs (rw
- vresult
) .ge
. e
) STOP 6
112 if (abs (rv
- vresult
) .ge
. e
) STOP 7
113 if (abs (rc
- vresult
) .ge
. e
) STOP 8
125 !$acc parallel num_gangs(ng) copy(rg)
126 !$acc loop reduction(max:rg) gang
128 rg
= max (rg
, array(i
))
132 !$acc parallel num_workers(nw) copy(rw)
133 !$acc loop reduction(max:rw) worker
135 rw
= max (rw
, array(i
))
139 !$acc parallel vector_length(vl) copy(rv)
140 !$acc loop reduction(max:rv) vector
142 rv
= max (rv
, array(i
))
146 !$acc parallel num_gangs(ng) num_workers(nw) vector_length(vl) copy(rc)
147 !$acc loop reduction(max:rc) gang worker vector
149 rc
= max (rc
, array(i
))
155 vresult
= max (vresult
, array(i
))
158 if (abs (rg
- vresult
) .ge
. e
) STOP 9
159 if (abs (rw
- vresult
) .ge
. e
) STOP 10
160 if (abs (rg
- vresult
) .ge
. e
) STOP 11
161 if (abs (rc
- vresult
) .ge
. e
) STOP 12
173 !$acc parallel num_gangs(ng) copy(rg)
174 !$acc loop reduction(min:rg) gang
176 rg
= min (rg
, array(i
))
180 !$acc parallel num_workers(nw) copy(rw)
181 !$acc loop reduction(min:rw) worker
183 rw
= min (rw
, array(i
))
187 !$acc parallel vector_length(vl) copy(rv)
188 !$acc loop reduction(min:rv) vector
190 rv
= min (rv
, array(i
))
194 !$acc parallel num_gangs(ng) num_workers(nw) vector_length(vl) copy(rc)
195 !$acc loop reduction(min:rc) gang worker vector
197 rc
= min (rc
, array(i
))
203 vresult
= min (vresult
, array(i
))
206 if (rg
.ne
. vresult
) STOP 13
207 if (rv
.ne
. vresult
) STOP 14
208 if (rw
.ne
. vresult
) STOP 15
209 if (rc
.ne
. vresult
) STOP 16
221 !$acc parallel num_gangs(ng) copy(lrg)
222 !$acc loop reduction(.and.:lrg) gang
224 lrg
= lrg
.and
. (array(i
) .ge
. 5)
228 !$acc parallel num_workers(nw) copy(lrw)
229 !$acc loop reduction(.and.:lrw) worker
231 lrw
= lrw
.and
. (array(i
) .ge
. 5)
235 !$acc parallel vector_length(vl) copy(lrv)
236 !$acc loop reduction(.and.:lrv) vector
238 lrv
= lrv
.and
. (array(i
) .ge
. 5)
242 !$acc parallel num_gangs(ng) num_workers(nw) vector_length(vl) copy(lrc)
243 !$acc loop reduction(.and.:lrc) gang worker vector
245 lrc
= lrc
.and
. (array(i
) .ge
. 5)
251 lvresult
= lvresult
.and
. (array(i
) .ge
. 5)
254 if (lrg
.neqv
. lvresult
) STOP 17
255 if (lrw
.neqv
. lvresult
) STOP 18
256 if (lrv
.neqv
. lvresult
) STOP 19
257 if (lrc
.neqv
. lvresult
) STOP 20
269 !$acc parallel num_gangs(ng) copy(lrg)
270 !$acc loop reduction(.or.:lrg) gang
272 lrg
= lrg
.or
. (array(i
) .ge
. 5)
276 !$acc parallel num_workers(nw) copy(lrw)
277 !$acc loop reduction(.or.:lrw) worker
279 lrw
= lrw
.or
. (array(i
) .ge
. 5)
283 !$acc parallel vector_length(vl) copy(lrv)
284 !$acc loop reduction(.or.:lrv) vector
286 lrv
= lrv
.or
. (array(i
) .ge
. 5)
290 !$acc parallel num_gangs(ng) num_workers(nw) vector_length(vl) copy(lrc)
291 !$acc loop reduction(.or.:lrc) gang worker vector
293 lrc
= lrc
.or
. (array(i
) .ge
. 5)
299 lvresult
= lvresult
.or
. (array(i
) .ge
. 5)
302 if (lrg
.neqv
. lvresult
) STOP 21
303 if (lrw
.neqv
. lvresult
) STOP 22
304 if (lrv
.neqv
. lvresult
) STOP 23
305 if (lrc
.neqv
. lvresult
) STOP 24
317 !$acc parallel num_gangs(ng) copy(lrg)
318 !$acc loop reduction(.eqv.:lrg) gang
320 lrg
= lrg
.eqv
. (array(i
) .ge
. 5)
324 !$acc parallel num_workers(nw) copy(lrw)
325 !$acc loop reduction(.eqv.:lrw) worker
327 lrw
= lrw
.eqv
. (array(i
) .ge
. 5)
331 !$acc parallel vector_length(vl) copy(lrv)
332 !$acc loop reduction(.eqv.:lrv) vector
334 lrv
= lrv
.eqv
. (array(i
) .ge
. 5)
338 !$acc parallel num_gangs(ng) num_workers(nw) vector_length(vl) copy(lrc)
339 !$acc loop reduction(.eqv.:lrc) gang worker vector
341 lrc
= lrc
.eqv
. (array(i
) .ge
. 5)
347 lvresult
= lvresult
.eqv
. (array(i
) .ge
. 5)
350 if (lrg
.neqv
. lvresult
) STOP 25
351 if (lrw
.neqv
. lvresult
) STOP 26
352 if (lrv
.neqv
. lvresult
) STOP 27
353 if (lrc
.neqv
. lvresult
) STOP 28
356 ! '.neqv.' reductions
365 !$acc parallel num_gangs(ng) copy(lrg)
366 !$acc loop reduction(.neqv.:lrg) gang
368 lrg
= lrg
.neqv
. (array(i
) .ge
. 5)
372 !$acc parallel num_workers(nw) copy(lrw)
373 !$acc loop reduction(.neqv.:lrw) worker
375 lrw
= lrw
.neqv
. (array(i
) .ge
. 5)
379 !$acc parallel vector_length(vl) copy(lrv)
380 !$acc loop reduction(.neqv.:lrv) vector
382 lrv
= lrv
.neqv
. (array(i
) .ge
. 5)
386 !$acc parallel num_gangs(ng) num_workers(nw) vector_length(vl) copy(lrc)
387 !$acc loop reduction(.neqv.:lrc) gang worker vector
389 lrc
= lrc
.neqv
. (array(i
) .ge
. 5)
395 lvresult
= lvresult
.neqv
. (array(i
) .ge
. 5)
398 if (lrg
.neqv
. lvresult
) STOP 29
399 if (lrw
.neqv
. lvresult
) STOP 30
400 if (lrv
.neqv
. lvresult
) STOP 31
401 if (lrc
.neqv
. lvresult
) STOP 32
402 end program reduction_2