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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
! RUN: %S/test_symbols.sh %s %t %f18 -fopenmp
! 2.15.1.1 Predetermined rules for associated do-loops index variable
! a) The loop iteration variable(s) in the associated do-loop(s) of a do,
! parallel do, taskloop, or distribute construct is (are) private.
! b) The loop iteration variable in the associated do-loop of a simd construct
! with just one associated do-loop is linear with a linear-step that is the
! increment of the associated do-loop.
! c) The loop iteration variables in the associated do-loops of a simd
! construct with multiple associated do-loops are lastprivate.
! d) A loop iteration variable for a sequential loop in a parallel or task
! generating construct is private in the innermost such construct that
! encloses the loop.
! - TBD
! All the tests assume that the do-loops association for collapse/ordered
! clause has been performed (the number of nested do-loops >= n).
! Rule a)
! TODO: nested constructs (k should be private too)
!DEF: /test_do (Subroutine) Subprogram
subroutine test_do
implicit none
!DEF: /test_do/a ObjectEntity REAL(4)
real a(20,20,20)
!DEF: /test_do/i ObjectEntity INTEGER(4)
!DEF: /test_do/j ObjectEntity INTEGER(4)
!DEF: /test_do/k ObjectEntity INTEGER(4)
integer i, j, k
!$omp parallel
!REF: /test_do/i
i = 99
!$omp do collapse(2)
!DEF: /test_do/Block1/Block1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
do i=1,5
!DEF: /test_do/Block1/Block1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
do j=6,10
!REF: /test_do/a
a(1,1,1) = 0.
!DEF: /test_do/Block1/k (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
do k=11,15
!REF: /test_do/a
!REF: /test_do/Block1/k
!REF: /test_do/Block1/Block1/j
!REF: /test_do/Block1/Block1/i
a(k,j,i) = 1.
end do
end do
end do
!$omp end parallel
end subroutine test_do
! Rule a)
!DEF: /test_pardo (Subroutine) Subprogram
subroutine test_pardo
implicit none
!DEF: /test_pardo/a ObjectEntity REAL(4)
real a(20,20,20)
!DEF: /test_pardo/i ObjectEntity INTEGER(4)
!DEF: /test_pardo/j ObjectEntity INTEGER(4)
!DEF: /test_pardo/k ObjectEntity INTEGER(4)
integer i, j, k
!$omp parallel do collapse(2) private(k) ordered(2)
!DEF: /test_pardo/Block1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
do i=1,5
!DEF: /test_pardo/Block1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
do j=6,10
!REF: /test_pardo/a
a(1,1,1) = 0.
!DEF: /test_pardo/Block1/k (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
do k=11,15
!REF: /test_pardo/a
!REF: /test_pardo/Block1/k
!REF: /test_pardo/Block1/j
!REF: /test_pardo/Block1/i
a(k,j,i) = 1.
end do
end do
end do
end subroutine test_pardo
! Rule a)
!DEF: /test_taskloop (Subroutine) Subprogram
subroutine test_taskloop
implicit none
!DEF: /test_taskloop/a ObjectEntity REAL(4)
real a(5,5)
!DEF: /test_taskloop/i ObjectEntity INTEGER(4)
!DEF: /test_taskloop/j ObjectEntity INTEGER(4)
integer i, j
!$omp taskloop private(j)
!DEF: /test_taskloop/Block1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
do i=1,5
!DEF: /test_taskloop/Block1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
!REF: /test_taskloop/Block1/i
do j=1,i
!REF: /test_taskloop/a
!REF: /test_taskloop/Block1/j
!REF: /test_taskloop/Block1/i
a(j,i) = 3.14
end do
end do
!$omp end taskloop
end subroutine test_taskloop
! Rule a); OpenMP 4.5 Examples teams.2.f90
! TODO: reduction; data-mapping attributes
!DEF: /dotprod (Subroutine) Subprogram
!DEF: /dotprod/b ObjectEntity REAL(4)
!DEF: /dotprod/c ObjectEntity REAL(4)
!DEF: /dotprod/n ObjectEntity INTEGER(4)
!DEF: /dotprod/block_size ObjectEntity INTEGER(4)
!DEF: /dotprod/num_teams ObjectEntity INTEGER(4)
!DEF: /dotprod/block_threads ObjectEntity INTEGER(4)
subroutine dotprod (b, c, n, block_size, num_teams, block_threads)
implicit none
!REF: /dotprod/n
integer n
!REF: /dotprod/b
!REF: /dotprod/n
!REF: /dotprod/c
!DEF: /dotprod/sum ObjectEntity REAL(4)
real b(n), c(n), sum
!REF: /dotprod/block_size
!REF: /dotprod/num_teams
!REF: /dotprod/block_threads
!DEF: /dotprod/i ObjectEntity INTEGER(4)
!DEF: /dotprod/i0 ObjectEntity INTEGER(4)
integer block_size, num_teams, block_threads, i, i0
!REF: /dotprod/sum
sum = 0.0e0
!$omp target map(to:b,c) map(tofrom:sum)
!$omp teams num_teams(num_teams) thread_limit(block_threads) reduction(+:sum)
!$omp distribute
!DEF: /dotprod/Block1/Block1/Block1/i0 (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
!REF: /dotprod/n
!REF: /dotprod/block_size
do i0=1,n,block_size
!$omp parallel do reduction(+:sum)
!DEF: /dotprod/Block1/Block1/Block1/Block1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
!REF: /dotprod/Block1/Block1/Block1/i0
!DEF: /dotprod/min ELEMENTAL, INTRINSIC, PURE (Function) ProcEntity
!REF: /dotprod/block_size
!REF: /dotprod/n
do i=i0,min(i0+block_size, n)
!DEF: /dotprod/Block1/Block1/Block1/Block1/sum (OmpReduction) HostAssoc REAL(4)
!REF: /dotprod/b
!REF: /dotprod/Block1/Block1/Block1/Block1/i
!REF: /dotprod/c
sum = sum+b(i)*c(i)
end do
end do
!$omp end teams
!$omp end target
!REF: /dotprod/sum
print *, sum
end subroutine dotprod
! Rule b)
! TODO: nested constructs (j, k should be private too)
!DEF: /test_simd (Subroutine) Subprogram
subroutine test_simd
implicit none
!DEF: /test_simd/a ObjectEntity REAL(4)
real a(20,20,20)
!DEF: /test_simd/i ObjectEntity INTEGER(4)
!DEF: /test_simd/j ObjectEntity INTEGER(4)
!DEF: /test_simd/k ObjectEntity INTEGER(4)
integer i, j, k
!$omp parallel do simd
!DEF: /test_simd/Block1/i (OmpLinear, OmpPreDetermined) HostAssoc INTEGER(4)
do i=1,5
!DEF: /test_simd/Block1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
do j=6,10
!DEF: /test_simd/Block1/k (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
do k=11,15
!REF: /test_simd/a
!REF: /test_simd/Block1/k
!REF: /test_simd/Block1/j
!REF: /test_simd/Block1/i
a(k,j,i) = 3.14
end do
end do
end do
end subroutine test_simd
! Rule c)
!DEF: /test_simd_multi (Subroutine) Subprogram
subroutine test_simd_multi
implicit none
!DEF: /test_simd_multi/a ObjectEntity REAL(4)
real a(20,20,20)
!DEF: /test_simd_multi/i ObjectEntity INTEGER(4)
!DEF: /test_simd_multi/j ObjectEntity INTEGER(4)
!DEF: /test_simd_multi/k ObjectEntity INTEGER(4)
integer i, j, k
!$omp parallel do simd collapse(3)
!DEF: /test_simd_multi/Block1/i (OmpLastPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
do i=1,5
!DEF: /test_simd_multi/Block1/j (OmpLastPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
do j=6,10
!DEF: /test_simd_multi/Block1/k (OmpLastPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
do k=11,15
!REF: /test_simd_multi/a
!REF: /test_simd_multi/Block1/k
!REF: /test_simd_multi/Block1/j
!REF: /test_simd_multi/Block1/i
a(k,j,i) = 3.14
end do
end do
end do
end subroutine test_simd_multi
! Rule d)
!DEF: /test_seq_loop (Subroutine) Subprogram
subroutine test_seq_loop
implicit none
!DEF: /test_seq_loop/i ObjectEntity INTEGER(4)
!DEF: /test_seq_loop/j ObjectEntity INTEGER(4)
integer i, j
!REF: /test_seq_loop/i
i = -1
!REF: /test_seq_loop/j
j = -1
!$omp parallel
!REF: /test_seq_loop/i
!REF: /test_seq_loop/j
print *, i, j
!$omp parallel
!REF: /test_seq_loop/i
!DEF: /test_seq_loop/Block1/Block1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
print *, i, j
!$omp do
!DEF: /test_seq_loop/Block1/Block1/Block1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
do i=1,10
!REF: /test_seq_loop/Block1/Block1/j
do j=1,10
end do
end do
!REF: /test_seq_loop/i
!REF: /test_seq_loop/Block1/Block1/j
print *, i, j
!$omp end parallel
!REF: /test_seq_loop/i
!REF: /test_seq_loop/j
print *, i, j
!$omp end parallel
!REF: /test_seq_loop/i
!REF: /test_seq_loop/j
print *, i, j
end subroutine test_seq_loop
|