Skip to content

Commit d4159e2

Browse files
authored
[MLIR][NVVM] Add support for griddepcontrol Ops (#124603)
Adds `griddepcontrol.wait` and `griddepcontrol.launch.dependents` MLIR Ops to generate griddepcontrol instructions. `griddepcontrol` - Allows dependent and prerequisite grids as defined by the runtime to control execution in the following ways: - `griddepcontrol.wait` - causes the executing thread to wait until all prerequisite grids in flight have completed and all the memory operations from the prerequisite grids are performed and made visible to the current grid. - `griddepcontrol.launch.dependents` - signals that specific dependents the runtime system designated to react to this instruction can be scheduled as soon as all other CTAs in the grid issue the same instruction or have completed. PTX Spec Reference: https://docs.nvidia.com/cuda/parallel-thread-execution/#parallel-synchronization-and-communication-instructions-griddepcontrol
1 parent ab6d41e commit d4159e2

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,6 +2512,33 @@ def NVVM_WgmmaMmaAsyncOp : NVVM_Op<"wgmma.mma_async",
25122512
}];
25132513
}
25142514

2515+
//===----------------------------------------------------------------------===//
2516+
// NVVM Griddepcontrol Ops
2517+
//===----------------------------------------------------------------------===//
2518+
2519+
def NVVM_GriddepcontrolWaitOp : NVVM_IntrOp<"griddepcontrol.wait", [], 0> {
2520+
let assemblyFormat = "attr-dict";
2521+
2522+
let description = [{
2523+
Causes the executing thread to wait until all prerequisite grids in flight
2524+
have completed and all the memory operations from the prerequisite grids
2525+
are performed and made visible to the current grid.
2526+
[For more information, see PTX ISA](https://docs.nvidia.com/cuda/parallel-thread-execution/#parallel-synchronization-and-communication-instructions-griddepcontrol)
2527+
}];
2528+
}
2529+
2530+
def NVVM_GriddepcontrolLaunchDependentsOp
2531+
: NVVM_IntrOp<"griddepcontrol.launch.dependents", [], 0> {
2532+
let assemblyFormat = "attr-dict";
2533+
2534+
let description = [{
2535+
Signals that specific dependents the runtime system designated to react to
2536+
this instruction can be scheduled as soon as all other CTAs in the grid
2537+
issue the same instruction or have completed.
2538+
[For more information, see PTX ISA](https://docs.nvidia.com/cuda/parallel-thread-execution/#parallel-synchronization-and-communication-instructions-griddepcontrol)
2539+
}];
2540+
}
2541+
25152542
def NVVM_Exit : NVVM_Op<"exit"> {
25162543
let summary = "Exit Op";
25172544
let description = [{

mlir/test/Dialect/LLVMIR/nvvm.mlir

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,19 @@ func.func @wgmma_wait_group_sync_aligned() {
509509
return
510510
}
511511

512+
func.func @griddepcontrol_wait() {
513+
// CHECK: nvvm.griddepcontrol.wait
514+
nvvm.griddepcontrol.wait
515+
return
516+
}
517+
518+
func.func @griddepcontrol_launch_dependents()
519+
{
520+
// CHECK: nvvm.griddepcontrol.launch.dependents
521+
nvvm.griddepcontrol.launch.dependents
522+
return
523+
}
524+
512525
// -----
513526

514527
// Just check these don't emit errors.

mlir/test/Target/LLVMIR/nvvmir.mlir

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,3 +757,19 @@ llvm.func @nvvm_wgmma_wait_group_aligned() {
757757
nvvm.wgmma.wait.group.sync.aligned 20
758758
llvm.return
759759
}
760+
761+
// -----
762+
// CHECK-LABEL: @nvvm_griddepcontrol_wait
763+
llvm.func @nvvm_griddepcontrol_wait() {
764+
// CHECK: call void @llvm.nvvm.griddepcontrol.wait()
765+
nvvm.griddepcontrol.wait
766+
llvm.return
767+
}
768+
769+
// -----
770+
// CHECK-LABEL: @nvvm_griddepcontrol_launch_dependents
771+
llvm.func @nvvm_griddepcontrol_launch_dependents() {
772+
// CHECK: call void @llvm.nvvm.griddepcontrol.launch.dependents()
773+
nvvm.griddepcontrol.launch.dependents
774+
llvm.return
775+
}

0 commit comments

Comments
 (0)