[Mlir-commits] [mlir] Adding masked operation to OpenMP Dialect (PR #96022)
Anchu Rajendran S
llvmlistbot at llvm.org
Wed Jun 19 22:39:20 PDT 2024
https://github.com/anchuraj updated https://github.com/llvm/llvm-project/pull/96022
>From 6169ebfd77528418df676eaf600d1e009ca2f2e3 Mon Sep 17 00:00:00 2001
From: Anchu Rajendran <asudhaku at amd.com>
Date: Sat, 15 Jun 2024 00:03:59 -0500
Subject: [PATCH 1/2] Adding masked operations to OpenMP Dialect
---
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | 41 +++++++++++++++++++
mlir/test/Dialect/OpenMP/ops.mlir | 15 +++++++
2 files changed, 56 insertions(+)
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index f28911adccd02..70c53f0fbc1d9 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -2149,4 +2149,45 @@ def DeclareReductionOp : OpenMP_Op<"declare_reduction", [Symbol,
let hasRegionVerifier = 1;
}
+//===----------------------------------------------------------------------===//
+// 2.19.5.4 reduction clause
+//===----------------------------------------------------------------------===//
+
+def ReductionOp : OpenMP_Op<"reduction"> {
+ let summary = "reduction construct";
+ let description = [{
+ Indicates the value that is produced by the current reduction-participating
+ entity for a reduction requested in some ancestor. The reduction is
+ identified by the accumulator, but the value of the accumulator may not be
+ updated immediately.
+ }];
+
+ let arguments= (ins AnyType:$operand, OpenMP_PointerLikeType:$accumulator);
+ let assemblyFormat = [{
+ $operand `,` $accumulator attr-dict `:` type($operand) `,` type($accumulator)
+ }];
+ let hasVerifier = 1;
+}
+
+//===----------------------------------------------------------------------===//
+// [Spec 5.2] 10.5 masked Construct
+//===----------------------------------------------------------------------===//
+def MaskedOp : OpenMP_Op<"masked"> {
+ let summary = "masked construct";
+ let description = [{
+ Masked construct allows to specify a structured block to be executed by a subset of
+ threads of the current team. Filter clause allows to select the threads expected to
+ execute the region
+ }];
+
+ let arguments = (ins Optional<I32>:$filteredThreadId);
+ let regions = (region AnyRegion:$region);
+
+ let assemblyFormat = [{
+ oilist(
+ `filter` `(` $filteredThreadId `:` type($filteredThreadId) `)`
+ ) $region attr-dict
+ }];
+}
+
#endif // OPENMP_OPS
diff --git a/mlir/test/Dialect/OpenMP/ops.mlir b/mlir/test/Dialect/OpenMP/ops.mlir
index af66d0c65dab8..abad5e93bbda5 100644
--- a/mlir/test/Dialect/OpenMP/ops.mlir
+++ b/mlir/test/Dialect/OpenMP/ops.mlir
@@ -16,6 +16,21 @@ func.func @omp_master() -> () {
return
}
+// CHECK-LABEL: omp_masked
+func.func @omp_masked(%filtered_thread_id : i32) -> () {
+
+
+ // CHECK: omp.masked filter(%{{.*}} : i32)
+ "omp.masked" (%filtered_thread_id) ({
+ omp.terminator
+ }) : (i32) -> ()
+
+ // CHECK: omp.masked
+ "omp.masked" () ({
+ omp.terminator
+ }) : () -> ()
+ return
+}
func.func @omp_taskwait() -> () {
// CHECK: omp.taskwait
omp.taskwait
>From e58369098df89ff6ecfc405d8529ed96124841ad Mon Sep 17 00:00:00 2001
From: Anchu Rajendran <asudhaku at amd.com>
Date: Thu, 20 Jun 2024 00:30:20 -0500
Subject: [PATCH 2/2] xR2: Adding some formatting changes
---
mlir/test/Dialect/OpenMP/ops.mlir | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/mlir/test/Dialect/OpenMP/ops.mlir b/mlir/test/Dialect/OpenMP/ops.mlir
index abad5e93bbda5..febf052bbac43 100644
--- a/mlir/test/Dialect/OpenMP/ops.mlir
+++ b/mlir/test/Dialect/OpenMP/ops.mlir
@@ -18,8 +18,6 @@ func.func @omp_master() -> () {
// CHECK-LABEL: omp_masked
func.func @omp_masked(%filtered_thread_id : i32) -> () {
-
-
// CHECK: omp.masked filter(%{{.*}} : i32)
"omp.masked" (%filtered_thread_id) ({
omp.terminator
@@ -31,6 +29,7 @@ func.func @omp_masked(%filtered_thread_id : i32) -> () {
}) : () -> ()
return
}
+
func.func @omp_taskwait() -> () {
// CHECK: omp.taskwait
omp.taskwait
More information about the Mlir-commits
mailing list