brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 3e46692 Raw
54 lines · plain
1// RUN: fir-opt --omp-do-concurrent-conversion="map-to=device" %s -o - | FileCheck %s2 3fir.declare_reduction @add_reduction_f32 : f32 init {4^bb0(%arg0: f32):5  %cst = arith.constant 0.000000e+00 : f326  fir.yield(%cst : f32)7} combiner {8^bb0(%arg0: f32, %arg1: f32):9  %0 = arith.addf %arg0, %arg1 fastmath<contract> : f3210  fir.yield(%0 : f32)11}12 13func.func @_QPfoo() {14  %0 = fir.dummy_scope : !fir.dscope15  %3 = fir.alloca f32 {bindc_name = "s", uniq_name = "_QFfooEs"}16  %4:2 = hlfir.declare %3 {uniq_name = "_QFfooEs"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)17    %c1 = arith.constant 1 : index18  %c10 = arith.constant 1 : index19  fir.do_concurrent {20    %7 = fir.alloca i32 {bindc_name = "i"}21    %8:2 = hlfir.declare %7 {uniq_name = "_QFfooEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)22    fir.do_concurrent.loop (%arg0) = (%c1) to (%c10) step (%c1) reduce(@add_reduction_f32 #fir.reduce_attr<add> %4#0 -> %arg1 : !fir.ref<f32>) {23      %9 = fir.convert %arg0 : (index) -> i3224      fir.store %9 to %8#0 : !fir.ref<i32>25      %10:2 = hlfir.declare %arg1 {uniq_name = "_QFfooEs"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)26      %11 = fir.load %10#0 : !fir.ref<f32>27      %cst = arith.constant 1.000000e+00 : f3228      %12 = arith.addf %11, %cst fastmath<contract> : f3229      hlfir.assign %12 to %10#0 : f32, !fir.ref<f32>30    }31  }32  return33}34 35// CHECK: omp.declare_reduction @[[OMP_RED:.*.omp]] : f3236 37// CHECK: %[[S_DECL:.*]]:2 = hlfir.declare %6 {uniq_name = "_QFfooEs"}38// CHECK: %[[S_MAP:.*]] = omp.map.info var_ptr(%[[S_DECL]]#139 40// CHECK: omp.target host_eval({{.*}}) map_entries({{.*}}, %[[S_MAP]] -> %[[S_TARGET_ARG:.*]] : {{.*}}) {41// CHECK:   %[[S_DEV_DECL:.*]]:2 = hlfir.declare %[[S_TARGET_ARG]]42// CHECK:   omp.teams reduction(@[[OMP_RED]] %[[S_DEV_DECL]]#0 -> %[[RED_TEAMS_ARG:.*]] : !fir.ref<f32>) {43// CHECK:   omp.parallel {44// CHECK:     omp.distribute {45// CHECK:       omp.wsloop reduction(@[[OMP_RED]] %[[RED_TEAMS_ARG]] -> %[[RED_WS_ARG:.*]] : {{.*}}) {46// CHECK:         %[[S_WS_DECL:.*]]:2 = hlfir.declare %[[RED_WS_ARG]] {uniq_name = "_QFfooEs"}47// CHECK:         %[[S_VAL:.*]] = fir.load %[[S_WS_DECL]]#048// CHECK:         %[[RED_RES:.*]] = arith.addf %[[S_VAL]], %{{.*}} fastmath<contract> : f3249// CHECK:         hlfir.assign %[[RED_RES]] to %[[S_WS_DECL]]#050// CHECK:       }51// CHECK:     }52// CHECK:   }53// CHECK: }54