[Mlir-commits] [mlir] Adding masked operations to OpenMP Dialect (PR #96022)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Jun 18 22:08:50 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-openmp
Author: Anchu Rajendran S (anchuraj)
<details>
<summary>Changes</summary>
Adding MLIR Op support for omp masked. Omp masked is introduced in 5.2 standard and allows a parallel region to be executed by threads specified by a programmer. This is achieved with the help of filter clause which helps to specify thread id expected to execute the region.
---
Full diff: https://github.com/llvm/llvm-project/pull/96022.diff
2 Files Affected:
- (modified) mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td (+21)
- (modified) mlir/test/Dialect/OpenMP/ops.mlir (+15)
``````````diff
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index 122abbe7cc975..08a89e18510a7 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -2179,4 +2179,25 @@ def ReductionOp : OpenMP_Op<"reduction"> {
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 0d5fd9383a92f..fe24b6484f292 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
``````````
</details>
https://github.com/llvm/llvm-project/pull/96022
More information about the Mlir-commits
mailing list