Skip to content

Commit 6db9b0d

Browse files
authored
[mlir][rocdl] Add more gfx12 wait intrinsics (#149984)
1 parent 20c52e4 commit 6db9b0d

File tree

3 files changed

+91
-3
lines changed

3 files changed

+91
-3
lines changed

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

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,56 @@ def ROCDL_BarrierWaitOp : ROCDL_ConcreteNonMemIntrOp<"s.barrier.wait", [], 0, [0
284284
let assemblyFormat = "$id attr-dict";
285285
}
286286

287-
def ROCDL_WaitDscntOp: ROCDL_ConcreteNonMemIntrOp<"s.wait.dscnt", [], 0, [0], ["id"]>,
288-
Arguments<(ins I16Attr:$id)> {
287+
def ROCDL_WaitDscntOp: ROCDL_ConcreteNonMemIntrOp<"s.wait.dscnt", [], 0, [0], ["count"]>,
288+
Arguments<(ins I16Attr:$count)> {
289+
let summary = "Wait until DSCNT is less than or equal to `count`";
290+
let description = [{
291+
Wait for the counter specified to be less-than or equal-to the `count`
292+
before continuing.
293+
294+
Available on gfx12+.
295+
}];
289296
let results = (outs);
290-
let assemblyFormat = "$id attr-dict";
297+
let assemblyFormat = "$count attr-dict";
298+
}
299+
300+
def ROCDL_WaitLoadcntOp: ROCDL_ConcreteNonMemIntrOp<"s.wait.loadcnt", [], 0, [0], ["count"]>,
301+
Arguments<(ins I16Attr:$count)> {
302+
let summary = "Wait until LOADCNT is less than or equal to `count`";
303+
let description = [{
304+
Wait for the counter specified to be less-than or equal-to the `count`
305+
before continuing.
306+
307+
Available on gfx12+.
308+
}];
309+
let results = (outs);
310+
let assemblyFormat = "$count attr-dict";
311+
}
312+
313+
def ROCDL_WaitStorecntOp: ROCDL_ConcreteNonMemIntrOp<"s.wait.storecnt", [], 0, [0], ["count"]>,
314+
Arguments<(ins I16Attr:$count)> {
315+
let summary = "Wait until STORECNT is less than or equal to `count`";
316+
let description = [{
317+
Wait for the counter specified to be less-than or equal-to the `count`
318+
before continuing.
319+
320+
Available on gfx12+.
321+
}];
322+
let results = (outs);
323+
let assemblyFormat = "$count attr-dict";
324+
}
325+
326+
def ROCDL_WaitExpcntOp: ROCDL_ConcreteNonMemIntrOp<"s.wait.expcnt", [], 0, [0], ["count"]>,
327+
Arguments<(ins I16Attr:$count)> {
328+
let summary = "Wait until EXPCNT is less than or equal to `count`";
329+
let description = [{
330+
Wait for the counter specified to be less-than or equal-to the `count`
331+
before continuing.
332+
333+
Available on gfx12+.
334+
}];
335+
let results = (outs);
336+
let assemblyFormat = "$count attr-dict";
291337
}
292338

293339
def ROCDL_SetPrioOp : ROCDL_ConcreteNonMemIntrOp<"s.setprio", [], 0, [0], ["priority"]>,

mlir/test/Dialect/LLVMIR/rocdl.mlir

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,27 @@ llvm.func @rocdl.s.wait.dscnt() {
958958
llvm.return
959959
}
960960

961+
llvm.func @rocdl.s.wait.loadcnt() {
962+
// CHECK-LABEL: rocdl.s.wait.loadcnt
963+
// CHECK: rocdl.s.wait.loadcnt 0
964+
rocdl.s.wait.loadcnt 0
965+
llvm.return
966+
}
967+
968+
llvm.func @rocdl.s.wait.storecnt() {
969+
// CHECK-LABEL: rocdl.s.wait.storecnt
970+
// CHECK: rocdl.s.wait.storecnt 0
971+
rocdl.s.wait.storecnt 0
972+
llvm.return
973+
}
974+
975+
llvm.func @rocdl.s.wait.expcnt() {
976+
// CHECK-LABEL: rocdl.s.wait.expcnt
977+
// CHECK: rocdl.s.wait.expcnt 0
978+
rocdl.s.wait.expcnt 0
979+
llvm.return
980+
}
981+
961982
// -----
962983

963984
llvm.func @rocdl.readlane(%src : f32) -> f32 {

mlir/test/Target/LLVMIR/rocdl.mlir

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,27 @@ llvm.func @rocdl.s.wait.dscnt() {
196196
llvm.return
197197
}
198198

199+
llvm.func @rocdl.s.wait.loadcnt() {
200+
// CHECK-LABEL: rocdl.s.wait.loadcnt
201+
// CHECK-NEXT: call void @llvm.amdgcn.s.wait.loadcnt(i16 0)
202+
rocdl.s.wait.loadcnt 0
203+
llvm.return
204+
}
205+
206+
llvm.func @rocdl.s.wait.storecnt() {
207+
// CHECK-LABEL: rocdl.s.wait.storecnt
208+
// CHECK-NEXT: call void @llvm.amdgcn.s.wait.storecnt(i16 0)
209+
rocdl.s.wait.storecnt 0
210+
llvm.return
211+
}
212+
213+
llvm.func @rocdl.s.wait.expcnt() {
214+
// CHECK-LABEL: rocdl.s.wait.expcnt
215+
// CHECK-NEXT: call void @llvm.amdgcn.s.wait.expcnt(i16 0)
216+
rocdl.s.wait.expcnt 0
217+
llvm.return
218+
}
219+
199220
llvm.func @rocdl.setprio() {
200221
// CHECK: call void @llvm.amdgcn.s.setprio(i16 0)
201222
rocdl.s.setprio 0

0 commit comments

Comments
 (0)