Skip to content

Commit af92cab

Browse files
authored
[MLIR][NVVM] Combine griddepcontrol Ops (llvm#152525)
We've 2 ops: 1. nvvm.griddepcontrol.wait 2. nvvm.griddepcontrol.launch_dependents They are related to Grid Dependent Launch (or programmatic dependent launch in CUDA) and same concept. This PR unifies both ops into a single one.
1 parent 15d7a95 commit af92cab

File tree

3 files changed

+35
-19
lines changed

3 files changed

+35
-19
lines changed

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

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3036,30 +3036,46 @@ def NVVM_WgmmaMmaAsyncOp : NVVM_Op<"wgmma.mma_async",
30363036
// NVVM Griddepcontrol Ops
30373037
//===----------------------------------------------------------------------===//
30383038

3039-
def NVVM_GriddepcontrolWaitOp : NVVM_IntrOp<"griddepcontrol.wait", [], 0> {
3040-
let assemblyFormat = "attr-dict";
3039+
def GridDepActionWait : I32EnumCase<"wait", 0>;
3040+
def GridDepActionLaunchDependent : I32EnumCase<"launch_dependents", 1>;
3041+
3042+
def GridDepActionKind : I32Enum<"GridDepActionKind", "Action kind for grid dependency control",
3043+
[GridDepActionWait, GridDepActionLaunchDependent]> {
3044+
let cppNamespace = "::mlir::NVVM";
3045+
}
30413046

3047+
def GridDepActionAttr : EnumAttr<NVVM_Dialect, GridDepActionKind, "grid_dep_action">;
3048+
3049+
def NVVM_GriddepcontrolOp : NVVM_Op<"griddepcontrol", []> {
30423050
let description = [{
3043-
Causes the executing thread to wait until all prerequisite grids in flight
3051+
If the $kind attribute is set to `wait`, it causes the
3052+
executing thread to wait until all prerequisite grids in flight
30443053
have completed and all the memory operations from the prerequisite grids
30453054
are performed and made visible to the current grid.
30463055

3056+
When the $kind is launch_dependents, it signals that specific dependents
3057+
the runtime system designated to react to this instruction can be scheduled
3058+
as soon as all other CTAs in the grid issue the same instruction or have
3059+
completed.
30473060

30483061
[For more information, see PTX ISA](https://docs.nvidia.com/cuda/parallel-thread-execution/#parallel-synchronization-and-communication-instructions-griddepcontrol)
30493062
}];
3050-
}
30513063

3052-
def NVVM_GriddepcontrolLaunchDependentsOp
3053-
: NVVM_IntrOp<"griddepcontrol.launch.dependents", [], 0> {
3054-
let assemblyFormat = "attr-dict";
3055-
3056-
let description = [{
3057-
Signals that specific dependents the runtime system designated to react to
3058-
this instruction can be scheduled as soon as all other CTAs in the grid
3059-
issue the same instruction or have completed.
3064+
let arguments = (ins GridDepActionAttr:$kind);
30603065

3066+
let assemblyFormat = "$kind attr-dict";
30613067

3062-
[For more information, see PTX ISA](https://docs.nvidia.com/cuda/parallel-thread-execution/#parallel-synchronization-and-communication-instructions-griddepcontrol)
3068+
string llvmBuilder = [{
3069+
llvm::Intrinsic::ID id;
3070+
switch ($kind) {
3071+
case NVVM::GridDepActionKind::wait:
3072+
id = llvm::Intrinsic::nvvm_griddepcontrol_wait;
3073+
break;
3074+
case NVVM::GridDepActionKind::launch_dependents:
3075+
id = llvm::Intrinsic::nvvm_griddepcontrol_launch_dependents;
3076+
break;
3077+
}
3078+
createIntrinsicCall(builder, id);
30633079
}];
30643080
}
30653081

mlir/test/Dialect/LLVMIR/nvvm.mlir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,15 +524,15 @@ func.func @wgmma_wait_group_sync_aligned() {
524524
}
525525

526526
func.func @griddepcontrol_wait() {
527-
// CHECK: nvvm.griddepcontrol.wait
528-
nvvm.griddepcontrol.wait
527+
// CHECK: nvvm.griddepcontrol wait
528+
nvvm.griddepcontrol wait
529529
return
530530
}
531531

532532
func.func @griddepcontrol_launch_dependents()
533533
{
534-
// CHECK: nvvm.griddepcontrol.launch.dependents
535-
nvvm.griddepcontrol.launch.dependents
534+
// CHECK: nvvm.griddepcontrol launch_dependents
535+
nvvm.griddepcontrol launch_dependents
536536
return
537537
}
538538

mlir/test/Target/LLVMIR/nvvmir.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,15 +796,15 @@ llvm.func @nvvm_wgmma_wait_group_aligned() {
796796
// CHECK-LABEL: @nvvm_griddepcontrol_wait
797797
llvm.func @nvvm_griddepcontrol_wait() {
798798
// CHECK: call void @llvm.nvvm.griddepcontrol.wait()
799-
nvvm.griddepcontrol.wait
799+
nvvm.griddepcontrol wait
800800
llvm.return
801801
}
802802

803803
// -----
804804
// CHECK-LABEL: @nvvm_griddepcontrol_launch_dependents
805805
llvm.func @nvvm_griddepcontrol_launch_dependents() {
806806
// CHECK: call void @llvm.nvvm.griddepcontrol.launch.dependents()
807-
nvvm.griddepcontrol.launch.dependents
807+
nvvm.griddepcontrol launch_dependents
808808
llvm.return
809809
}
810810

0 commit comments

Comments
 (0)