Skip to content

Commit 11141bc

Browse files
authored
Fix what seems to be a silly bug in gpu.set_default_device rewriting. Smoke test included. (#75756)
1 parent 300adbe commit 11141bc

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,8 +1334,9 @@ LogicalResult ConvertSetDefaultDeviceOpToGpuRuntimeCallPattern::matchAndRewrite(
13341334
gpu::SetDefaultDeviceOp op, OpAdaptor adaptor,
13351335
ConversionPatternRewriter &rewriter) const {
13361336
Location loc = op.getLoc();
1337-
setDefaultDeviceCallBuilder.create(loc, rewriter, {adaptor.getDevIndex()});
1338-
rewriter.replaceOp(op, {});
1337+
auto call = setDefaultDeviceCallBuilder.create(loc, rewriter,
1338+
{adaptor.getDevIndex()});
1339+
rewriter.replaceOp(op, call);
13391340
return success();
13401341
}
13411342

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: mlir-opt %s --gpu-to-llvm | FileCheck %s
2+
3+
module attributes {gpu.container_module} {
4+
// CHECK-LABEL: func @set_default_device
5+
func.func @set_default_device(%arg0: i32) {
6+
// CHECK: mgpuSetDefaultDevice
7+
gpu.set_default_device %arg0
8+
return
9+
}
10+
}

0 commit comments

Comments
 (0)