1! RUN: %python %S/../test_symbols.py %s %flang_fc1 -fopenmp 2 3! 2.15.1.1 Predetermined rules for associated do-loops index variable 4! a) The loop iteration variable(s) in the associated do-loop(s) of a do, 5! parallel do, taskloop, or distribute construct is (are) private. 6! b) The loop iteration variable in the associated do-loop of a simd construct 7! with just one associated do-loop is linear with a linear-step that is the 8! increment of the associated do-loop. 9! c) The loop iteration variables in the associated do-loops of a simd 10! construct with multiple associated do-loops are lastprivate. 11! d) A loop iteration variable for a sequential loop in a parallel or task 12! generating construct is private in the innermost such construct that 13! encloses the loop. 14! - TBD 15 16! All the tests assume that the do-loops association for collapse/ordered 17! clause has been performed (the number of nested do-loops >= n). 18 19! Rule a) 20! TODO: nested constructs (k should be private too) 21!DEF: /test_do (Subroutine) Subprogram 22subroutine test_do 23 implicit none 24 !DEF: /test_do/a ObjectEntity REAL(4) 25 real a(20,20,20) 26 !DEF: /test_do/i ObjectEntity INTEGER(4) 27 !DEF: /test_do/j ObjectEntity INTEGER(4) 28 !DEF: /test_do/k ObjectEntity INTEGER(4) 29 integer i, j, k 30!$omp parallel 31 !DEF: /test_do/OtherConstruct1/i HostAssoc INTEGER(4) 32 i = 99 33!$omp do collapse(2) 34 !DEF: /test_do/OtherConstruct1/OtherConstruct1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 35 do i=1,5 36 !DEF: /test_do/OtherConstruct1/OtherConstruct1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 37 do j=6,10 38 !DEF: /test_do/OtherConstruct1/a HostAssoc REAL(4) 39 a(1,1,1) = 0. 40 !DEF: /test_do/OtherConstruct1/k (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 41 do k=11,15 42 !REF: /test_do/OtherConstruct1/a 43 !REF: /test_do/OtherConstruct1/k 44 !REF: /test_do/OtherConstruct1/OtherConstruct1/j 45 !REF: /test_do/OtherConstruct1/OtherConstruct1/i 46 a(k,j,i) = 1. 47 end do 48 end do 49 end do 50!$omp end parallel 51end subroutine test_do 52 53! Rule a) 54!DEF: /test_pardo (Subroutine) Subprogram 55subroutine test_pardo 56 implicit none 57 !DEF: /test_pardo/a ObjectEntity REAL(4) 58 real a(20,20,20) 59 !DEF: /test_pardo/i ObjectEntity INTEGER(4) 60 !DEF: /test_pardo/j ObjectEntity INTEGER(4) 61 !DEF: /test_pardo/k ObjectEntity INTEGER(4) 62 integer i, j, k 63!$omp parallel do collapse(2) private(k) ordered(2) 64 !DEF: /test_pardo/OtherConstruct1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 65 do i=1,5 66 !DEF: /test_pardo/OtherConstruct1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 67 do j=6,10 68 !DEF: /test_pardo/OtherConstruct1/a HostAssoc REAL(4) 69 a(1,1,1) = 0. 70 !DEF: /test_pardo/OtherConstruct1/k (OmpPrivate) HostAssoc INTEGER(4) 71 do k=11,15 72 !REF: /test_pardo/OtherConstruct1/a 73 !REF: /test_pardo/OtherConstruct1/k 74 !REF: /test_pardo/OtherConstruct1/j 75 !REF: /test_pardo/OtherConstruct1/i 76 a(k,j,i) = 1. 77 end do 78 end do 79 end do 80end subroutine test_pardo 81 82! Rule a) 83!DEF: /test_taskloop (Subroutine) Subprogram 84subroutine test_taskloop 85 implicit none 86 !DEF: /test_taskloop/a ObjectEntity REAL(4) 87 real a(5,5) 88 !DEF: /test_taskloop/i ObjectEntity INTEGER(4) 89 !DEF: /test_taskloop/j ObjectEntity INTEGER(4) 90 integer i, j 91!$omp taskloop private(j) 92 !DEF: /test_taskloop/OtherConstruct1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 93 do i=1,5 94 !DEF: /test_taskloop/OtherConstruct1/j (OmpPrivate) HostAssoc INTEGER(4) 95 !REF: /test_taskloop/OtherConstruct1/i 96 do j=1,i 97 !DEF: /test_taskloop/OtherConstruct1/a (OmpFirstPrivate, OmpImplicit) HostAssoc REAL(4) 98 !REF: /test_taskloop/OtherConstruct1/j 99 !REF: /test_taskloop/OtherConstruct1/i 100 a(j,i) = 3.14 101 end do 102 end do 103!$omp end taskloop 104end subroutine test_taskloop 105 106! Rule a); OpenMP 4.5 Examples teams.2.f90 107! TODO: reduction; data-mapping attributes 108!DEF: /dotprod (Subroutine) Subprogram 109!DEF: /dotprod/b (OmpMapTo) ObjectEntity REAL(4) 110!DEF: /dotprod/c (OmpMapTo) ObjectEntity REAL(4) 111!DEF: /dotprod/n ObjectEntity INTEGER(4) 112!DEF: /dotprod/block_size ObjectEntity INTEGER(4) 113!DEF: /dotprod/num_teams ObjectEntity INTEGER(4) 114!DEF: /dotprod/block_threads ObjectEntity INTEGER(4) 115subroutine dotprod (b, c, n, block_size, num_teams, block_threads) 116 implicit none 117 !REF: /dotprod/n 118 integer n 119 !REF: /dotprod/b 120 !REF: /dotprod/n 121 !REF: /dotprod/c 122 !DEF: /dotprod/sum (OmpMapToFrom) ObjectEntity REAL(4) 123 real b(n), c(n), sum 124 !REF: /dotprod/block_size 125 !REF: /dotprod/num_teams 126 !REF: /dotprod/block_threads 127 !DEF: /dotprod/i ObjectEntity INTEGER(4) 128 !DEF: /dotprod/i0 ObjectEntity INTEGER(4) 129 integer block_size, num_teams, block_threads, i, i0 130 !REF: /dotprod/sum 131 sum = 0.0e0 132!$omp target map(to:b,c) map(tofrom:sum) 133!$omp teams num_teams(num_teams) thread_limit(block_threads) reduction(+: sum& 134!$OMP&) 135!$omp distribute 136 !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/i0 (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 137 !REF: /dotprod/n 138 !REF: /dotprod/block_size 139 do i0=1,n,block_size 140!$omp parallel do reduction(+: sum) 141 !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/OtherConstruct1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 142 !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/OtherConstruct1/i0 HostAssoc INTEGER(4) 143 !DEF: /dotprod/min ELEMENTAL, INTRINSIC, PURE (Function) ProcEntity 144 !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/OtherConstruct1/block_size HostAssoc INTEGER(4) 145 !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/OtherConstruct1/n HostAssoc INTEGER(4) 146 do i=i0,min(i0+block_size, n) 147 !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/OtherConstruct1/sum (OmpReduction) HostAssoc REAL(4) 148 !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/OtherConstruct1/b HostAssoc REAL(4) 149 !REF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/OtherConstruct1/i 150 !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/OtherConstruct1/c HostAssoc REAL(4) 151 sum = sum+b(i)*c(i) 152 end do 153 end do 154!$omp end teams 155!$omp end target 156 !REF: /dotprod/sum 157 print *, sum 158end subroutine dotprod 159 160! Rule b) 161! TODO: nested constructs (j, k should be private too) 162!DEF: /test_simd (Subroutine) Subprogram 163subroutine test_simd 164 implicit none 165 !DEF: /test_simd/a ObjectEntity REAL(4) 166 real a(20,20,20) 167 !DEF: /test_simd/i ObjectEntity INTEGER(4) 168 !DEF: /test_simd/j ObjectEntity INTEGER(4) 169 !DEF: /test_simd/k ObjectEntity INTEGER(4) 170 integer i, j, k 171!$omp parallel do simd 172 !DEF: /test_simd/OtherConstruct1/i (OmpLinear, OmpPreDetermined) HostAssoc INTEGER(4) 173 do i=1,5 174 !DEF: /test_simd/OtherConstruct1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 175 do j=6,10 176 !DEF: /test_simd/OtherConstruct1/k (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 177 do k=11,15 178 !DEF: /test_simd/OtherConstruct1/a HostAssoc REAL(4) 179 !REF: /test_simd/OtherConstruct1/k 180 !REF: /test_simd/OtherConstruct1/j 181 !REF: /test_simd/OtherConstruct1/i 182 a(k,j,i) = 3.14 183 end do 184 end do 185 end do 186end subroutine test_simd 187 188! Rule c) 189!DEF: /test_simd_multi (Subroutine) Subprogram 190subroutine test_simd_multi 191 implicit none 192 !DEF: /test_simd_multi/a ObjectEntity REAL(4) 193 real a(20,20,20) 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) 197 integer i, j, k 198!$omp parallel do simd collapse(3) 199 !DEF: /test_simd_multi/OtherConstruct1/i (OmpLastPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 200 do i=1,5 201 !DEF: /test_simd_multi/OtherConstruct1/j (OmpLastPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 202 do j=6,10 203 !DEF: /test_simd_multi/OtherConstruct1/k (OmpLastPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 204 do k=11,15 205 !DEF: /test_simd_multi/OtherConstruct1/a HostAssoc REAL(4) 206 !REF: /test_simd_multi/OtherConstruct1/k 207 !REF: /test_simd_multi/OtherConstruct1/j 208 !REF: /test_simd_multi/OtherConstruct1/i 209 a(k,j,i) = 3.14 210 end do 211 end do 212 end do 213end subroutine test_simd_multi 214 215! Rule d) 216!DEF: /test_seq_loop (Subroutine) Subprogram 217subroutine test_seq_loop 218 implicit none 219 !DEF: /test_seq_loop/i ObjectEntity INTEGER(4) 220 !DEF: /test_seq_loop/j ObjectEntity INTEGER(4) 221 integer i, j 222 !REF: /test_seq_loop/i 223 i = -1 224 !REF: /test_seq_loop/j 225 j = -1 226 !$omp parallel 227 !DEF: /test_seq_loop/OtherConstruct1/i HostAssoc INTEGER(4) 228 !DEF: /test_seq_loop/OtherConstruct1/j HostAssoc INTEGER(4) 229 print *, i, j 230 !$omp parallel 231 !DEF: /test_seq_loop/OtherConstruct1/OtherConstruct1/i HostAssoc INTEGER(4) 232 !DEF: /test_seq_loop/OtherConstruct1/OtherConstruct1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 233 print *, i, j 234 !$omp do 235 !DEF: /test_seq_loop/OtherConstruct1/OtherConstruct1/OtherConstruct1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 236 do i=1,10 237 !REF: /test_seq_loop/OtherConstruct1/OtherConstruct1/j 238 do j=1,10 239 end do 240 end do 241 !REF: /test_seq_loop/OtherConstruct1/OtherConstruct1/i 242 !REF: /test_seq_loop/OtherConstruct1/OtherConstruct1/j 243 print *, i, j 244 !$omp end parallel 245 !REF: /test_seq_loop/OtherConstruct1/i 246 !REF: /test_seq_loop/OtherConstruct1/j 247 print *, i, j 248 !$omp end parallel 249 !REF: /test_seq_loop/i 250 !REF: /test_seq_loop/j 251 print *, i, j 252end subroutine test_seq_loop 253