Skip to content

Commit

Permalink
Fix what seems to be a silly bug in gpu.set_default_device rewriting.…
Browse files Browse the repository at this point in the history
… Smoke test included. (llvm#75756)
  • Loading branch information
pcf000 authored Dec 20, 2023
1 parent 300adbe commit 11141bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1334,8 +1334,9 @@ LogicalResult ConvertSetDefaultDeviceOpToGpuRuntimeCallPattern::matchAndRewrite(
gpu::SetDefaultDeviceOp op, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const {
Location loc = op.getLoc();
setDefaultDeviceCallBuilder.create(loc, rewriter, {adaptor.getDevIndex()});
rewriter.replaceOp(op, {});
auto call = setDefaultDeviceCallBuilder.create(loc, rewriter,
{adaptor.getDevIndex()});
rewriter.replaceOp(op, call);
return success();
}

Expand Down
10 changes: 10 additions & 0 deletions mlir/test/Conversion/GPUCommon/set-default-device.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// RUN: mlir-opt %s --gpu-to-llvm | FileCheck %s

module attributes {gpu.container_module} {
// CHECK-LABEL: func @set_default_device
func.func @set_default_device(%arg0: i32) {
// CHECK: mgpuSetDefaultDevice
gpu.set_default_device %arg0
return
}
}

0 comments on commit 11141bc

Please sign in to comment.