Skip to content

Commit 1c75a81

Browse files
committed
updates
1 parent de4364f commit 1c75a81

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ def ROCDL_BlockIdXOp : ROCDL_SpecialIdRegisterOp<"workgroup.id.x">;
216216
def ROCDL_BlockIdYOp : ROCDL_SpecialIdRegisterOp<"workgroup.id.y">;
217217
def ROCDL_BlockIdZOp : ROCDL_SpecialIdRegisterOp<"workgroup.id.z">;
218218

219-
def ROCDL_WavefrontSizeOp : ROCDL_SpecialIdRegisterOp<"wavefrontsize">;
219+
def ROCDL_WavefrontSizeOp : ROCDL_IntrPure1Op<"wavefrontsize">,
220+
Arguments<(ins OptionalAttr<IndexAttr>:$upper_bound)> {
221+
let assemblyFormat = "(`upper_bound` $upper_bound^)? attr-dict `:` type($res)";
222+
}
220223

221224
//===----------------------------------------------------------------------===//
222225
// Thread range and Block range

mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ struct GPUSubgroupSizeOpToROCDL : ConvertOpToLLVMPattern<gpu::SubgroupSizeOp> {
138138
matchAndRewrite(gpu::SubgroupSizeOp op, gpu::SubgroupSizeOp::Adaptor adaptor,
139139
ConversionPatternRewriter &rewriter) const override {
140140
Value wavefrontOp = rewriter.create<ROCDL::WavefrontSizeOp>(
141-
op.getLoc(), IntegerType::get(rewriter.getContext(), 32));
141+
op.getLoc(), rewriter.getI32Type(), op.getUpperBoundAttr());
142142
wavefrontOp = truncOrExtToLLVMType(rewriter, op.getLoc(), wavefrontOp,
143143
*getTypeConverter());
144144
rewriter.replaceOp(op, {wavefrontOp});

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

Lines changed: 7 additions & 3 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, index, index) {
1515
// CHECK32-NOT: = llvm.sext %{{.*}} : i32 to i64
1616

1717
// CHECK: rocdl.workitem.id.x : i32
@@ -63,12 +63,16 @@ gpu.module @test_module {
6363
// CHECK: = llvm.sext %{{.*}} : i32 to i64
6464
%subgroupSize = gpu.subgroup_size : index
6565

66+
// CHECK: = rocdl.wavefrontsize upper_bound 64 : i32
67+
// CHECK: = llvm.sext %{{.*}} : i32 to i64
68+
%subgroupSize2 = gpu.subgroup_size upper_bound 64 : index
69+
6670
func.return %tIdX, %tIdY, %tIdZ, %bDimX, %bDimY, %bDimZ,
6771
%bIdX, %bIdY, %bIdZ, %gDimX, %gDimY, %gDimZ,
68-
%laneId, %subgroupSize
72+
%laneId, %subgroupSize, %subgroupSize2
6973
: index, index, index, index, index, index,
7074
index, index, index, index, index, index,
71-
index, index
75+
index, index, index
7276
}
7377
}
7478

mlir/test/Target/LLVMIR/rocdl.mlir

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ llvm.func @rocdl_special_regs() -> i32 {
3333
// CHECK: call range(i64 1, 65) i64 @__ockl_get_local_size(i32 0)
3434
%14 = rocdl.workgroup.dim.x range <i32, 1, 65> : i64
3535

36-
// CHECK: call i32 $llvm.amdgcn.wavefrontsize()
36+
// CHECK: call i32 @llvm.amdgcn.wavefrontsize()
3737
%15 = rocdl.wavefrontsize : i32
3838

39+
// CHECK: call i32 @llvm.amdgcn.wavefrontsize()
40+
%16 = rocdl.wavefrontsize upper_bound 32 : i32
41+
3942
llvm.return %1 : i32
4043
}
4144

0 commit comments

Comments
 (0)