Fix gcc.c-torture/execute/ieee/cdivchkf.c on hpux
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-fortran / reduction-6.f90
blob6908d16418ca5e45a65e4af051286d39b080233f
1 ! { dg-do run }
2 ! { dg-additional-options "-cpp" }
4 ! { dg-additional-options "-Wopenacc-parallelism" } for testing/documenting
5 ! aspects of that functionality.
7 program reduction
8 implicit none
10 integer, parameter :: n = 100, n2 = 1000, chunksize = 10
11 integer :: i, gs1, gs2, ws1, ws2, vs1, vs2, cs1, cs2, hs1, hs2
12 integer :: j, red, vred
14 gs1 = 0
15 gs2 = 0
16 ws1 = 0
17 ws2 = 0
18 vs1 = 0
19 vs2 = 0
20 cs1 = 0
21 cs2 = 0
22 hs1 = 0
23 hs2 = 0
25 !$acc parallel num_gangs (1000)
26 !$acc loop reduction(+:gs1, gs2) gang
27 do i = 1, n
28 gs1 = gs1 + 1
29 gs2 = gs2 + 2
30 end do
31 !$acc end parallel
33 !$acc parallel num_workers (4) vector_length (32)
34 ! { dg-warning "region is vector partitioned but does not contain vector partitioned code" "" { target *-*-* } .-1 }
35 !$acc loop reduction(+:ws1, ws2) worker
36 do i = 1, n
37 ws1 = ws1 + 1
38 ws2 = ws2 + 2
39 end do
40 !$acc end parallel
42 !$acc parallel vector_length (32)
43 !$acc loop reduction(+:vs1, vs2) vector
44 do i = 1, n
45 vs1 = vs1 + 1
46 vs2 = vs2 + 2
47 end do
48 !$acc end parallel
50 !$acc parallel num_gangs(8) num_workers(4) vector_length(32)
51 !$acc loop reduction(+:cs1, cs2) gang worker vector
52 do i = 1, n
53 cs1 = cs1 + 1
54 cs2 = cs2 + 2
55 end do
56 !$acc end parallel
58 ! Verify the results on the host
59 do i = 1, n
60 hs1 = hs1 + 1
61 hs2 = hs2 + 2
62 end do
64 if (gs1 .ne. hs1) STOP 1
65 if (gs2 .ne. hs2) STOP 2
67 if (ws1 .ne. hs1) STOP 3
68 if (ws2 .ne. hs2) STOP 4
70 if (vs1 .ne. hs1) STOP 5
71 if (vs2 .ne. hs2) STOP 6
73 if (cs1 .ne. hs1) STOP 7
74 if (cs2 .ne. hs2) STOP 8
76 ! Nested reductions.
78 red = 0
79 vred = 0
81 !$acc parallel num_gangs(10) vector_length(32)
82 !$acc loop reduction(+:red) gang
83 do i = 1, n/chunksize
84 !$acc loop reduction(+:red) vector
85 do j = 1, chunksize
86 red = red + chunksize
87 end do
88 end do
89 !$acc end parallel
91 do i = 1, n/chunksize
92 do j = 1, chunksize
93 vred = vred + chunksize
94 end do
95 end do
97 if (red .ne. vred) STOP 9
98 end program reduction