[flang-commits] [flang] [Flang][OpenMP]Support for lowering task_reduction and in_reduction to MLIR (PR #111155)

Sergio Afonso via flang-commits flang-commits at lists.llvm.org
Thu Jan 9 09:00:33 PST 2025


================
@@ -0,0 +1,49 @@
+! RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=50 -o - %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=50 -o - %s 2>&1 | FileCheck %s
+
+! CHECK-LABEL:  omp.declare_reduction @add_reduction_byref_box_Uxf32 : !fir.ref<!fir.box<!fir.array<?xf32>>> alloc {
+!                 [...]
+! CHECK:          omp.yield
+! CHECK-LABEL:  } init {
+!                 [...]
+! CHECK:          omp.yield
+! CHECK-LABEL:  } combiner {
+!                 [...]
+! CHECK:          omp.yield
+! CHECK-LABEL:  }  cleanup {
+!                  [...]
+! CHECK:           omp.yield
+! CHECK:  }
+
+! CHECK-LABEL:  func.func @_QPtaskreduction
+! CHECK-SAME:  (%[[VAL_0:.*]]: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "x"}) {
+! CHECK:          %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK:          %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]]
+! CHECK-SAME      {uniq_name = "_QFtaskreductionEx"} : (!fir.box<!fir.array<?xf32>>, !fir.dscope) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
+! CHECK:          omp.parallel {
+! CHECK:            %[[VAL_3:.*]] = fir.alloca !fir.box<!fir.array<?xf32>>
+! CHECK:            fir.store %[[VAL_2]]#1 to %[[VAL_3]] : !fir.ref<!fir.box<!fir.array<?xf32>>>
+! CHECK:            omp.taskgroup task_reduction(byref @add_reduction_byref_box_Uxf32 %[[VAL_3]] ->  %[[VAL_4:.*]]: !fir.ref<!fir.box<!fir.array<?xf32>>>) {
+! CHECK:              %[[VAL_5:.*]] = fir.alloca !fir.box<!fir.array<?xf32>>
----------------
skatrak wrote:

This doesn't look right to me, but I might be wrong. Shouldn't we be passing the result of an `hlfir.declare` of VAL_4 to `omp.task`, rather than creating an alloca for it? Perhaps this is related to the missing binding of Fortran symbols to entry block arguments during the creation of the region for `omp.taskgroup`.

https://github.com/llvm/llvm-project/pull/111155


More information about the flang-commits mailing list