Skip to content

Commit 8f37fb2

Browse files
[mlir][acc] Add MappableType API for generating private recipe init (#148293)
This introduces the first in a series of APIs that will allow a MappableType to generate the body of the recipes. The current API does not actually generate the recipe itself - it generates the body of it. So it can either be placed in a recipe or inlined directly as needed.
1 parent 15d36aa commit 8f37fb2

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

mlir/include/mlir/Dialect/OpenACC/OpenACCTypeInterfaces.td

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,36 @@ def OpenACC_MappableTypeInterface : TypeInterface<"MappableType"> {
180180
return ::mlir::acc::VariableTypeCategory::uncategorized;
181181
}]
182182
>,
183+
InterfaceMethod<
184+
/*description=*/[{
185+
Generates the operations that would be normally placed in a recipe's
186+
init region. It inserts at the builder's current location.
187+
It can be used either to directly "inline" the init region
188+
or if the caller sets the insertion point to inside a recipe body,
189+
it fills it in. This does not generate the `acc.yield` that normally
190+
would terminate a recipe.
191+
192+
The `extents` are optional and can be empty - it is only when a
193+
slice of the private variable needs allocation.
194+
The `initVal` can be empty - it is primarily needed for reductions
195+
to ensure the variable is also initialized with appropriate value.
196+
197+
If the return value is empty, it means that recipe body was not
198+
successfully generated.
199+
}],
200+
/*retTy=*/"::mlir::Value",
201+
/*methodName=*/"generatePrivateInit",
202+
/*args=*/(ins "::mlir::OpBuilder &":$builder,
203+
"::mlir::Location":$loc,
204+
"::mlir::TypedValue<::mlir::acc::MappableType>":$var,
205+
"::llvm::StringRef":$varName,
206+
"::mlir::ValueRange":$extents,
207+
"::mlir::Value":$initVal),
208+
/*methodBody=*/"",
209+
/*defaultImplementation=*/[{
210+
return {};
211+
}]
212+
>,
183213
];
184214
}
185215

0 commit comments

Comments
 (0)