[flang-commits] [flang] 396ed32 - [flang][OpenMP] Lower OpenMP `taskgroup` construct
Sourabh Singh Tomar via flang-commits
flang-commits at lists.llvm.org
Fri Sep 16 08:38:06 PDT 2022
Author: Sourabh Singh Tomar
Date: 2022-09-16T21:07:47+05:30
New Revision: 396ed327bbb1f7c3a2a0fca429debb3ca12b0523
URL: https://github.com/llvm/llvm-project/commit/396ed327bbb1f7c3a2a0fca429debb3ca12b0523
DIFF: https://github.com/llvm/llvm-project/commit/396ed327bbb1f7c3a2a0fca429debb3ca12b0523.diff
LOG: [flang][OpenMP] Lower OpenMP `taskgroup` construct
Lower Fortran OpenMP `taskgroup` to FIR + OpenMP Dialect.
Reviewed By: kiranchandramohan, peixin
Differential Revision: https://reviews.llvm.org/D133918
Added:
flang/test/Lower/OpenMP/taskgroup.f90
Modified:
flang/lib/Lower/OpenMP.cpp
flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
Removed:
################################################################################
diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index 639184506b45f..ae21ae9c02169 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -837,6 +837,13 @@ genOMP(Fortran::lower::AbstractConverter &converter,
/*in_reductions=*/nullptr, priorityClauseOperand, allocateOperands,
allocatorOperands);
createBodyOfOp(taskOp, converter, currentLocation, eval, &opClauseList);
+ } else if (blockDirective.v == llvm::omp::OMPD_taskgroup) {
+ // TODO: Add task_reduction support
+ auto taskGroupOp = firOpBuilder.create<mlir::omp::TaskGroupOp>(
+ currentLocation, /*task_reduction_vars=*/ValueRange(),
+ /*task_reductions=*/nullptr, allocateOperands, allocatorOperands);
+ createBodyOfOp(taskGroupOp, converter, currentLocation, eval,
+ &opClauseList);
} else {
TODO(converter.getCurrentLocation(), "Unhandled block directive");
}
diff --git a/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir b/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
index d40e69d22a2bb..b6e97d9cc45e6 100644
--- a/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
+++ b/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
@@ -270,3 +270,30 @@ func.func @_QPsimdloop_with_nested_loop() {
// CHECK: }
// CHECK: llvm.return
// CHECK: }
+
+// -----
+
+func.func @_QPomp_taskgroup() {
+ omp.taskgroup {
+ omp.task {
+ fir.call @_QPwork() : () -> ()
+ omp.terminator
+ }
+ omp.terminator
+ }
+ return
+}
+func.func private @_QPwork()
+
+// CHECK-LABEL: llvm.func @_QPomp_taskgroup() {
+// CHECK: omp.taskgroup {
+// CHECK: omp.task {
+// CHECK: llvm.call @_QPwork() : () -> ()
+// CHECK: omp.terminator
+// CHECK: }
+// CHECK: omp.terminator
+// CHECK: }
+// CHECK: llvm.return
+// CHECK: }
+// CHECK: llvm.func @_QPwork() attributes {sym_visibility = "private"}
+// CHECK: }
diff --git a/flang/test/Lower/OpenMP/taskgroup.f90 b/flang/test/Lower/OpenMP/taskgroup.f90
new file mode 100644
index 0000000000000..0cac7843d578b
--- /dev/null
+++ b/flang/test/Lower/OpenMP/taskgroup.f90
@@ -0,0 +1,19 @@
+!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
+
+!CHECK-LABEL: @_QPomp_taskgroup
+subroutine omp_taskgroup
+use omp_lib
+integer :: allocated_x
+!CHECK-DAG: %{{.*}} = fir.alloca i32 {bindc_name = "allocated_x", uniq_name = "_QFomp_taskgroupEallocated_x"}
+!CHECK-DAG: %{{.*}} = arith.constant 1 : i32
+
+!CHECK: omp.taskgroup allocate(%{{.*}} : i32 -> %0 : !fir.ref<i32>)
+!$omp taskgroup allocate(omp_high_bw_mem_alloc: allocated_x)
+!$omp task
+!CHECK: fir.call @_QPwork() : () -> ()
+ call work()
+!CHECK: omp.terminator
+!$omp end task
+!CHECK: omp.terminator
+!$omp end taskgroup
+end subroutine
More information about the flang-commits
mailing list