[Mlir-commits] [mlir] [MLIR][OpenMP] Add a new ComposableLoopWrapperInterface to check/set a composite unitAttr. (PR #101991)
Akash Banerjee
llvmlistbot at llvm.org
Mon Aug 5 07:34:27 PDT 2024
https://github.com/TIFitis created https://github.com/llvm/llvm-project/pull/101991
None
>From 6687d80c74290ce9d3a0096b84bd2a1829d0a754 Mon Sep 17 00:00:00 2001
From: Akash Banerjee <Akash.Banerjee at amd.com>
Date: Mon, 5 Aug 2024 15:31:25 +0100
Subject: [PATCH] [MLIR][OpenMP] Add a new ComposableLoopWrapperInterface to
check and set a composite unitAttr.
---
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | 9 +++--
.../Dialect/OpenMP/OpenMPOpsInterfaces.td | 34 +++++++++++++++++++
2 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index 68f92e6952694..44210025dfe18 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -129,6 +129,7 @@ def PrivateClauseOp : OpenMP_Op<"private", [IsolatedFromAbove, RecipeInterface]>
def ParallelOp : OpenMP_Op<"parallel", traits = [
AttrSizedOperandSegments, AutomaticAllocationScope,
DeclareOpInterfaceMethods<LoopWrapperInterface>,
+ DeclareOpInterfaceMethods<ComposableLoopWrapperInterface>,
DeclareOpInterfaceMethods<OutlineableOpenMPOpInterface>,
RecursiveMemoryEffects
], clauses = [
@@ -357,6 +358,7 @@ def LoopNestOp : OpenMP_Op<"loop_nest", traits = [
def WsloopOp : OpenMP_Op<"wsloop", traits = [
AttrSizedOperandSegments, DeclareOpInterfaceMethods<LoopWrapperInterface>,
+ DeclareOpInterfaceMethods<ComposableLoopWrapperInterface>,
RecursiveMemoryEffects, SingleBlock
], clauses = [
OpenMP_AllocateClauseSkip<assemblyFormat = true>,
@@ -433,6 +435,7 @@ def WsloopOp : OpenMP_Op<"wsloop", traits = [
def SimdOp : OpenMP_Op<"simd", traits = [
AttrSizedOperandSegments, DeclareOpInterfaceMethods<LoopWrapperInterface>,
+ DeclareOpInterfaceMethods<ComposableLoopWrapperInterface>,
RecursiveMemoryEffects, SingleBlock
], clauses = [
OpenMP_AlignedClause, OpenMP_IfClause, OpenMP_LinearClause,
@@ -500,6 +503,7 @@ def YieldOp : OpenMP_Op<"yield",
//===----------------------------------------------------------------------===//
def DistributeOp : OpenMP_Op<"distribute", traits = [
AttrSizedOperandSegments, DeclareOpInterfaceMethods<LoopWrapperInterface>,
+ DeclareOpInterfaceMethods<ComposableLoopWrapperInterface>,
RecursiveMemoryEffects, SingleBlock
], clauses = [
OpenMP_AllocateClause, OpenMP_DistScheduleClause, OpenMP_OrderClause,
@@ -587,8 +591,9 @@ def TaskOp : OpenMP_Op<"task", traits = [
def TaskloopOp : OpenMP_Op<"taskloop", traits = [
AttrSizedOperandSegments, AutomaticAllocationScope,
- DeclareOpInterfaceMethods<LoopWrapperInterface>, RecursiveMemoryEffects,
- SingleBlock
+ DeclareOpInterfaceMethods<LoopWrapperInterface>,
+ DeclareOpInterfaceMethods<ComposableLoopWrapperInterface>,
+ RecursiveMemoryEffects, SingleBlock
], clauses = [
OpenMP_AllocateClause, OpenMP_FinalClause, OpenMP_GrainsizeClause,
OpenMP_IfClause, OpenMP_InReductionClauseSkip<extraClassDeclaration = true>,
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
index 2d1de37239c82..50394eaf236f9 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
@@ -142,6 +142,40 @@ def LoopWrapperInterface : OpInterface<"LoopWrapperInterface"> {
];
}
+def ComposableLoopWrapperInterface : OpInterface<"ComposableLoopWrapperInterface"> {
+ let description = [{
+ OpenMP operations that can wrap a single loop nest. When taking a wrapper
+ role, these operations must only contain a single region with a single block
+ in which there's a single operation and a terminator. That nested operation
+ must be another loop wrapper or an `omp.loop_nest`.
+ }];
+
+ let cppNamespace = "::mlir::omp";
+
+ let methods = [
+ InterfaceMethod<
+ /*description=*/[{
+ Check whether the operation is composable.
+ }],
+ /*retTy=*/"bool",
+ /*methodName=*/"isComposite",
+ (ins ), [{}], [{
+ return $_op->hasAttr("omp.composite");
+ }]
+ >,
+ InterfaceMethod<
+ /*description=*/[{
+ Set the CompositeAttr for the op.
+ }],
+ /*retTy=*/"void",
+ /*methodName=*/"setComposite",
+ (ins), [{}], [{
+ $_op->setDiscardableAttr("omp.composite", mlir::UnitAttr::get($_op->getContext()));
+ }]
+ >
+ ];
+}
+
def DeclareTargetInterface : OpInterface<"DeclareTargetInterface"> {
let description = [{
OpenMP operations that support declare target have this interface.
More information about the Mlir-commits
mailing list