|
3 | 3 | ! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s --check-prefixes=CHECK,FIR
|
4 | 4 | ! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s --check-prefixes=CHECK,HLFIR
|
5 | 5 |
|
| 6 | +! CHECK-LABEL: acc.reduction.recipe @reduction_max_ref_UxUxf32 : !fir.ref<!fir.array<?x?xf32>> reduction_operator <max> init { |
| 7 | +! CHECK: ^bb0(%[[ARG0:.*]]: !fir.ref<!fir.array<?x?xf32>>, %[[ARG1:.*]]: index, %[[ARG2:.*]]: index): |
| 8 | +! HLFIR: %[[CST:.*]] = arith.constant -1.401300e-45 : f32 |
| 9 | +! HLFIR: %[[SHAPE:.*]] = fir.shape %arg1, %arg2 : (index, index) -> !fir.shape<2> |
| 10 | +! HLFIR: %[[TEMP:.*]] = fir.alloca !fir.array<?x?xf32>, %arg1, %arg2 |
| 11 | +! HLFIR: %[[DECL:.*]]:2 = hlfir.declare %[[TEMP]](%[[SHAPE]]) {uniq_name = "acc.reduction.init"} : (!fir.ref<!fir.array<?x?xf32>>, !fir.shape<2>) -> (!fir.box<!fir.array<?x?xf32>>, !fir.ref<!fir.array<?x?xf32>>) |
| 12 | +! HLFIR: hlfir.assign %[[CST]] to %[[DECL]]#0 : f32, !fir.box<!fir.array<?x?xf32>> |
| 13 | +! HLFIR: acc.yield %[[DECL]]#0 : !fir.box<!fir.array<?x?xf32>> |
| 14 | +! CHECK: } combiner { |
| 15 | +! CHECK: ^bb0(%[[V1:.*]]: !fir.ref<!fir.array<?x?xf32>>, %[[V2:.*]]: !fir.ref<!fir.array<?x?xf32>>, %[[LB0:.*]]: index, %[[UB0:.*]]: index, %[[STEP0:.*]]: index, %[[LB1:.*]]: index, %[[UB1:.*]]: index, %[[STEP1:.*]]: index): |
| 16 | +! HLFIR: %[[SHAPE:.*]] = fir.shape %{{.*}}, %{{.*}} : (index, index) -> !fir.shape<2> |
| 17 | +! HLFIR: %[[DECL_V1:.*]]:2 = hlfir.declare %[[V1]](%[[SHAPE]]) {uniq_name = ""} : (!fir.ref<!fir.array<?x?xf32>>, !fir.shape<2>) -> (!fir.box<!fir.array<?x?xf32>>, !fir.ref<!fir.array<?x?xf32>>) |
| 18 | +! HLFIR: %[[DECL_V2:.*]]:2 = hlfir.declare %[[V2]](%[[SHAPE]]) {uniq_name = ""} : (!fir.ref<!fir.array<?x?xf32>>, !fir.shape<2>) -> (!fir.box<!fir.array<?x?xf32>>, !fir.ref<!fir.array<?x?xf32>>) |
| 19 | +! HLFIR: %[[DES_V1:.*]] = hlfir.designate %[[DECL_V1]]#0 (%arg2:%arg3:%arg4, %arg5:%arg6:%arg7) shape %10 : (!fir.box<!fir.array<?x?xf32>>, index, index, index, index, index, index, !fir.shape<2>) -> !fir.box<!fir.array<?x?xf32>> |
| 20 | +! HLFIR: %[[DES_V2:.*]] = hlfir.designate %[[DECL_V2]]#0 (%arg2:%arg3:%arg4, %arg5:%arg6:%arg7) shape %10 : (!fir.box<!fir.array<?x?xf32>>, index, index, index, index, index, index, !fir.shape<2>) -> !fir.box<!fir.array<?x?xf32>> |
| 21 | +! HLFIR: %[[ELEMENTAL:.*]] = hlfir.elemental %[[SHAPE]] unordered : (!fir.shape<2>) -> !hlfir.expr<?x?xf32> { |
| 22 | +! HLFIR: ^bb0(%[[ARG0:.*]]: index, %[[ARG1:.*]]: index): |
| 23 | +! HLFIR: %[[D1:.*]] = hlfir.designate %13 (%[[ARG0]], %[[ARG1]]) : (!fir.box<!fir.array<?x?xf32>>, index, index) -> !fir.ref<f32> |
| 24 | +! HLFIR: %[[D2:.*]] = hlfir.designate %14 (%[[ARG0]], %[[ARG1]]) : (!fir.box<!fir.array<?x?xf32>>, index, index) -> !fir.ref<f32> |
| 25 | +! HLFIR: %[[LOAD1:.*]] = fir.load %[[D1]] : !fir.ref<f32> |
| 26 | +! HLFIR: %[[LOAD2:.*]] = fir.load %[[D2]] : !fir.ref<f32> |
| 27 | +! HLFIR: %[[CMP:.*]] = arith.cmpf ogt, %[[LOAD1]], %[[LOAD2]] : f32 |
| 28 | +! HLFIR: %[[SELECT:.*]] = arith.select %[[CMP]], %[[LOAD1]], %[[LOAD2]] : f32 |
| 29 | +! HLFIR: hlfir.yield_element %[[SELECT]] : f32 |
| 30 | +! HLFIR: } |
| 31 | +! HLFIR: hlfir.assign %[[ELEMENTAL]] to %[[DECL_V1]]#0 : !hlfir.expr<?x?xf32>, !fir.box<!fir.array<?x?xf32>> |
| 32 | +! HLFIR: acc.yield %[[V1]] : !fir.ref<!fir.array<?x?xf32>> |
| 33 | +! CHECK: } |
| 34 | + |
6 | 35 | ! CHECK-LABEL: acc.reduction.recipe @reduction_max_box_ptr_Uxf32 : !fir.box<!fir.ptr<!fir.array<?xf32>>> reduction_operator <max> init {
|
7 | 36 | ! CHECK: ^bb0(%{{.*}}: !fir.box<!fir.ptr<!fir.array<?xf32>>>):
|
8 | 37 | ! CHECK: } combiner {
|
|
290 | 319 | ! CHECK-LABEL: acc.reduction.recipe @reduction_max_section_ext100_ref_100xf32 : !fir.ref<!fir.array<100xf32>> reduction_operator <max> init {
|
291 | 320 | ! CHECK: ^bb0(%{{.*}}: !fir.ref<!fir.array<100xf32>>):
|
292 | 321 | ! CHECK: %[[INIT:.*]] = arith.constant -1.401300e-45 : f32
|
293 |
| -! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100xf32> |
294 | 322 | ! HLFIR: %[[SHAPE:.*]] = fir.shape %{{.*}} : (index) -> !fir.shape<1>
|
| 323 | +! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100xf32> |
295 | 324 | ! HLFIR: %[[DECLARE:.*]]:2 = hlfir.declare %[[ALLOCA]](%[[SHAPE]]) {uniq_name = "acc.reduction.init"} : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<100xf32>>, !fir.ref<!fir.array<100xf32>>)
|
296 | 325 | ! CHECK: %[[LB:.*]] = arith.constant 0 : index
|
297 | 326 | ! CHECK: %[[UB:.*]] = arith.constant 99 : index
|
|
338 | 367 | ! CHECK-LABEL: acc.reduction.recipe @reduction_max_section_ext100xext10_ref_100x10xi32 : !fir.ref<!fir.array<100x10xi32>> reduction_operator <max> init {
|
339 | 368 | ! CHECK: ^bb0(%arg0: !fir.ref<!fir.array<100x10xi32>>):
|
340 | 369 | ! CHECK: %[[INIT:.*]] = arith.constant -2147483648 : i32
|
341 |
| -! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100x10xi32> |
342 | 370 | ! HLFIR: %[[SHAPE:.*]] = fir.shape %{{.*}}, %{{.*}} : (index, index) -> !fir.shape<2>
|
| 371 | +! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100x10xi32> |
343 | 372 | ! HLFIR: %[[DECLARE:.*]]:2 = hlfir.declare %[[ALLOCA]](%[[SHAPE]]) {uniq_name = "acc.reduction.init"} : (!fir.ref<!fir.array<100x10xi32>>, !fir.shape<2>) -> (!fir.ref<!fir.array<100x10xi32>>, !fir.ref<!fir.array<100x10xi32>>)
|
344 | 373 | ! HLFIR: acc.yield %[[DECLARE]]#0 : !fir.ref<!fir.array<100x10xi32>>
|
345 | 374 | ! CHECK: } combiner {
|
|
384 | 413 | ! CHECK-LABEL: acc.reduction.recipe @reduction_min_section_ext100xext10_ref_100x10xf32 : !fir.ref<!fir.array<100x10xf32>> reduction_operator <min> init {
|
385 | 414 | ! CHECK: ^bb0(%{{.*}}: !fir.ref<!fir.array<100x10xf32>>):
|
386 | 415 | ! CHECK: %[[INIT:.*]] = arith.constant 3.40282347E+38 : f32
|
387 |
| -! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100x10xf32> |
388 | 416 | ! HLFIR: %[[SHAPE:.*]] = fir.shape %{{.*}}, %{{.*}} : (index, index) -> !fir.shape<2>
|
| 417 | +! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100x10xf32> |
389 | 418 | ! HLFIR: %[[DECLARE:.*]]:2 = hlfir.declare %[[ALLOCA]](%[[SHAPE]]) {uniq_name = "acc.reduction.init"} : (!fir.ref<!fir.array<100x10xf32>>, !fir.shape<2>) -> (!fir.ref<!fir.array<100x10xf32>>, !fir.ref<!fir.array<100x10xf32>>)
|
390 | 419 | ! HLFIR: acc.yield %[[DECLARE]]#0 : !fir.ref<!fir.array<100x10xf32>>
|
391 | 420 | ! CHECK: } combiner {
|
|
430 | 459 | ! CHECK-LABEL: acc.reduction.recipe @reduction_min_section_ext100_ref_100xi32 : !fir.ref<!fir.array<100xi32>> reduction_operator <min> init {
|
431 | 460 | ! CHECK: ^bb0(%{{.*}}: !fir.ref<!fir.array<100xi32>>):
|
432 | 461 | ! CHECK: %[[INIT:.*]] = arith.constant 2147483647 : i32
|
433 |
| -! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100xi32> |
434 | 462 | ! HLFIR: %[[SHAPE:.*]] = fir.shape %{{.*}} : (index) -> !fir.shape<1>
|
| 463 | +! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100xi32> |
435 | 464 | ! HLFIR: %[[DECLARE:.*]]:2 = hlfir.declare %[[ALLOCA]](%[[SHAPE]]) {uniq_name = "acc.reduction.init"} : (!fir.ref<!fir.array<100xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<100xi32>>, !fir.ref<!fir.array<100xi32>>)
|
436 | 465 | ! HLFIR: acc.yield %[[DECLARE]]#0 : !fir.ref<!fir.array<100xi32>>
|
437 | 466 | ! CHECK: } combiner {
|
|
487 | 516 | ! CHECK-LABEL: acc.reduction.recipe @reduction_mul_section_ext100_ref_100xi32 : !fir.ref<!fir.array<100xi32>> reduction_operator <mul> init {
|
488 | 517 | ! CHECK: ^bb0(%{{.*}}: !fir.ref<!fir.array<100xi32>>):
|
489 | 518 | ! CHECK: %[[INIT:.*]] = arith.constant 1 : i32
|
490 |
| -! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100xi32> |
491 | 519 | ! HLFIR: %[[SHAPE:.*]] = fir.shape %{{.*}} : (index) -> !fir.shape<1>
|
| 520 | +! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100xi32> |
492 | 521 | ! HLFIR: %[[DECLARE:.*]]:2 = hlfir.declare %[[ALLOCA]](%[[SHAPE]]) {uniq_name = "acc.reduction.init"} : (!fir.ref<!fir.array<100xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<100xi32>>, !fir.ref<!fir.array<100xi32>>)
|
493 | 522 | ! HLFIR: acc.yield %[[DECLARE]]#0 : !fir.ref<!fir.array<100xi32>>
|
494 | 523 | ! CHECK: } combiner {
|
|
526 | 555 | ! CHECK-LABEL: acc.reduction.recipe @reduction_add_section_ext100_ref_100xf32 : !fir.ref<!fir.array<100xf32>> reduction_operator <add> init {
|
527 | 556 | ! CHECK: ^bb0(%{{.*}}: !fir.ref<!fir.array<100xf32>>):
|
528 | 557 | ! CHECK: %[[INIT:.*]] = arith.constant 0.000000e+00 : f32
|
529 |
| -! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100xf32> |
530 | 558 | ! HLFIR: %[[SHAPE:.*]] = fir.shape %{{.*}} : (index) -> !fir.shape<1>
|
| 559 | +! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100xf32> |
531 | 560 | ! HLFIR: %[[DECLARE:.*]]:2 = hlfir.declare %[[ALLOCA]](%[[SHAPE]]) {uniq_name = "acc.reduction.init"} : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<100xf32>>, !fir.ref<!fir.array<100xf32>>)
|
532 | 561 | ! HLFIR: acc.yield %[[DECLARE]]#0 : !fir.ref<!fir.array<100xf32>>
|
533 | 562 | ! CHECK: } combiner {
|
|
565 | 594 | ! CHECK-LABEL: acc.reduction.recipe @reduction_add_section_ext100xext10xext2_ref_100x10x2xi32 : !fir.ref<!fir.array<100x10x2xi32>> reduction_operator <add> init {
|
566 | 595 | ! CHECK: ^bb0(%{{.*}}: !fir.ref<!fir.array<100x10x2xi32>>):
|
567 | 596 | ! CHECK: %[[INIT:.*]] = arith.constant 0 : i32
|
568 |
| -! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100x10x2xi32> |
569 | 597 | ! HLFIR: %[[SHAPE:.*]] = fir.shape %{{.*}}, %{{.*}}, %{{.*}} : (index, index, index) -> !fir.shape<3>
|
| 598 | +! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100x10x2xi32> |
570 | 599 | ! HLFIR: %[[DECLARE:.*]]:2 = hlfir.declare %[[ALLOCA]](%[[SHAPE]]) {uniq_name = "acc.reduction.init"} : (!fir.ref<!fir.array<100x10x2xi32>>, !fir.shape<3>) -> (!fir.ref<!fir.array<100x10x2xi32>>, !fir.ref<!fir.array<100x10x2xi32>>)
|
571 | 600 | ! HLFIR: acc.yield %[[DECLARE]]#0 : !fir.ref<!fir.array<100x10x2xi32>>
|
572 | 601 | ! CHECK: } combiner {
|
|
598 | 627 | ! CHECK-LABEL: acc.reduction.recipe @reduction_add_section_ext100xext10_ref_100x10xi32 : !fir.ref<!fir.array<100x10xi32>> reduction_operator <add> init {
|
599 | 628 | ! CHECK: ^bb0(%{{.*}}: !fir.ref<!fir.array<100x10xi32>>):
|
600 | 629 | ! CHECK: %[[INIT:.*]] = arith.constant 0 : i32
|
601 |
| -! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100x10xi32> |
602 | 630 | ! HLFIR: %[[SHAPE:.*]] = fir.shape %{{.*}}, %{{.*}} : (index, index) -> !fir.shape<2>
|
| 631 | +! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100x10xi32> |
603 | 632 | ! HLFIR: %[[DECLARE:.*]]:2 = hlfir.declare %[[ALLOCA]](%[[SHAPE]]) {uniq_name = "acc.reduction.init"} : (!fir.ref<!fir.array<100x10xi32>>, !fir.shape<2>) -> (!fir.ref<!fir.array<100x10xi32>>, !fir.ref<!fir.array<100x10xi32>>)
|
604 | 633 | ! HLFIR: acc.yield %[[DECLARE]]#0 : !fir.ref<!fir.array<100x10xi32>>
|
605 | 634 | ! CHECK: } combiner {
|
|
626 | 655 | ! CHECK-LABEL: acc.reduction.recipe @reduction_add_section_ext100_ref_100xi32 : !fir.ref<!fir.array<100xi32>> reduction_operator <add> init {
|
627 | 656 | ! CHECK: ^bb0(%{{.*}}: !fir.ref<!fir.array<100xi32>>):
|
628 | 657 | ! CHECK: %[[INIT:.*]] = arith.constant 0 : i32
|
629 |
| -! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100xi32> |
630 | 658 | ! HLFIR: %[[SHAPE:.*]] = fir.shape %{{.*}} : (index) -> !fir.shape<1>
|
| 659 | +! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<100xi32> |
631 | 660 | ! HLFIR: %[[DECLARE:.*]]:2 = hlfir.declare %[[ALLOCA]](%[[SHAPE]]) {uniq_name = "acc.reduction.init"} : (!fir.ref<!fir.array<100xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<100xi32>>, !fir.ref<!fir.array<100xi32>>)
|
632 | 661 | ! HFLIR: acc.yield %[[DECLARE]]#0 : !fir.ref<!fir.array<100xi32>>
|
633 | 662 | ! CHECK: } combiner {
|
@@ -1134,13 +1163,13 @@ subroutine acc_reduction_add_dynamic_extent_add(a)
|
1134 | 1163 | ! HLFIR: %[[RED:.*]] = acc.reduction varPtr(%{{.*}} : !fir.ref<!fir.array<?xi32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<?xi32>> {name = "a"}
|
1135 | 1164 | ! HLFIR: acc.parallel reduction(@reduction_add_box_Uxi32 -> %[[RED:.*]] : !fir.ref<!fir.array<?xi32>>)
|
1136 | 1165 |
|
1137 |
| -subroutine acc_reduction_add_dynamic_extent_max(a) |
| 1166 | +subroutine acc_reduction_add_assumed_shape_max(a) |
1138 | 1167 | real :: a(:)
|
1139 | 1168 | !$acc parallel reduction(max:a)
|
1140 | 1169 | !$acc end parallel
|
1141 | 1170 | end subroutine
|
1142 | 1171 |
|
1143 |
| -! CHECK-LABEL: func.func @_QPacc_reduction_add_dynamic_extent_max( |
| 1172 | +! CHECK-LABEL: func.func @_QPacc_reduction_add_assumed_shape_max( |
1144 | 1173 | ! CHECK-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "a"})
|
1145 | 1174 | ! HLFIR: %[[DECLARG0:.*]]:2 = hlfir.declare %[[ARG0]]
|
1146 | 1175 | ! HLFIR: %[[RED:.*]] = acc.reduction varPtr(%{{.*}} : !fir.ref<!fir.array<?xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<?xf32>> {name = "a"}
|
@@ -1189,3 +1218,16 @@ subroutine acc_reduction_add_pointer_array(a)
|
1189 | 1218 | ! HLFIR: %[[BOX_ADDR:.*]] = fir.box_addr %[[BOX]] : (!fir.box<!fir.ptr<!fir.array<?xf32>>>) -> !fir.ptr<!fir.array<?xf32>>
|
1190 | 1219 | ! HLFIR: %[[RED:.*]] = acc.reduction varPtr(%[[BOX_ADDR]] : !fir.ptr<!fir.array<?xf32>>) bounds(%[[BOUND]]) -> !fir.ptr<!fir.array<?xf32>> {name = "a"}
|
1191 | 1220 | ! HLFIR: acc.parallel reduction(@reduction_max_box_ptr_Uxf32 -> %[[RED]] : !fir.ptr<!fir.array<?xf32>>)
|
| 1221 | + |
| 1222 | +subroutine acc_reduction_max_dynamic_extent_max(a, n) |
| 1223 | + integer :: n |
| 1224 | + real :: a(n, n) |
| 1225 | + !$acc parallel reduction(max:a) |
| 1226 | + !$acc end parallel |
| 1227 | +end subroutine |
| 1228 | + |
| 1229 | +! CHECK-LABEL: func.func @_QPacc_reduction_max_dynamic_extent_max( |
| 1230 | +! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<!fir.array<?x?xf32>> {fir.bindc_name = "a"}, %{{.*}}: !fir.ref<i32> {fir.bindc_name = "n"}) |
| 1231 | +! HLFIR: %[[DECL_A:.*]]:2 = hlfir.declare %[[ARG0]](%{{.*}}) {uniq_name = "_QFacc_reduction_max_dynamic_extent_maxEa"} : (!fir.ref<!fir.array<?x?xf32>>, !fir.shape<2>) -> (!fir.box<!fir.array<?x?xf32>>, !fir.ref<!fir.array<?x?xf32>>) |
| 1232 | +! HLFIR: %[[RED:.*]] = acc.reduction varPtr(%[[DECL_A]]#1 : !fir.ref<!fir.array<?x?xf32>>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref<!fir.array<?x?xf32>> {name = "a"} |
| 1233 | +! HLFIR: acc.parallel reduction(@reduction_max_ref_UxUxf32 -> %[[RED]] : !fir.ref<!fir.array<?x?xf32>>) |
0 commit comments