Skip to content

Commit dd04668

Browse files
[mlir][gpu] Refactor GpuOpsToROCDLOps pass interface (NFC) (#157402)
This PR deletes the `createLowerGpuOpsToROCDLOpsPass` constructor from the .td file, making the `createConvertGpuOpsToROCDLOps` pass available to users. This has the following effects: 1. `createLowerGpuOpsToROCDLOpsPass` is not available anymore. Instead, `createConvertGpuOpsToROCDLOps` should be used. This makes the interface consistent with ConvertGpuOpsToNVVMOps. 2. To call `createConvertGpuOpsToROCDLOps`, the options must be passed via ConvertGpuOpsToROCDLOpsOptions. This has the side effect of making the `allowed-dialects` option available, which was not accessible via C++ before.
1 parent 253d18d commit dd04668

File tree

3 files changed

+2
-34
lines changed

3 files changed

+2
-34
lines changed

mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <memory>
1414

1515
namespace mlir {
16+
class Pass;
1617
class LLVMTypeConverter;
1718
class ConversionTarget;
1819
class RewritePatternSet;
@@ -42,16 +43,6 @@ void populateGpuToROCDLConversionPatterns(const LLVMTypeConverter &converter,
4243
/// Configure target to convert from the GPU dialect to ROCDL.
4344
void configureGpuToROCDLConversionLegality(ConversionTarget &target);
4445

45-
/// Creates a pass that lowers GPU dialect operations to ROCDL counterparts. The
46-
/// index bitwidth used for the lowering of the device side index computations
47-
/// is configurable.
48-
std::unique_ptr<OperationPass<gpu::GPUModuleOp>>
49-
createLowerGpuOpsToROCDLOpsPass(
50-
const std::string &chipset = "gfx900",
51-
unsigned indexBitwidth = kDeriveIndexBitwidthFromDataLayout,
52-
bool useBarePtrCallConv = false,
53-
gpu::amd::Runtime runtime = gpu::amd::Runtime::Unknown);
54-
5546
} // namespace mlir
5647

5748
#endif // MLIR_CONVERSION_GPUTOROCDL_GPUTOROCDLPASS_H_

mlir/include/mlir/Conversion/Passes.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,6 @@ def ConvertGpuOpsToNVVMOps : Pass<"convert-gpu-to-nvvm", "gpu::GPUModuleOp"> {
624624

625625
def ConvertGpuOpsToROCDLOps : Pass<"convert-gpu-to-rocdl", "gpu::GPUModuleOp"> {
626626
let summary = "Generate ROCDL operations for gpu operations";
627-
let constructor = "mlir::createLowerGpuOpsToROCDLOpsPass()";
628627
let dependentDialects = [
629628
"ROCDL::ROCDLDialect",
630629
"amdgpu::AMDGPUDialect",

mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "mlir/Dialect/MemRef/IR/MemRef.h"
3737
#include "mlir/Dialect/Vector/IR/VectorOps.h"
3838
#include "mlir/IR/BuiltinAttributes.h"
39-
#include "mlir/Pass/Pass.h"
4039
#include "mlir/Transforms/DialectConversion.h"
4140
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
4241

@@ -287,19 +286,7 @@ struct GPUShuffleOpLowering : public ConvertOpToLLVMPattern<gpu::ShuffleOp> {
287286
// code.
288287
struct LowerGpuOpsToROCDLOpsPass final
289288
: public impl::ConvertGpuOpsToROCDLOpsBase<LowerGpuOpsToROCDLOpsPass> {
290-
LowerGpuOpsToROCDLOpsPass() = default;
291-
LowerGpuOpsToROCDLOpsPass(const std::string &chipset, unsigned indexBitwidth,
292-
bool useBarePtrCallConv,
293-
gpu::amd::Runtime runtime) {
294-
if (this->chipset.getNumOccurrences() == 0)
295-
this->chipset = chipset;
296-
if (this->indexBitwidth.getNumOccurrences() == 0)
297-
this->indexBitwidth = indexBitwidth;
298-
if (this->useBarePtrCallConv.getNumOccurrences() == 0)
299-
this->useBarePtrCallConv = useBarePtrCallConv;
300-
if (this->runtime.getNumOccurrences() == 0)
301-
this->runtime = runtime;
302-
}
289+
using Base::Base;
303290

304291
void getDependentDialects(DialectRegistry &registry) const override {
305292
Base::getDependentDialects(registry);
@@ -499,12 +486,3 @@ void mlir::populateGpuToROCDLConversionPatterns(
499486

500487
populateMathToROCDLConversionPatterns(converter, patterns);
501488
}
502-
503-
std::unique_ptr<OperationPass<gpu::GPUModuleOp>>
504-
mlir::createLowerGpuOpsToROCDLOpsPass(const std::string &chipset,
505-
unsigned indexBitwidth,
506-
bool useBarePtrCallConv,
507-
gpu::amd::Runtime runtime) {
508-
return std::make_unique<LowerGpuOpsToROCDLOpsPass>(
509-
chipset, indexBitwidth, useBarePtrCallConv, runtime);
510-
}

0 commit comments

Comments
 (0)