diff options
| author | George Karpenkov <cheshire@google.com> | 2019-09-19 14:33:54 -0700 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-09-19 14:34:30 -0700 |
| commit | 2df646bef6e7665fdb8523613d82e7d4a5013217 (patch) | |
| tree | 3bcbbee989db665c23fa9d9fef9131cfaf549e85 /mlir/lib/Dialect/GPU/Transforms | |
| parent | c8961d408ee0f48e3156e3c4248bba9a43579f1f (diff) | |
| download | bcm5719-llvm-2df646bef6e7665fdb8523613d82e7d4a5013217.tar.gz bcm5719-llvm-2df646bef6e7665fdb8523613d82e7d4a5013217.zip | |
Automated rollback of commit 5684a12434f923d03b6870f2aa16226bfb0b38b6
PiperOrigin-RevId: 270126672
Diffstat (limited to 'mlir/lib/Dialect/GPU/Transforms')
| -rw-r--r-- | mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp | 37 |
1 files changed, 4 insertions, 33 deletions
diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp index 9bf4cf6e643..4328fb39c29 100644 --- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp @@ -93,7 +93,7 @@ static gpu::LaunchFuncOp inlineConstants(FuncOp kernelFunc, } // Outline the `gpu.launch` operation body into a kernel function. Replace -// `gpu.return` operations by `std.return` in the generated function. +// `gpu.return` operations by `std.return` in the generated functions. static FuncOp outlineKernelFunc(gpu::LaunchOp launchOp) { Location loc = launchOp.getLoc(); SmallVector<Type, 4> kernelOperandTypes(launchOp.getKernelOperandTypes()); @@ -107,7 +107,7 @@ static FuncOp outlineKernelFunc(gpu::LaunchOp launchOp) { outlinedFunc.setAttr(gpu::GPUDialect::getKernelFuncAttrName(), builder.getUnitAttr()); injectGpuIndexOperations(loc, outlinedFunc); - outlinedFunc.walk([](gpu::Return op) { + outlinedFunc.walk([](mlir::gpu::Return op) { OpBuilder replacer(op); replacer.create<ReturnOp>(op.getLoc()); op.erase(); @@ -131,44 +131,15 @@ static void convertToLaunchFuncOp(gpu::LaunchOp &launchOp, FuncOp kernelFunc) { namespace { -/// Pass that moves the kernel of each LaunchOp into its separate nested module. -/// -/// This pass moves the kernel code of each LaunchOp into a function created -/// inside a nested module. It also creates an external function of the same -/// name in the parent module. -/// -/// The kernel modules are intended to be compiled to a cubin blob independently -/// in a separate pass. The external functions can then be annotated with the -/// symbol of the cubin accessor function. class GpuKernelOutliningPass : public ModulePass<GpuKernelOutliningPass> { public: void runOnModule() override { ModuleManager moduleManager(getModule()); - auto context = getModule().getContext(); - Builder builder(context); for (auto func : getModule().getOps<FuncOp>()) { - // Insert just after the function. - Block::iterator insertPt(func.getOperation()->getNextNode()); - func.walk([&](gpu::LaunchOp op) { - // TODO(b/141098412): Handle called functions and globals. + func.walk([&](mlir::gpu::LaunchOp op) { FuncOp outlinedFunc = outlineKernelFunc(op); - - // Potentially renames outlinedFunc to make symbol unique. - moduleManager.insert(insertPt, outlinedFunc); - - // Potentially changes signature, pulling in constants. + moduleManager.insert(outlinedFunc); convertToLaunchFuncOp(op, outlinedFunc); - - // Create clone and move body from outlinedFunc. - auto kernelFunc = outlinedFunc.cloneWithoutRegions(); - kernelFunc.getBody().takeBody(outlinedFunc.getBody()); - - // Create nested module and insert kernelFunc. - auto kernelModule = ModuleOp::create(UnknownLoc::get(context)); - kernelModule.setAttr(gpu::GPUDialect::getKernelModuleAttrName(), - builder.getUnitAttr()); - kernelModule.push_back(kernelFunc); - getModule().insert(insertPt, kernelModule); }); } } |

