1! Test cases of nested 'reduction' clauses expected to compile cleanly. 2 3! See also 'c-c++-common/goacc/nested-reductions-1-parallel.c'. 4 5subroutine acc_parallel () 6 implicit none (type, external) 7 integer :: i, j, k, sum, diff 8 9 !$acc parallel 10 !$acc loop reduction(+:sum) 11 do i = 1, 10 12 do j = 1, 10 13 do k = 1, 10 14 sum = 1 15 end do 16 end do 17 end do 18 19 !$acc loop collapse(2) reduction(+:sum) 20 do i = 1, 10 21 do j = 1, 10 22 do k = 1, 10 23 sum = 1 24 end do 25 end do 26 end do 27 28 !$acc loop reduction(+:sum) 29 do i = 1, 10 30 !$acc loop reduction(+:sum) 31 do j = 1, 10 32 do k = 1, 10 33 sum = 1 34 end do 35 end do 36 end do 37 38 !$acc loop reduction(+:sum) 39 do i = 1, 10 40 !$acc loop collapse(2) reduction(+:sum) 41 do j = 1, 10 42 do k = 1, 10 43 sum = 1 44 end do 45 end do 46 end do 47 48 !$acc loop reduction(+:sum) 49 do i = 1, 10 50 do j = 1, 10 51 !$acc loop reduction(+:sum) 52 do k = 1, 10 53 sum = 1 54 end do 55 end do 56 end do 57 58 !$acc loop reduction(+:sum) 59 do i = 1, 10 60 !$acc loop reduction(+:sum) 61 do j = 1, 10 62 !$acc loop reduction(+:sum) 63 do k = 1, 10 64 sum = 1 65 end do 66 end do 67 end do 68 69 !$acc loop reduction(+:sum) reduction(-:diff) 70 do i = 1, 10 71 !$acc loop reduction(+:sum) 72 do j = 1, 10 73 !$acc loop reduction(+:sum) 74 do k = 1, 10 75 sum = 1 76 end do 77 end do 78 79 !$acc loop reduction(-:diff) 80 do j = 1, 10 81 !$acc loop reduction(-:diff) 82 do k = 1, 10 83 diff = 1 84 end do 85 end do 86 end do 87 !$acc end parallel 88end subroutine acc_parallel 89 90! The same tests as above, but using a combined parallel loop construct. 91 92subroutine acc_parallel_loop () 93 implicit none (type, external) 94 integer :: h, i, j, k, l, sum, diff 95 96 !$acc parallel loop 97 do h = 1, 10 98 !$acc loop reduction(+:sum) 99 do i = 1, 10 100 do j = 1, 10 101 do k = 1, 10 102 sum = 1 103 end do 104 end do 105 end do 106 107 !$acc loop collapse(2) reduction(+:sum) 108 do i = 1, 10 109 do j = 1, 10 110 do k = 1, 10 111 sum = 1 112 end do 113 end do 114 end do 115 116 !$acc loop reduction(+:sum) 117 do i = 1, 10 118 !$acc loop reduction(+:sum) 119 do j = 1, 10 120 do k = 1, 10 121 sum = 1 122 end do 123 end do 124 end do 125 126 !$acc loop reduction(+:sum) 127 do i = 1, 10 128 !$acc loop collapse(2) reduction(+:sum) 129 do j = 1, 10 130 do k = 1, 10 131 sum = 1 132 end do 133 end do 134 end do 135 136 !$acc loop reduction(+:sum) 137 do i = 1, 10 138 do j = 1, 10 139 !$acc loop reduction(+:sum) 140 do k = 1, 10 141 sum = 1 142 end do 143 end do 144 end do 145 146 !$acc loop reduction(+:sum) 147 do i = 1, 10 148 !$acc loop reduction(+:sum) ! { dg-warning "insufficient partitioning available to parallelize loop" } 149 do j = 1, 10 150 !$acc loop reduction(+:sum) 151 do k = 1, 10 152 sum = 1 153 end do 154 end do 155 end do 156 157 !$acc loop reduction(+:sum) reduction(-:diff) 158 do i = 1, 10 159 !$acc loop reduction(+:sum) ! { dg-warning "insufficient partitioning available to parallelize loop" } 160 do j = 1, 10 161 !$acc loop reduction(+:sum) 162 do k = 1, 10 163 sum = 1 164 end do 165 end do 166 167 !$acc loop reduction(-:diff) ! { dg-warning "insufficient partitioning available to parallelize loop" } 168 do j = 1, 10 169 !$acc loop reduction(-:diff) 170 do k = 1, 10 171 diff = 1 172 end do 173 end do 174 end do 175 end do 176end subroutine acc_parallel_loop 177 178! The same tests as above, but now the outermost reduction clause is on 179! the parallel region, not the outermost loop. */ 180 181subroutine acc_parallel_reduction () 182 implicit none (type, external) 183 integer :: i, j, k, sum, diff 184 185 !$acc parallel reduction(+:sum) 186 do i = 1, 10 187 do j = 1, 10 188 do k = 1, 10 189 sum = 1 190 end do 191 end do 192 end do 193 194 do i = 1, 10 195 !$acc loop 196 do j = 1, 10 197 do k = 1, 10 198 sum = 1 199 end do 200 end do 201 end do 202 203 !$acc loop reduction(+:sum) 204 do i = 1, 10 205 do j = 1, 10 206 !$acc loop reduction(+:sum) 207 do k = 1, 10 208 sum = 1 209 end do 210 end do 211 end do 212 213 do i = 1, 10 214 do j = 1, 10 215 !$acc loop 216 do k = 1, 10 217 sum = 1 218 end do 219 end do 220 end do 221 222 !$acc loop reduction(+:sum) 223 do i = 1, 10 224 !$acc loop reduction(+:sum) 225 do j = 1, 10 226 !$acc loop reduction(+:sum) 227 do k = 1, 10 228 sum = 1 229 end do 230 end do 231 end do 232 233 !$acc loop reduction(+:sum) reduction(-:diff) 234 do i = 1, 10 235 !$acc loop reduction(+:sum) 236 do j = 1, 10 237 !$acc loop reduction(+:sum) 238 do k = 1, 10 239 sum = 1 240 end do 241 end do 242 243 !$acc loop reduction(-:diff) 244 do j = 1, 10 245 !$acc loop reduction(-:diff) 246 do k = 1, 10 247 diff = 1 248 end do 249 end do 250 end do 251 252 !$acc loop reduction(+:sum) 253 do i = 1, 10 254 !$acc loop reduction(+:sum) 255 do j = 1, 10 256 !$acc loop reduction(+:sum) 257 do k = 1, 10 258 sum = 1 259 end do 260 end do 261 262 !$acc loop reduction(-:diff) 263 do j = 1, 10 264 !$acc loop reduction(-:diff) 265 do k = 1, 10 266 diff = 1 267 end do 268 end do 269 end do 270 271 !$acc loop reduction(+:sum) 272 do i = 1, 10 273 !$acc loop reduction(+:sum) 274 do j = 1, 10 275 !$acc loop reduction(+:sum) 276 do k = 1, 10 277 sum = 1 278 end do 279 end do 280 281 !$acc loop 282 do j = 1, 10 283 !$acc loop reduction(-:diff) 284 do k = 1, 10 285 diff = 1 286 end do 287 end do 288 end do 289 !$acc end parallel 290end subroutine acc_parallel_reduction 291 292! The same tests as above, but using a combined parallel loop construct, and 293! the outermost reduction clause is on that one, not the outermost loop. */ 294subroutine acc_parallel_loop_reduction () 295 implicit none (type, external) 296 integer :: h, i, j, k, sum, diff 297 298 !$acc parallel loop reduction(+:sum) 299 do h = 1, 10 300 do i = 1, 10 301 do j = 1, 10 302 do k = 1, 10 303 sum = 1 304 end do 305 end do 306 end do 307 308 do i = 1, 10 309 !$acc loop 310 do j = 1, 10 311 do k = 1, 10 312 sum = 1 313 end do 314 end do 315 end do 316 317 !$acc loop reduction(+:sum) 318 do i = 1, 10 319 do j = 1, 10 320 !$acc loop reduction(+:sum) 321 do k = 1, 10 322 sum = 1 323 end do 324 end do 325 end do 326 327 do i = 1, 10 328 do j = 1, 10 329 !$acc loop 330 do k = 1, 10 331 sum = 1 332 end do 333 end do 334 end do 335 336 !$acc loop reduction(+:sum) 337 do i = 1, 10 338 !$acc loop reduction(+:sum) ! { dg-warning "insufficient partitioning available to parallelize loop" } 339 do j = 1, 10 340 !$acc loop reduction(+:sum) 341 do k = 1, 10 342 sum = 1 343 end do 344 end do 345 end do 346 347 !$acc loop reduction(+:sum) reduction(-:diff) 348 do i = 1, 10 349 !$acc loop reduction(+:sum) ! { dg-warning "insufficient partitioning available to parallelize loop" } 350 do j = 1, 10 351 !$acc loop reduction(+:sum) 352 do k = 1, 10 353 sum = 1 354 end do 355 end do 356 357 !$acc loop reduction(-:diff) ! { dg-warning "insufficient partitioning available to parallelize loop" } 358 do j = 1, 10 359 !$acc loop reduction(-:diff) 360 do k = 1, 10 361 diff = 1 362 end do 363 end do 364 end do 365 366 !$acc loop reduction(+:sum) 367 do i = 1, 10 368 !$acc loop reduction(+:sum) ! { dg-warning "insufficient partitioning available to parallelize loop" } 369 do j = 1, 10 370 !$acc loop reduction(+:sum) 371 do k = 1, 10 372 sum = 1 373 end do 374 end do 375 376 !$acc loop reduction(-:diff) ! { dg-warning "insufficient partitioning available to parallelize loop" } 377 do j = 1, 10 378 !$acc loop reduction(-:diff) 379 do k = 1, 10 380 diff = 1 381 end do 382 end do 383 end do 384 385 !$acc loop reduction(+:sum) 386 do i = 1, 10 387 !$acc loop reduction(+:sum) ! { dg-warning "insufficient partitioning available to parallelize loop" } 388 do j = 1, 10 389 !$acc loop reduction(+:sum) 390 do k = 1, 10 391 sum = 1 392 end do 393 end do 394 395 !$acc loop ! { dg-warning "insufficient partitioning available to parallelize loop" } 396 do j = 1, 10 397 !$acc loop reduction(-:diff) 398 do k = 1, 10 399 diff = 1 400 end do 401 end do 402 end do 403 end do 404end subroutine acc_parallel_loop_reduction 405