Skip to content

Commit 2208dbc

Browse files
committed
updates
1 parent 2fc9d61 commit 2208dbc

File tree

4 files changed

+25
-36
lines changed

4 files changed

+25
-36
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ void configureGpuToROCDLConversionLegality(ConversionTarget &target);
4343
/// index bitwidth used for the lowering of the device side index computations
4444
/// is configurable.
4545
std::unique_ptr<OperationPass<gpu::GPUModuleOp>>
46-
createLowerGpuOpsToROCDLOpsPass(
47-
const std::string &chipset = "gfx900",
48-
unsigned indexBitwidth = kDeriveIndexBitwidthFromDataLayout,
49-
bool useBarePtrCallConv = false,
50-
gpu::amd::Runtime runtime = gpu::amd::Runtime::Unknown);
46+
createLowerGpuOpsToROCDLOpsPass();
5147

5248
} // namespace mlir
5349

mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,11 @@ struct GPUSubgroupIdOpToROCDL final
203203
: ConvertOpToLLVMPattern<gpu::SubgroupIdOp> {
204204
using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern;
205205

206-
GPUSubgroupIdOpToROCDL(MLIRContext *ctx, mlir::amdgpu::Chipset chipset)
207-
: ConvertOpToLLVMPattern(ctx), chipset(chipset) {}
206+
GPUSubgroupIdOpToROCDL(const LLVMTypeConverter &converter,
207+
const mlir::amdgpu::Chipset &chipset)
208+
: ConvertOpToLLVMPattern(converter), chipset(chipset) {}
208209

209-
mlir::amdgpu::Chipset chipset;
210+
const mlir::amdgpu::Chipset chipset;
210211

211212
LogicalResult
212213
matchAndRewrite(gpu::SubgroupIdOp op, gpu::SubgroupIdOp::Adaptor adaptor,
@@ -235,19 +236,7 @@ struct GPUSubgroupIdOpToROCDL final
235236
// code.
236237
struct LowerGpuOpsToROCDLOpsPass final
237238
: public impl::ConvertGpuOpsToROCDLOpsBase<LowerGpuOpsToROCDLOpsPass> {
238-
LowerGpuOpsToROCDLOpsPass() = default;
239-
LowerGpuOpsToROCDLOpsPass(const std::string &chipset, unsigned indexBitwidth,
240-
bool useBarePtrCallConv,
241-
gpu::amd::Runtime runtime) {
242-
if (this->chipset.getNumOccurrences() == 0)
243-
this->chipset = chipset;
244-
if (this->indexBitwidth.getNumOccurrences() == 0)
245-
this->indexBitwidth = indexBitwidth;
246-
if (this->useBarePtrCallConv.getNumOccurrences() == 0)
247-
this->useBarePtrCallConv = useBarePtrCallConv;
248-
if (this->runtime.getNumOccurrences() == 0)
249-
this->runtime = runtime;
250-
}
239+
using Base::Base;
251240

252241
void getDependentDialects(DialectRegistry &registry) const override {
253242
Base::getDependentDialects(registry);
@@ -442,16 +431,11 @@ void mlir::populateGpuToROCDLConversionPatterns(
442431
patterns.add<GPUDynamicSharedMemoryOpLowering>(converter);
443432

444433
patterns.add<GPUShuffleOpLowering, GPULaneIdOpToROCDL>(converter);
445-
patterns.add(
446-
std::make_unique<GPUSubgroupIdOpToROCDL>(patterns.getContext(), chipset));
434+
patterns.add<GPUSubgroupIdOpToROCDL>(converter, chipset);
447435
populateMathToROCDLConversionPatterns(converter, patterns);
448436
}
449437

450438
std::unique_ptr<OperationPass<gpu::GPUModuleOp>>
451-
mlir::createLowerGpuOpsToROCDLOpsPass(const std::string &chipset,
452-
unsigned indexBitwidth,
453-
bool useBarePtrCallConv,
454-
gpu::amd::Runtime runtime) {
455-
return std::make_unique<LowerGpuOpsToROCDLOpsPass>(
456-
chipset, indexBitwidth, useBarePtrCallConv, runtime);
439+
mlir::createLowerGpuOpsToROCDLOpsPass() {
440+
return std::make_unique<LowerGpuOpsToROCDLOpsPass>();
457441
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: mlir-opt %s -convert-gpu-to-rocdl='chipset=gfx1030' -split-input-file | FileCheck %s
2+
3+
gpu.module @test_module {
4+
// CHECK-LABEL: func @gpu_subgroup_id()
5+
func.func @gpu_subgroup_id() -> (index) {
6+
// expected-error@+1 {{failed to legalize operation 'gpu.subgroup_id' that was explicitly marked illegal}}
7+
// CHECK: = rocdl.wave_id : i32
8+
// CHECK: = llvm.sext %{{.*}} : i32 to i64
9+
%waveId = gpu.subgroup_id : index
10+
func.return %waveId : index
11+
}
12+
}
13+

mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ gpu.module @test_module {
1111
func.func @gpu_index_ops()
1212
-> (index, index, index, index, index, index,
1313
index, index, index, index, index, index,
14-
index, index) {
14+
index) {
1515
// CHECK32-NOT: = llvm.sext %{{.*}} : i32 to i64
1616

1717
// CHECK: rocdl.workitem.id.x : i32
@@ -59,16 +59,12 @@ gpu.module @test_module {
5959
// CHECK: = llvm.sext %{{.*}} : i32 to i64
6060
%laneId = gpu.lane_id
6161

62-
// CHECK: = rocdl.wave_id : i32
63-
// CHECK: = llvm.sext %{{.*}} : i32 to i64
64-
%waveId = gpu.subgroup_id : index
65-
6662
func.return %tIdX, %tIdY, %tIdZ, %bDimX, %bDimY, %bDimZ,
6763
%bIdX, %bIdY, %bIdZ, %gDimX, %gDimY, %gDimZ,
68-
%laneId, %waveId
64+
%laneId
6965
: index, index, index, index, index, index,
7066
index, index, index, index, index, index,
71-
index, index
67+
index
7268
}
7369
}
7470

0 commit comments

Comments
 (0)