diff options
| author | Alex Zinenko <zinenko@google.com> | 2019-07-12 05:36:55 -0700 |
|---|---|---|
| committer | jpienaar <jpienaar@google.com> | 2019-07-12 08:44:14 -0700 |
| commit | 2178467dca97af5ffd7edf1681bc5a8425ae86ee (patch) | |
| tree | 3b104fe7d040860039a9801b6a6dacfc3bdf0a6d /mlir/lib/Conversion/LoopsToGPU | |
| parent | f20f347fdb11487d8970e2868d89fd18eef05261 (diff) | |
| download | bcm5719-llvm-2178467dca97af5ffd7edf1681bc5a8425ae86ee.tar.gz bcm5719-llvm-2178467dca97af5ffd7edf1681bc5a8425ae86ee.zip | |
LoopsToGPU: use PassRegistration with constructor
PassRegistration with an optional constructor was introduced after the
LoopsToGPUPass, which resorted to deriving one pass from another as a means of
accepting options supplied as command-line arguments. Use PassRegistration with
constructor instead of defining a derived pass for LoopsToGPU. Also rename the
pass to better reflect its current nature.
PiperOrigin-RevId: 257786923
Diffstat (limited to 'mlir/lib/Conversion/LoopsToGPU')
| -rw-r--r-- | mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp index a8ef3d36772..13e4171033e 100644 --- a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp +++ b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp @@ -41,8 +41,8 @@ namespace { // A pass that traverses top-level loops in the function and converts them to // GPU launch operations. Nested launches are not allowed, so this does not // walk the function recursively to avoid considering nested loops. -struct AffineForGPUMapper : public FunctionPass<AffineForGPUMapper> { - AffineForGPUMapper(unsigned numBlockDims, unsigned numThreadDims) +struct ForLoopMapper : public FunctionPass<ForLoopMapper> { + ForLoopMapper(unsigned numBlockDims, unsigned numThreadDims) : numBlockDims(numBlockDims), numThreadDims(numThreadDims) {} void runOnFunction() override { @@ -63,18 +63,15 @@ struct AffineForGPUMapper : public FunctionPass<AffineForGPUMapper> { unsigned numBlockDims; unsigned numThreadDims; }; - -struct AffineForGPUMapperCLI : public AffineForGPUMapper { - AffineForGPUMapperCLI() - : AffineForGPUMapper(clNumBlockDims.getValue(), - clNumThreadDims.getValue()) {} -}; } // namespace FunctionPassBase *mlir::createSimpleLoopsToGPUPass(unsigned numBlockDims, unsigned numThreadDims) { - return new AffineForGPUMapper(numBlockDims, numThreadDims); + return new ForLoopMapper(numBlockDims, numThreadDims); } -static PassRegistration<AffineForGPUMapperCLI> - registration(PASS_NAME, "Convert top-level loops to GPU kernels"); +static PassRegistration<ForLoopMapper> + registration(PASS_NAME, "Convert top-level loops to GPU kernels", [] { + return new ForLoopMapper(clNumBlockDims.getValue(), + clNumThreadDims.getValue()); + }); |

