brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.1 KiB · 8870572 Raw
177 lines · plain
1! RUN: %flang_fc1 -fopenmp -emit-hlfir %s -o - | FileCheck %s2! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s3 4subroutine cancel_parallel()5  !$omp parallel6    !$omp cancel parallel7  !$omp end parallel8end subroutine9! CHECK-LABEL:   func.func @_QPcancel_parallel() {10! CHECK:           omp.parallel {11! CHECK:             omp.cancel cancellation_construct_type(parallel)12! CHECK:             omp.terminator13! CHECK:           }14! CHECK:           return15! CHECK:         }16 17subroutine cancel_do()18  !$omp parallel do19  do i = 1,10020    !$omp cancel do21  enddo22  !$omp end parallel do23end subroutine24! CHECK-LABEL:   func.func @_QPcancel_do() {25! CHECK:           %[[VAL_0:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFcancel_doEi"}26! CHECK:           %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFcancel_doEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)27! CHECK:           omp.parallel {28! CHECK:             %[[VAL_2:.*]] = arith.constant 1 : i3229! CHECK:             %[[VAL_3:.*]] = arith.constant 100 : i3230! CHECK:             %[[VAL_4:.*]] = arith.constant 1 : i3231! CHECK:             omp.wsloop private(@_QFcancel_doEi_private_i32 %[[VAL_1]]#0 -> %[[VAL_5:.*]] : !fir.ref<i32>) {32! CHECK:               omp.loop_nest (%[[VAL_6:.*]]) : i32 = (%[[VAL_2]]) to (%[[VAL_3]]) inclusive step (%[[VAL_4]]) {33! CHECK:                 %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_5]] {uniq_name = "_QFcancel_doEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)34! CHECK:                 hlfir.assign %[[VAL_6]] to %[[VAL_7]]#0 : i32, !fir.ref<i32>35! CHECK:                 omp.cancel cancellation_construct_type(loop)36! CHECK:                 omp.yield37! CHECK:               }38! CHECK:             }39! CHECK:             omp.terminator40! CHECK:           }41! CHECK:           return42! CHECK:         }43 44subroutine cancel_sections()45  !$omp sections46    !$omp section47      !$omp cancel sections48  !$omp end sections49end subroutine50! CHECK-LABEL:   func.func @_QPcancel_sections() {51! CHECK:           omp.sections {52! CHECK:             omp.section {53! CHECK:               omp.cancel cancellation_construct_type(sections)54! CHECK:               omp.terminator55! CHECK:             }56! CHECK:             omp.terminator57! CHECK:           }58! CHECK:           return59! CHECK:         }60 61subroutine cancel_taskgroup()62  !$omp taskgroup63    !$omp task64      !$omp cancel taskgroup65    !$omp end task66  !$omp end taskgroup67end subroutine68! CHECK-LABEL:   func.func @_QPcancel_taskgroup() {69! CHECK:           omp.taskgroup {70! CHECK:             omp.task {71! CHECK:               omp.cancel cancellation_construct_type(taskgroup)72! CHECK:               omp.terminator73! CHECK:             }74! CHECK:             omp.terminator75! CHECK:           }76! CHECK:           return77! CHECK:         }78 79subroutine cancel_parallel_if(cond)80  logical :: cond81  !$omp parallel82    !$omp cancel parallel if(cond)83  !$omp end parallel84end subroutine85! CHECK-LABEL:   func.func @_QPcancel_parallel_if(86! CHECK-SAME:                                     %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.ref<!fir.logical<4>> {fir.bindc_name = "cond"}) {87! CHECK:           %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope88! CHECK:           %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] arg {{[0-9]+}} {uniq_name = "_QFcancel_parallel_ifEcond"} : (!fir.ref<!fir.logical<4>>, !fir.dscope) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)89! CHECK:           omp.parallel {90! CHECK:             %[[VAL_3:.*]] = fir.load %[[VAL_2]]#0 : !fir.ref<!fir.logical<4>>91! CHECK:             %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.logical<4>) -> i192! CHECK:             omp.cancel cancellation_construct_type(parallel) if(%[[VAL_4]])93! CHECK:             omp.terminator94! CHECK:           }95! CHECK:           return96! CHECK:         }97 98subroutine cancel_do_if(cond)99  logical :: cond100  !$omp parallel do101  do i = 1,100102    !$omp cancel do if (cond)103  enddo104  !$omp end parallel do105end subroutine106! CHECK-LABEL:   func.func @_QPcancel_do_if(107! CHECK-SAME:                               %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.ref<!fir.logical<4>> {fir.bindc_name = "cond"}) {108! CHECK:           %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope109! CHECK:           %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] arg {{[0-9]+}} {uniq_name = "_QFcancel_do_ifEcond"} : (!fir.ref<!fir.logical<4>>, !fir.dscope) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)110! CHECK:           %[[VAL_3:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFcancel_do_ifEi"}111! CHECK:           %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_3]] {uniq_name = "_QFcancel_do_ifEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)112! CHECK:           omp.parallel {113! CHECK:             %[[VAL_5:.*]] = arith.constant 1 : i32114! CHECK:             %[[VAL_6:.*]] = arith.constant 100 : i32115! CHECK:             %[[VAL_7:.*]] = arith.constant 1 : i32116! CHECK:             omp.wsloop private(@_QFcancel_do_ifEi_private_i32 %[[VAL_4]]#0 -> %[[VAL_8:.*]] : !fir.ref<i32>) {117! CHECK:               omp.loop_nest (%[[VAL_9:.*]]) : i32 = (%[[VAL_5]]) to (%[[VAL_6]]) inclusive step (%[[VAL_7]]) {118! CHECK:                 %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_8]] {uniq_name = "_QFcancel_do_ifEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)119! CHECK:                 hlfir.assign %[[VAL_9]] to %[[VAL_10]]#0 : i32, !fir.ref<i32>120! CHECK:                 %[[VAL_11:.*]] = fir.load %[[VAL_2]]#0 : !fir.ref<!fir.logical<4>>121! CHECK:                 %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (!fir.logical<4>) -> i1122! CHECK:                 omp.cancel cancellation_construct_type(loop) if(%[[VAL_12]])123! CHECK:                 omp.yield124! CHECK:               }125! CHECK:             }126! CHECK:             omp.terminator127! CHECK:           }128! CHECK:           return129! CHECK:         }130 131subroutine cancel_sections_if(cond)132  logical :: cond133  !$omp sections134    !$omp section135    !$omp cancel sections if(cond)136  !$omp end sections137end subroutine138! CHECK-LABEL:   func.func @_QPcancel_sections_if(139! CHECK-SAME:                                     %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.ref<!fir.logical<4>> {fir.bindc_name = "cond"}) {140! CHECK:           %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope141! CHECK:           %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] arg {{[0-9]+}} {uniq_name = "_QFcancel_sections_ifEcond"} : (!fir.ref<!fir.logical<4>>, !fir.dscope) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)142! CHECK:           omp.sections {143! CHECK:             omp.section {144! CHECK:               %[[VAL_3:.*]] = fir.load %[[VAL_2]]#0 : !fir.ref<!fir.logical<4>>145! CHECK:               %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.logical<4>) -> i1146! CHECK:               omp.cancel cancellation_construct_type(sections) if(%[[VAL_4]])147! CHECK:               omp.terminator148! CHECK:             }149! CHECK:             omp.terminator150! CHECK:           }151! CHECK:           return152! CHECK:         }153 154subroutine cancel_taskgroup_if(cond)155  logical :: cond156  !$omp taskgroup157    !$omp task158      !$omp cancel taskgroup if(cond)159    !$omp end task160  !$omp end taskgroup161end subroutine162! CHECK-LABEL:   func.func @_QPcancel_taskgroup_if(163! CHECK-SAME:                                      %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.ref<!fir.logical<4>> {fir.bindc_name = "cond"}) {164! CHECK:           %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope165! CHECK:           %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] arg {{[0-9]+}} {uniq_name = "_QFcancel_taskgroup_ifEcond"} : (!fir.ref<!fir.logical<4>>, !fir.dscope) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)166! CHECK:           omp.taskgroup {167! CHECK:             omp.task {168! CHECK:               %[[VAL_3:.*]] = fir.load %[[VAL_2]]#0 : !fir.ref<!fir.logical<4>>169! CHECK:               %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.logical<4>) -> i1170! CHECK:               omp.cancel cancellation_construct_type(taskgroup) if(%[[VAL_4]])171! CHECK:               omp.terminator172! CHECK:             }173! CHECK:             omp.terminator174! CHECK:           }175! CHECK:           return176! CHECK:         }177