[Mlir-commits] [mlir] c2fd2b5 - [MLIR][OpenMP]Basic OpenMP target operation
Kiran Chandramohan
llvmlistbot at llvm.org
Thu Jun 24 01:58:48 PDT 2021
Author: Abid Malik
Date: 2021-06-24T09:58:25+01:00
New Revision: c2fd2b5194eee8a0935739c862efb8f98a0bcd4b
URL: https://github.com/llvm/llvm-project/commit/c2fd2b5194eee8a0935739c862efb8f98a0bcd4b
DIFF: https://github.com/llvm/llvm-project/commit/c2fd2b5194eee8a0935739c862efb8f98a0bcd4b.diff
LOG: [MLIR][OpenMP]Basic OpenMP target operation
This includes a basic implementation for the OpenMP target
operation. Currently, the if, thread_limit, private, shared, device, and nowait clauses are included in this implementation.
Co-authored-by: Kiran Chandramohan <kiran.chandramohan at arm.com>
Reviewed By: ftynse, kiranchandramohan
Differential Revision: https://reviews.llvm.org/D102816
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 087d10d143980..8eaaf971f3fdb 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -256,6 +256,40 @@ def FlushOp : OpenMP_Op<"flush"> {
let assemblyFormat = [{ ( `(` $varList^ `:` type($varList) `)` )? attr-dict}];
}
+//===----------------------------------------------------------------------===//
+// 2.14.5 target construct
+//===----------------------------------------------------------------------===//
+
+def TargetOp : OpenMP_Op<"target",[AttrSizedOperandSegments]> {
+ let summary = "target construct";
+ let description = [{
+ The target construct includes a region of code which is to be executed
+ on a device.
+
+ The optional $if_expr parameter specifies a boolean result of a
+ conditional check. If this value is 1 or is not provided then the target
+ region runs on a device, if it is 0 then the target region is executed on the
+ host device.
+
+ The optional $device parameter specifies the device number for the target region.
+
+ The optional $thread_limit specifies the limit on the number of threads
+
+ The optional $nowait elliminates the implicit barrier so the parent task can make progress
+ even if the target task is not yet completed.
+
+ TODO: private, map, is_device_ptr, firstprivate, depend, defaultmap, in_reduction
+
+ }];
+
+ let arguments = (ins Optional<I1>:$if_expr,
+ Optional<AnyInteger>:$device,
+ Optional<AnyInteger>:$thread_limit,
+ UnitAttr:$nowait);
+
+ let regions = (region AnyRegion:$region);
+}
+
//===----------------------------------------------------------------------===//
// 2.16 master Construct
diff --git a/mlir/test/Dialect/OpenMP/ops.mlir b/mlir/test/Dialect/OpenMP/ops.mlir
index 8f7f9c1ca69ca..f23ddf9df0f73 100644
--- a/mlir/test/Dialect/OpenMP/ops.mlir
+++ b/mlir/test/Dialect/OpenMP/ops.mlir
@@ -278,3 +278,19 @@ func @omp_wsloop_pretty_multiple(%lb1 : i32, %ub1 : i32, %step1 : i32, %lb2 : i3
return
}
+
+// CHECK-LABEL: omp_target
+func @omp_target(%if_cond : i1, %device : si32, %num_threads : si32) -> () {
+
+ // Test with optional operands; if_expr, device, thread_limit, and nowait.
+ // CHECK: omp.target
+ "omp.target"(%if_cond, %device, %num_threads) ({
+ // CHECK: omp.terminator
+ omp.terminator
+ }) {operand_segment_sizes = dense<[1,1,1]>: vector<3xi32>, nowait } : ( i1, si32, si32 ) -> ()
+
+ // CHECK: omp.barrier
+ omp.barrier
+
+ return
+}
More information about the Mlir-commits
mailing list