1 ! RUN: %S/test_symbols.sh %s %t %flang_fc1 -fopenmp
4 ! 2.15.1.1 Predetermined rules for associated do-loops index variable
5 ! a) The loop iteration variable(s) in the associated do-loop(s) of a do,
6 ! parallel do, taskloop, or distribute construct is (are) private.
7 ! b) The loop iteration variable in the associated do-loop of a simd construct
8 ! with just one associated do-loop is linear with a linear-step that is the
9 ! increment of the associated do-loop.
10 ! c) The loop iteration variables in the associated do-loops of a simd
11 ! construct with multiple associated do-loops are lastprivate.
12 ! d) A loop iteration variable for a sequential loop in a parallel or task
13 ! generating construct is private in the innermost such construct that
17 ! All the tests assume that the do-loops association for collapse/ordered
18 ! clause has been performed (the number of nested do-loops >= n).
21 ! TODO: nested constructs (k should be private too)
22 !DEF: /test_do (Subroutine) Subprogram
25 !DEF: /test_do/a ObjectEntity REAL(4)
27 !DEF: /test_do/i ObjectEntity INTEGER(4)
28 !DEF: /test_do/j ObjectEntity INTEGER(4)
29 !DEF: /test_do/k ObjectEntity INTEGER(4)
35 !DEF: /test_do/Block1/Block1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
37 !DEF: /test_do/Block1/Block1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
41 !DEF: /test_do/Block1/k (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
44 !REF: /test_do/Block1/k
45 !REF: /test_do/Block1/Block1/j
46 !REF: /test_do/Block1/Block1/i
52 end subroutine test_do
55 !DEF: /test_pardo (Subroutine) Subprogram
58 !DEF: /test_pardo/a ObjectEntity REAL(4)
60 !DEF: /test_pardo/i ObjectEntity INTEGER(4)
61 !DEF: /test_pardo/j ObjectEntity INTEGER(4)
62 !DEF: /test_pardo/k ObjectEntity INTEGER(4)
64 !$omp parallel do collapse(2) private(k) ordered(2)
65 !DEF: /test_pardo/Block1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
67 !DEF: /test_pardo/Block1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
71 !DEF: /test_pardo/Block1/k (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
74 !REF: /test_pardo/Block1/k
75 !REF: /test_pardo/Block1/j
76 !REF: /test_pardo/Block1/i
81 end subroutine test_pardo
84 !DEF: /test_taskloop (Subroutine) Subprogram
85 subroutine test_taskloop
87 !DEF: /test_taskloop/a ObjectEntity REAL(4)
89 !DEF: /test_taskloop/i ObjectEntity INTEGER(4)
90 !DEF: /test_taskloop/j ObjectEntity INTEGER(4)
92 !$omp taskloop private(j)
93 !DEF: /test_taskloop/Block1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
95 !DEF: /test_taskloop/Block1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
96 !REF: /test_taskloop/Block1/i
98 !REF: /test_taskloop/a
99 !REF: /test_taskloop/Block1/j
100 !REF: /test_taskloop/Block1/i
105 end subroutine test_taskloop
107 ! Rule a); OpenMP 4.5 Examples teams.2.f90
108 ! TODO: reduction; data-mapping attributes
109 !DEF: /dotprod (Subroutine) Subprogram
110 !DEF: /dotprod/b ObjectEntity REAL(4)
111 !DEF: /dotprod/c ObjectEntity REAL(4)
112 !DEF: /dotprod/n ObjectEntity INTEGER(4)
113 !DEF: /dotprod/block_size ObjectEntity INTEGER(4)
114 !DEF: /dotprod/num_teams ObjectEntity INTEGER(4)
115 !DEF: /dotprod/block_threads ObjectEntity INTEGER(4)
116 subroutine dotprod (b
, c
, n
, block_size
, num_teams
, block_threads
)
123 !DEF: /dotprod/sum ObjectEntity REAL(4)
125 !REF: /dotprod/block_size
126 !REF: /dotprod/num_teams
127 !REF: /dotprod/block_threads
128 !DEF: /dotprod/i ObjectEntity INTEGER(4)
129 !DEF: /dotprod/i0 ObjectEntity INTEGER(4)
130 integer block_size
, num_teams
, block_threads
, i
, i0
133 !$omp target map(to:b,c) map(tofrom:sum)
134 !$omp teams num_teams(num_teams) thread_limit(block_threads) reduction(+:sum)
136 !DEF: /dotprod/Block1/Block1/Block1/i0 (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
138 !REF: /dotprod/block_size
140 !$omp parallel do reduction(+:sum)
141 !DEF: /dotprod/Block1/Block1/Block1/Block1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
142 !REF: /dotprod/Block1/Block1/Block1/i0
143 !DEF: /dotprod/min ELEMENTAL, INTRINSIC, PURE (Function) ProcEntity
144 !REF: /dotprod/block_size
146 do i
=i0
,min(i0
+block_size
, n
)
147 !DEF: /dotprod/Block1/Block1/Block1/Block1/sum (OmpReduction) HostAssoc REAL(4)
149 !REF: /dotprod/Block1/Block1/Block1/Block1/i
158 end subroutine dotprod
161 ! TODO: nested constructs (j, k should be private too)
162 !DEF: /test_simd (Subroutine) Subprogram
165 !DEF: /test_simd/a ObjectEntity REAL(4)
167 !DEF: /test_simd/i ObjectEntity INTEGER(4)
168 !DEF: /test_simd/j ObjectEntity INTEGER(4)
169 !DEF: /test_simd/k ObjectEntity INTEGER(4)
171 !$omp parallel do simd
172 !DEF: /test_simd/Block1/i (OmpLinear, OmpPreDetermined) HostAssoc INTEGER(4)
174 !DEF: /test_simd/Block1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
176 !DEF: /test_simd/Block1/k (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
179 !REF: /test_simd/Block1/k
180 !REF: /test_simd/Block1/j
181 !REF: /test_simd/Block1/i
186 end subroutine test_simd
189 !DEF: /test_simd_multi (Subroutine) Subprogram
190 subroutine test_simd_multi
192 !DEF: /test_simd_multi/a ObjectEntity REAL(4)
194 !DEF: /test_simd_multi/i ObjectEntity INTEGER(4)
195 !DEF: /test_simd_multi/j ObjectEntity INTEGER(4)
196 !DEF: /test_simd_multi/k ObjectEntity INTEGER(4)
198 !$omp parallel do simd collapse(3)
199 !DEF: /test_simd_multi/Block1/i (OmpLastPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
201 !DEF: /test_simd_multi/Block1/j (OmpLastPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
203 !DEF: /test_simd_multi/Block1/k (OmpLastPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
205 !REF: /test_simd_multi/a
206 !REF: /test_simd_multi/Block1/k
207 !REF: /test_simd_multi/Block1/j
208 !REF: /test_simd_multi/Block1/i
213 end subroutine test_simd_multi
216 !DEF: /test_seq_loop (Subroutine) Subprogram
217 subroutine test_seq_loop
219 !DEF: /test_seq_loop/i ObjectEntity INTEGER(4)
220 !DEF: /test_seq_loop/j ObjectEntity INTEGER(4)
222 !REF: /test_seq_loop/i
224 !REF: /test_seq_loop/j
227 !REF: /test_seq_loop/i
228 !REF: /test_seq_loop/j
231 !REF: /test_seq_loop/i
232 !DEF: /test_seq_loop/Block1/Block1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
235 !DEF: /test_seq_loop/Block1/Block1/Block1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
237 !REF: /test_seq_loop/Block1/Block1/j
241 !REF: /test_seq_loop/i
242 !REF: /test_seq_loop/Block1/Block1/j
245 !REF: /test_seq_loop/i
246 !REF: /test_seq_loop/j
249 !REF: /test_seq_loop/i
250 !REF: /test_seq_loop/j
252 end subroutine test_seq_loop