[Mlir-commits] [mlir] dbb5979 - [MLIR][OpenMP] Defined master operation in OpenMP Dialect

Anchu Rajendran llvmlistbot at llvm.org
Fri May 29 10:16:57 PDT 2020


Author: Anchu Rajendran
Date: 2020-05-29T22:46:02+05:30
New Revision: dbb5979d158cd7c49fdb31a03a4a73dfb402cf66

URL: https://github.com/llvm/llvm-project/commit/dbb5979d158cd7c49fdb31a03a4a73dfb402cf66
DIFF: https://github.com/llvm/llvm-project/commit/dbb5979d158cd7c49fdb31a03a4a73dfb402cf66.diff

LOG: [MLIR][OpenMP] Defined master operation in OpenMP Dialect

Summary:
Implemented the basic changes for defining master operation in OpenMP.
It uses the generic parser and printer.

Reviewed By: kiranchandramohan, ftynse

Differential Revision: https://reviews.llvm.org/D80689

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
    mlir/test/Dialect/OpenMP/ops.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index 27b2110bf71e..78b56cac1353 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -94,7 +94,7 @@ def ParallelOp : OpenMP_Op<"parallel", [AttrSizedOperandSegments]> {
 }
 
 def TerminatorOp : OpenMP_Op<"terminator", [Terminator]> {
-  let summary = "terminator for OpenMP regions.";
+  let summary = "terminator for OpenMP regions";
   let description = [{
     A terminator operation for regions that appear in the body of OpenMP
     operation.  These regions are not expected to return any value so the
@@ -102,8 +102,7 @@ def TerminatorOp : OpenMP_Op<"terminator", [Terminator]> {
     enclosing op.
   }];
 
-  let parser = [{ return success(); }];
-  let printer = [{ p << getOperationName(); }];
+  let assemblyFormat = "attr-dict";
 }
 
 //===----------------------------------------------------------------------===//
@@ -137,6 +136,19 @@ def FlushOp : OpenMP_Op<"flush"> {
   let assemblyFormat = "attr-dict ($varList^ `:` type($varList))?";
 }
 
+//===----------------------------------------------------------------------===//
+// 2.16 master Construct
+//===----------------------------------------------------------------------===//
+def MasterOp : OpenMP_Op<"master"> {
+  let summary = "master construct";
+  let description = [{
+    The master construct specifies a structured block that is executed by
+    the master thread of the team.
+  }];
+
+  let regions = (region AnyRegion:$region);
+}
+
 //===----------------------------------------------------------------------===//
 // 2.17.2 barrier Construct
 //===----------------------------------------------------------------------===//

diff  --git a/mlir/test/Dialect/OpenMP/ops.mlir b/mlir/test/Dialect/OpenMP/ops.mlir
index bffc82417761..e780cebd93fa 100644
--- a/mlir/test/Dialect/OpenMP/ops.mlir
+++ b/mlir/test/Dialect/OpenMP/ops.mlir
@@ -6,6 +6,15 @@ func @omp_barrier() -> () {
   return
 }
 
+func @omp_master() -> () {
+  // CHECK: omp.master
+  "omp.master" ()({
+    // CHECK: omp.terminator
+    omp.terminator
+  }):()->()
+  return
+}
+
 func @omp_taskwait() -> () {
   // CHECK: omp.taskwait
   omp.taskwait
@@ -42,7 +51,7 @@ func @omp_terminator() -> () {
 }
 
 func @omp_parallel(%data_var : memref<i32>, %if_cond : i1, %num_threads : si32) -> () {
-  // CHECK: omp_parallel
+  // CHECK: omp.parallel
   "omp.parallel" (%if_cond, %num_threads, %data_var, %data_var, %data_var, %data_var) ({
 
   // test without if condition


        


More information about the Mlir-commits mailing list