Add gpu.launch_func builder.

--

PiperOrigin-RevId: 247364893
This commit is contained in:
Thomas Joerg 2019-05-08 23:37:57 -07:00 committed by Mehdi Amini
parent e05eda9d22
commit 530439075a
2 changed files with 18 additions and 0 deletions

View File

@ -104,6 +104,11 @@ class LaunchFuncOp : public Op<LaunchFuncOp, OpTrait::AtLeastNOperands<6>::Impl,
public:
using Op::Op;
static void build(Builder *builder, OperationState *result,
Function *kernelFunc, Value *gridSizeX, Value *gridSizeY,
Value *gridSizeZ, Value *blockSizeX, Value *blockSizeY,
Value *blockSizeZ, ArrayRef<Value *> kernelOperands);
/// The kernel function specified by the operation's `kernel` attribute.
Function *kernel();
/// The number of operands passed to the kernel function.

View File

@ -268,6 +268,19 @@ ParseResult LaunchOp::parse(OpAsmParser *parser, OperationState *result) {
//===----------------------------------------------------------------------===//
// LaunchFuncOp
//===----------------------------------------------------------------------===//
void LaunchFuncOp::build(Builder *builder, OperationState *result,
Function *kernelFunc, Value *gridSizeX,
Value *gridSizeY, Value *gridSizeZ, Value *blockSizeX,
Value *blockSizeY, Value *blockSizeZ,
ArrayRef<Value *> kernelOperands) {
// Add grid and block sizes as op operands, followed by the data operands.
result->addOperands(
{gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ});
result->addOperands(kernelOperands);
result->addAttribute("kernel", builder->getFunctionAttr(kernelFunc));
}
Function *LaunchFuncOp::kernel() {
return this->getAttr("kernel").dyn_cast<FunctionAttr>().getValue();
}