Skip to content

Commit 693afaa

Browse files
committed
Add test for reading attached target
1 parent ba8efb5 commit 693afaa

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,12 @@ struct LowerGpuOpsToROCDLOpsPass
222222
ArrayAttr targets = m.getTargetsAttr();
223223
if (chipset == "infer") {
224224
if (!targets) {
225-
emitError(UnknownLoc::get(ctx),
226-
"ROCDLTargetAttr is empty on GPU module");
225+
m->emitError("ROCDLTargetAttr is empty on GPU module");
227226
return signalPassFailure();
228227
}
229228
if (targets.size() != 1) {
230-
emitError(UnknownLoc::get(ctx), "ROCDLTargetAttrs has more specified "
231-
"more than one gpu-arch on GPU module");
229+
m->emitError("ROCDLTargetAttrs has more specified more than one "
230+
"gpu-arch on GPU module");
232231
return signalPassFailure();
233232
}
234233
const ROCDL::ROCDLTargetAttr targetAttr =
@@ -238,7 +237,7 @@ struct LowerGpuOpsToROCDLOpsPass
238237

239238
FailureOr<amdgpu::Chipset> maybeChipset = amdgpu::Chipset::parse(chipset);
240239
if (failed(maybeChipset)) {
241-
emitError(UnknownLoc::get(ctx), "Invalid chipset name: " + chipset);
240+
m->emitError("Invalid chipset name: " + chipset);
242241
return signalPassFailure();
243242
}
244243

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: mlir-opt %s -convert-gpu-to-rocdl -split-input-file --verify-diagnostics | FileCheck --check-prefix=CHECK_TARGET %s
2+
3+
// CHECK_TARGET: @test_module [#rocdl.target<O = 3, chip = "gfx90a">] attributes {llvm.data_layout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"} {
4+
gpu.module @test_module [#rocdl.target<O = 3, chip = "gfx90a">] {
5+
// CHECK_TARGET-LABEL: @kernel_func
6+
// CHECK_TARGET: attributes
7+
// CHECK_TARGET: gpu.kernel
8+
// CHECK_TARGET: rocdl.kernel
9+
gpu.func @kernel_func() kernel {
10+
gpu.return
11+
}
12+
}
13+
14+
// -----
15+
16+
// expected-error@below {{ROCDLTargetAttr is empty on GPU module}}
17+
gpu.module @test_module {
18+
gpu.func @kernel_func() kernel {
19+
gpu.return
20+
}
21+
}
22+
23+
// -----
24+
25+
// expected-error@below {{Invalid chipset name: gfx90a,gfx900}}
26+
gpu.module @test_module [#rocdl.target<O = 3, chip = "gfx90a,gfx900">] {
27+
gpu.func @kernel_func() kernel {
28+
gpu.return
29+
}
30+
}

0 commit comments

Comments
 (0)