Skip to content

Commit 556a645

Browse files
authored
[MLIR][NFC] Retire let constructor for GPU (#129849)
`let constructor` is legacy (do not use in tree!) since the table gen backend emits most of the glue logic to build a pass.
1 parent 5ce4045 commit 556a645

File tree

6 files changed

+18
-70
lines changed

6 files changed

+18
-70
lines changed

mlir/include/mlir/Dialect/GPU/Transforms/Passes.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,6 @@ class FuncOp;
3535
#define GEN_PASS_DECL
3636
#include "mlir/Dialect/GPU/Transforms/Passes.h.inc"
3737

38-
/// Pass that moves ops which are likely an index computation into gpu.launch
39-
/// body.
40-
std::unique_ptr<Pass> createGpuLauchSinkIndexComputationsPass();
41-
42-
/// Replaces `gpu.launch` with `gpu.launch_func` by moving the region into
43-
/// a separate kernel function.
44-
std::unique_ptr<OperationPass<ModuleOp>>
45-
createGpuKernelOutliningPass(StringRef dataLayoutStr = StringRef());
46-
47-
/// Rewrites a function region so that GPU ops execute asynchronously.
48-
std::unique_ptr<OperationPass<func::FuncOp>> createGpuAsyncRegionPass();
49-
50-
/// Maps the parallel loops found in the given function to workgroups. The first
51-
/// loop encountered will be mapped to the global workgroup and the second loop
52-
/// encountered to the local workgroup. Within each mapping, the first three
53-
/// dimensions are mapped to x/y/z hardware ids and all following dimensions are
54-
/// mapped to sequential loops.
55-
std::unique_ptr<OperationPass<func::FuncOp>> createGpuMapParallelLoopsPass();
56-
5738
/// Collect a set of patterns to rewrite GlobalIdOp op within the GPU dialect.
5839
void populateGpuGlobalIdPatterns(RewritePatternSet &patterns);
5940

@@ -110,9 +91,6 @@ LogicalResult transformGpuModulesToBinaries(
11091
/// Collect a set of patterns to decompose memrefs ops.
11192
void populateGpuDecomposeMemrefsPatterns(RewritePatternSet &patterns);
11293

113-
/// Pass decomposes memref ops inside `gpu.launch` body.
114-
std::unique_ptr<Pass> createGpuDecomposeMemrefsPass();
115-
11694
/// Erase barriers that do not enforce conflicting memory side effects.
11795
void populateGpuEliminateBarriersPatterns(RewritePatternSet &patterns);
11896

mlir/include/mlir/Dialect/GPU/Transforms/Passes.td

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,35 @@
1111

1212
include "mlir/Pass/PassBase.td"
1313

14-
def GpuLaunchSinkIndexComputations : Pass<"gpu-launch-sink-index-computations"> {
14+
def GpuLaunchSinkIndexComputationsPass
15+
: Pass<"gpu-launch-sink-index-computations"> {
1516
let summary = "Sink index computations into gpu.launch body";
16-
let constructor = "mlir::createGpuLauchSinkIndexComputationsPass()";
1717
let dependentDialects = ["mlir::gpu::GPUDialect"];
1818
}
1919

20-
def GpuKernelOutlining : Pass<"gpu-kernel-outlining", "ModuleOp"> {
20+
def GpuKernelOutliningPass : Pass<"gpu-kernel-outlining", "ModuleOp"> {
2121
let summary = "Outline gpu.launch bodies to kernel functions";
22-
let constructor = "mlir::createGpuKernelOutliningPass()";
2322
let dependentDialects = ["mlir::DLTIDialect", "cf::ControlFlowDialect"];
23+
let options = [Option<"dataLayoutStr", "data-layout-str", "std::string",
24+
/*default=*/"",
25+
"String description of the data layout">];
2426
}
2527

2628
def GpuAsyncRegionPass : Pass<"gpu-async-region", "func::FuncOp"> {
2729
let summary = "Make GPU ops async";
28-
let constructor = "mlir::createGpuAsyncRegionPass()";
2930
let dependentDialects = ["async::AsyncDialect"];
3031
}
3132

3233
def GpuMapParallelLoopsPass
3334
: Pass<"gpu-map-parallel-loops", "mlir::func::FuncOp"> {
3435
let summary = "Greedily maps loops to GPU hardware dimensions.";
35-
let constructor = "mlir::createGpuMapParallelLoopsPass()";
36-
let description = "Greedily maps loops to GPU hardware dimensions.";
36+
let description = [{
37+
Maps the parallel loops found in the given function to workgroups. The first
38+
loop encountered will be mapped to the global workgroup and the second loop
39+
encountered to the local workgroup. Within each mapping, the first three
40+
dimensions are mapped to x/y/z hardware ids and all following dimensions are
41+
mapped to sequential loops.
42+
}];
3743
let dependentDialects = ["mlir::gpu::GPUDialect"];
3844
}
3945

@@ -66,7 +72,6 @@ def GpuDecomposeMemrefsPass : Pass<"gpu-decompose-memrefs"> {
6672
and sizes/strides for dynamically-sized memrefs are not available inside
6773
`gpu.launch`.
6874
}];
69-
let constructor = "mlir::createGpuDecomposeMemrefsPass()";
7075
let dependentDialects = [
7176
"mlir::gpu::GPUDialect", "mlir::memref::MemRefDialect",
7277
"mlir::affine::AffineDialect"

mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,3 @@ void GpuAsyncRegionPass::runOnOperation() {
347347
// Makes each !gpu.async.token returned from async.execute op have single use.
348348
getOperation().getRegion().walk(SingleTokenUseCallback());
349349
}
350-
351-
std::unique_ptr<OperationPass<func::FuncOp>> mlir::createGpuAsyncRegionPass() {
352-
return std::make_unique<GpuAsyncRegionPass>();
353-
}

mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,3 @@ void mlir::populateGpuDecomposeMemrefsPatterns(RewritePatternSet &patterns) {
238238
patterns.insert<FlattenLoad, FlattenStore, FlattenSubview>(
239239
patterns.getContext());
240240
}
241-
242-
std::unique_ptr<Pass> mlir::createGpuDecomposeMemrefsPass() {
243-
return std::make_unique<GpuDecomposeMemrefsPass>();
244-
}

mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
#include <limits>
3131

3232
namespace mlir {
33-
#define GEN_PASS_DEF_GPULAUNCHSINKINDEXCOMPUTATIONS
34-
#define GEN_PASS_DEF_GPUKERNELOUTLINING
33+
#define GEN_PASS_DEF_GPULAUNCHSINKINDEXCOMPUTATIONSPASS
34+
#define GEN_PASS_DEF_GPUKERNELOUTLININGPASS
3535
#include "mlir/Dialect/GPU/Transforms/Passes.h.inc"
3636
} // namespace mlir
3737

@@ -302,7 +302,7 @@ namespace {
302302
/// Pass that moves ops which are likely an index computation into gpu.launch
303303
/// body.
304304
class GpuLaunchSinkIndexComputationsPass
305-
: public impl::GpuLaunchSinkIndexComputationsBase<
305+
: public impl::GpuLaunchSinkIndexComputationsPassBase<
306306
GpuLaunchSinkIndexComputationsPass> {
307307
public:
308308
void runOnOperation() override {
@@ -329,17 +329,9 @@ class GpuLaunchSinkIndexComputationsPass
329329
/// a separate pass. The external functions can then be annotated with the
330330
/// symbol of the cubin accessor function.
331331
class GpuKernelOutliningPass
332-
: public impl::GpuKernelOutliningBase<GpuKernelOutliningPass> {
332+
: public impl::GpuKernelOutliningPassBase<GpuKernelOutliningPass> {
333333
public:
334-
GpuKernelOutliningPass(StringRef dlStr) {
335-
if (!dlStr.empty() && !dataLayoutStr.hasValue())
336-
dataLayoutStr = dlStr.str();
337-
}
338-
339-
GpuKernelOutliningPass(const GpuKernelOutliningPass &other)
340-
: GpuKernelOutliningBase(other), dataLayoutSpec(other.dataLayoutSpec) {
341-
dataLayoutStr = other.dataLayoutStr.getValue();
342-
}
334+
using Base::Base;
343335

344336
LogicalResult initialize(MLIRContext *context) override {
345337
// Initialize the data layout specification from the data layout string.
@@ -457,21 +449,7 @@ class GpuKernelOutliningPass
457449
return kernelModule;
458450
}
459451

460-
Option<std::string> dataLayoutStr{
461-
*this, "data-layout-str",
462-
llvm::cl::desc("String containing the data layout specification to be "
463-
"attached to the GPU kernel module")};
464-
465452
DataLayoutSpecInterface dataLayoutSpec;
466453
};
467454

468455
} // namespace
469-
470-
std::unique_ptr<Pass> mlir::createGpuLauchSinkIndexComputationsPass() {
471-
return std::make_unique<GpuLaunchSinkIndexComputationsPass>();
472-
}
473-
474-
std::unique_ptr<OperationPass<ModuleOp>>
475-
mlir::createGpuKernelOutliningPass(StringRef dataLayoutStr) {
476-
return std::make_unique<GpuKernelOutliningPass>(dataLayoutStr);
477-
}

mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,3 @@ struct GpuMapParallelLoopsPass
146146
} // namespace
147147
} // namespace gpu
148148
} // namespace mlir
149-
150-
std::unique_ptr<mlir::OperationPass<mlir::func::FuncOp>>
151-
mlir::createGpuMapParallelLoopsPass() {
152-
return std::make_unique<gpu::GpuMapParallelLoopsPass>();
153-
}

0 commit comments

Comments
 (0)