1! RUN: %S/test_symbols.sh %s %t %f18 -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 !REF: /test_do/i 32 i = 99 33!$omp do collapse(2) 34 !DEF: /test_do/Block1/Block1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 35 do i=1,5 36 !DEF: /test_do/Block1/Block1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 37 do j=6,10 38 !REF: /test_do/a 39 a(1,1,1) = 0. 40 !DEF: /test_do/Block1/k (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 41 do k=11,15 42 !REF: /test_do/a 43 !REF: /test_do/Block1/k 44 !REF: /test_do/Block1/Block1/j 45 !REF: /test_do/Block1/Block1/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/Block1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 65 do i=1,5 66 !DEF: /test_pardo/Block1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 67 do j=6,10 68 !REF: /test_pardo/a 69 a(1,1,1) = 0. 70 !DEF: /test_pardo/Block1/k (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 71 do k=11,15 72 !REF: /test_pardo/a 73 !REF: /test_pardo/Block1/k 74 !REF: /test_pardo/Block1/j 75 !REF: /test_pardo/Block1/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/Block1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 93 do i=1,5 94 !DEF: /test_taskloop/Block1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 95 !REF: /test_taskloop/Block1/i 96 do j=1,i 97 !REF: /test_taskloop/a 98 !REF: /test_taskloop/Block1/j 99 !REF: /test_taskloop/Block1/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 ObjectEntity REAL(4) 110!DEF: /dotprod/c 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 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 distribute 135 !DEF: /dotprod/Block1/Block1/Block1/i0 (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 136 !REF: /dotprod/n 137 !REF: /dotprod/block_size 138 do i0=1,n,block_size 139!$omp parallel do reduction(+:sum) 140 !DEF: /dotprod/Block1/Block1/Block1/Block1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 141 !REF: /dotprod/Block1/Block1/Block1/i0 142 !DEF: /dotprod/min INTRINSIC (Function) ProcEntity 143 !REF: /dotprod/block_size 144 !REF: /dotprod/n 145 do i=i0,min(i0+block_size, n) 146 !REF: /dotprod/sum 147 !REF: /dotprod/b 148 !REF: /dotprod/Block1/Block1/Block1/Block1/i 149 !REF: /dotprod/c 150 sum = sum+b(i)*c(i) 151 end do 152 end do 153!$omp end teams 154!$omp end target 155 !REF: /dotprod/sum 156 print *, sum 157end subroutine dotprod 158 159! Rule b) 160! TODO: nested constructs (j, k should be private too) 161!DEF: /test_simd (Subroutine) Subprogram 162subroutine test_simd 163 implicit none 164 !DEF: /test_simd/a ObjectEntity REAL(4) 165 real a(20,20,20) 166 !DEF: /test_simd/i ObjectEntity INTEGER(4) 167 !DEF: /test_simd/j ObjectEntity INTEGER(4) 168 !DEF: /test_simd/k ObjectEntity INTEGER(4) 169 integer i, j, k 170!$omp parallel do simd 171 !DEF: /test_simd/Block1/i (OmpLinear, OmpPreDetermined) HostAssoc INTEGER(4) 172 do i=1,5 173 !DEF: /test_simd/Block1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 174 do j=6,10 175 !DEF: /test_simd/Block1/k (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 176 do k=11,15 177 !REF: /test_simd/a 178 !REF: /test_simd/Block1/k 179 !REF: /test_simd/Block1/j 180 !REF: /test_simd/Block1/i 181 a(k,j,i) = 3.14 182 end do 183 end do 184 end do 185end subroutine test_simd 186 187! Rule c) 188!DEF: /test_simd_multi (Subroutine) Subprogram 189subroutine test_simd_multi 190 implicit none 191 !DEF: /test_simd_multi/a ObjectEntity REAL(4) 192 real a(20,20,20) 193 !DEF: /test_simd_multi/i ObjectEntity INTEGER(4) 194 !DEF: /test_simd_multi/j ObjectEntity INTEGER(4) 195 !DEF: /test_simd_multi/k ObjectEntity INTEGER(4) 196 integer i, j, k 197!$omp parallel do simd collapse(3) 198 !DEF: /test_simd_multi/Block1/i (OmpLastPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 199 do i=1,5 200 !DEF: /test_simd_multi/Block1/j (OmpLastPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 201 do j=6,10 202 !DEF: /test_simd_multi/Block1/k (OmpLastPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 203 do k=11,15 204 !REF: /test_simd_multi/a 205 !REF: /test_simd_multi/Block1/k 206 !REF: /test_simd_multi/Block1/j 207 !REF: /test_simd_multi/Block1/i 208 a(k,j,i) = 3.14 209 end do 210 end do 211 end do 212end subroutine test_simd_multi 213 214! Rule d) 215!DEF: /test_seq_loop (Subroutine) Subprogram 216subroutine test_seq_loop 217 implicit none 218 !DEF: /test_seq_loop/i ObjectEntity INTEGER(4) 219 !DEF: /test_seq_loop/j ObjectEntity INTEGER(4) 220 integer i, j 221 !REF: /test_seq_loop/i 222 i = -1 223 !REF: /test_seq_loop/j 224 j = -1 225 !$omp parallel 226 !REF: /test_seq_loop/i 227 !REF: /test_seq_loop/j 228 print *, i, j 229 !$omp parallel 230 !REF: /test_seq_loop/i 231 !DEF: /test_seq_loop/Block1/Block1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 232 print *, i, j 233 !$omp do 234 !DEF: /test_seq_loop/Block1/Block1/Block1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) 235 do i=1,10 236 !REF: /test_seq_loop/Block1/Block1/j 237 do j=1,10 238 end do 239 end do 240 !REF: /test_seq_loop/i 241 !REF: /test_seq_loop/Block1/Block1/j 242 print *, i, j 243 !$omp end parallel 244 !REF: /test_seq_loop/i 245 !REF: /test_seq_loop/j 246 print *, i, j 247 !$omp end parallel 248 !REF: /test_seq_loop/i 249 !REF: /test_seq_loop/j 250 print *, i, j 251end subroutine test_seq_loop 252