1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
! { dg-do run }
program collapse3
call test1
call test2 (2, 6, -2, 4, 13, 18)
call test3 (2, 6, -2, 4, 13, 18, 1, 1, 1)
call test4
call test5 (2, 6, -2, 4, 13, 18)
call test6 (2, 6, -2, 4, 13, 18, 1, 1, 1)
contains
subroutine test1
integer :: i, j, k, a(1:7, -3:5, 12:19), m
logical :: l
l = .false.
a(:, :, :) = 0
!$omp parallel do collapse (3) lastprivate (i, j, k, m) reduction (.or.:l)
do i = 2, 6
do j = -2, 4
do k = 13, 18
l = l.or.i.lt.2.or.i.gt.6.or.j.lt.-2.or.j.gt.4
l = l.or.k.lt.13.or.k.gt.18
if (.not.l) a(i, j, k) = a(i, j, k) + 1
m = i * 100 + j * 10 + k
end do
end do
end do
if (i.ne.7.or.j.ne.5.or.k.ne.19) call abort
if (m.ne.(600+40+18)) call abort
do i = 1, 7
do j = -3, 5
do k = 12, 19
if (i.eq.1.or.i.eq.7.or.j.eq.-3.or.j.eq.5.or.k.eq.12.or.k.eq.19) then
if (a(i, j, k).ne.0) print *, i, j, k
else
if (a(i, j, k).ne.1) print *, 'kk', i, j, k, a(i, j, k)
end if
end do
end do
end do
end subroutine test1
subroutine test2(v1, v2, v3, v4, v5, v6)
integer :: i, j, k, a(1:7, -3:5, 12:19), m
integer :: v1, v2, v3, v4, v5, v6
logical :: l
l = .false.
a(:, :, :) = 0
!$omp parallel do collapse (3) lastprivate (i, j, k, m) reduction (.or.:l)
do i = v1, v2
do j = v3, v4
do k = v5, v6
l = l.or.i.lt.2.or.i.gt.6.or.j.lt.-2.or.j.gt.4
l = l.or.k.lt.13.or.k.gt.18
if (.not.l) a(i, j, k) = a(i, j, k) + 1
m = i * 100 + j * 10 + k
end do
end do
end do
if (i.ne.7.or.j.ne.5.or.k.ne.19) call abort
if (m.ne.(600+40+18)) call abort
do i = 1, 7
do j = -3, 5
do k = 12, 19
if (i.eq.1.or.i.eq.7.or.j.eq.-3.or.j.eq.5.or.k.eq.12.or.k.eq.19) then
if (a(i, j, k).ne.0) print *, i, j, k
else
if (a(i, j, k).ne.1) print *, 'kk', i, j, k, a(i, j, k)
end if
end do
end do
end do
end subroutine test2
subroutine test3(v1, v2, v3, v4, v5, v6, v7, v8, v9)
integer :: i, j, k, a(1:7, -3:5, 12:19), m
integer :: v1, v2, v3, v4, v5, v6, v7, v8, v9
logical :: l
l = .false.
a(:, :, :) = 0
!$omp parallel do collapse (3) lastprivate (i, j, k, m) reduction (.or.:l)
do i = v1, v2, v7
do j = v3, v4, v8
do k = v5, v6, v9
l = l.or.i.lt.2.or.i.gt.6.or.j.lt.-2.or.j.gt.4
l = l.or.k.lt.13.or.k.gt.18
if (.not.l) a(i, j, k) = a(i, j, k) + 1
m = i * 100 + j * 10 + k
end do
end do
end do
if (i.ne.7.or.j.ne.5.or.k.ne.19) call abort
if (m.ne.(600+40+18)) call abort
do i = 1, 7
do j = -3, 5
do k = 12, 19
if (i.eq.1.or.i.eq.7.or.j.eq.-3.or.j.eq.5.or.k.eq.12.or.k.eq.19) then
if (a(i, j, k).ne.0) print *, i, j, k
else
if (a(i, j, k).ne.1) print *, 'kk', i, j, k, a(i, j, k)
end if
end do
end do
end do
end subroutine test3
subroutine test4
integer :: i, j, k, a(1:7, -3:5, 12:19), m
logical :: l
l = .false.
a(:, :, :) = 0
!$omp parallel do collapse (3) lastprivate (i, j, k, m) reduction (.or.:l) &
!$omp& schedule (dynamic, 5)
do i = 2, 6
do j = -2, 4
do k = 13, 18
l = l.or.i.lt.2.or.i.gt.6.or.j.lt.-2.or.j.gt.4
l = l.or.k.lt.13.or.k.gt.18
if (.not.l) a(i, j, k) = a(i, j, k) + 1
m = i * 100 + j * 10 + k
end do
end do
end do
if (i.ne.7.or.j.ne.5.or.k.ne.19) call abort
if (m.ne.(600+40+18)) call abort
do i = 1, 7
do j = -3, 5
do k = 12, 19
if (i.eq.1.or.i.eq.7.or.j.eq.-3.or.j.eq.5.or.k.eq.12.or.k.eq.19) then
if (a(i, j, k).ne.0) print *, i, j, k
else
if (a(i, j, k).ne.1) print *, 'kk', i, j, k, a(i, j, k)
end if
end do
end do
end do
end subroutine test4
subroutine test5(v1, v2, v3, v4, v5, v6)
integer :: i, j, k, a(1:7, -3:5, 12:19), m
integer :: v1, v2, v3, v4, v5, v6
logical :: l
l = .false.
a(:, :, :) = 0
!$omp parallel do collapse (3) lastprivate (i, j, k, m) reduction (.or.:l) &
!$omp & schedule (guided)
do i = v1, v2
do j = v3, v4
do k = v5, v6
l = l.or.i.lt.2.or.i.gt.6.or.j.lt.-2.or.j.gt.4
l = l.or.k.lt.13.or.k.gt.18
if (.not.l) a(i, j, k) = a(i, j, k) + 1
m = i * 100 + j * 10 + k
end do
end do
end do
if (i.ne.7.or.j.ne.5.or.k.ne.19) call abort
if (m.ne.(600+40+18)) call abort
do i = 1, 7
do j = -3, 5
do k = 12, 19
if (i.eq.1.or.i.eq.7.or.j.eq.-3.or.j.eq.5.or.k.eq.12.or.k.eq.19) then
if (a(i, j, k).ne.0) print *, i, j, k
else
if (a(i, j, k).ne.1) print *, 'kk', i, j, k, a(i, j, k)
end if
end do
end do
end do
end subroutine test5
subroutine test6(v1, v2, v3, v4, v5, v6, v7, v8, v9)
integer :: i, j, k, a(1:7, -3:5, 12:19), m
integer :: v1, v2, v3, v4, v5, v6, v7, v8, v9
logical :: l
l = .false.
a(:, :, :) = 0
!$omp parallel do collapse (3) lastprivate (i, j, k, m) reduction (.or.:l) &
!$omp & schedule (dynamic)
do i = v1, v2, v7
do j = v3, v4, v8
do k = v5, v6, v9
l = l.or.i.lt.2.or.i.gt.6.or.j.lt.-2.or.j.gt.4
l = l.or.k.lt.13.or.k.gt.18
if (.not.l) a(i, j, k) = a(i, j, k) + 1
m = i * 100 + j * 10 + k
end do
end do
end do
if (i.ne.7.or.j.ne.5.or.k.ne.19) call abort
if (m.ne.(600+40+18)) call abort
do i = 1, 7
do j = -3, 5
do k = 12, 19
if (i.eq.1.or.i.eq.7.or.j.eq.-3.or.j.eq.5.or.k.eq.12.or.k.eq.19) then
if (a(i, j, k).ne.0) print *, i, j, k
else
if (a(i, j, k).ne.1) print *, 'kk', i, j, k, a(i, j, k)
end if
end do
end do
end do
end subroutine test6
end program collapse3
|