diff options
| author | Tres Popp <tpopp@google.com> | 2020-01-14 11:09:59 +0100 |
|---|---|---|
| committer | Stephan Herhut <herhut@google.com> | 2020-01-14 12:05:47 +0100 |
| commit | 4624a1e8ac8a3f69cc887403b976f538f587744a (patch) | |
| tree | 13cb3b1371abedefbdbd7e09933633acc4aca44c /mlir/lib/Dialect/GPU/Transforms | |
| parent | 9492e9d8cfd356109276da5aa926b297db0e16db (diff) | |
| download | bcm5719-llvm-4624a1e8ac8a3f69cc887403b976f538f587744a.tar.gz bcm5719-llvm-4624a1e8ac8a3f69cc887403b976f538f587744a.zip | |
[mlir] Create a gpu.module operation for the GPU Dialect.
Summary:
This is based on the use of code constantly checking for an attribute on
a model and instead represents the distinct operaion with a different
op. Instead, this op can be used to provide better filtering.
Reviewers: herhut, mravishankar, antiagainst, rriddle
Reviewed By: herhut, antiagainst, rriddle
Subscribers: liufengdb, aartbik, jholewinski, mgorny, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, csigg, arpith-jacob, mgester, lucyrfox, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D72336
Diffstat (limited to 'mlir/lib/Dialect/GPU/Transforms')
| -rw-r--r-- | mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp index 37f9c2e7b84..0f8e2253980 100644 --- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp @@ -140,8 +140,8 @@ namespace { /// 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 +/// The gpu.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: @@ -174,15 +174,19 @@ public: } private: - // Returns a module containing kernelFunc and all callees (recursive). - ModuleOp createKernelModule(gpu::GPUFuncOp kernelFunc, - const SymbolTable &parentSymbolTable) { + // Returns a gpu.module containing kernelFunc and all callees (recursive). + gpu::GPUModuleOp createKernelModule(gpu::GPUFuncOp kernelFunc, + const SymbolTable &parentSymbolTable) { + // TODO: This code cannot use an OpBuilder because it must be inserted into + // a SymbolTable by the caller. SymbolTable needs to be refactored to + // prevent manual building of Ops with symbols in code using SymbolTables + // and then this needs to use the OpBuilder. auto context = getModule().getContext(); Builder builder(context); - auto kernelModule = - ModuleOp::create(builder.getUnknownLoc(), kernelFunc.getName()); - kernelModule.setAttr(gpu::GPUDialect::getKernelModuleAttrName(), - builder.getUnitAttr()); + OperationState state(kernelFunc.getLoc(), + gpu::GPUModuleOp::getOperationName()); + gpu::GPUModuleOp::build(&builder, state, kernelFunc.getName()); + auto kernelModule = cast<gpu::GPUModuleOp>(Operation::create(state)); SymbolTable symbolTable(kernelModule); symbolTable.insert(kernelFunc); |

