[Mlir-commits] [mlir] af92cab - [MLIR][NVVM] Combine griddepcontrol Ops (#152525)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Aug 15 06:47:14 PDT 2025
Author: Guray Ozen
Date: 2025-08-15T15:47:12+02:00
New Revision: af92cabdef72164341a7108a8c099d1c12cf283c
URL: https://github.com/llvm/llvm-project/commit/af92cabdef72164341a7108a8c099d1c12cf283c
DIFF: https://github.com/llvm/llvm-project/commit/af92cabdef72164341a7108a8c099d1c12cf283c.diff
LOG: [MLIR][NVVM] Combine griddepcontrol Ops (#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.
Added:
Modified:
mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
mlir/test/Dialect/LLVMIR/nvvm.mlir
mlir/test/Target/LLVMIR/nvvmir.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
index f5a77af028abd..f9cd58de8915f 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
@@ -3036,30 +3036,46 @@ def NVVM_WgmmaMmaAsyncOp : NVVM_Op<"wgmma.mma_async",
// NVVM Griddepcontrol Ops
//===----------------------------------------------------------------------===//
-def NVVM_GriddepcontrolWaitOp : NVVM_IntrOp<"griddepcontrol.wait", [], 0> {
- let assemblyFormat = "attr-dict";
+def GridDepActionWait : I32EnumCase<"wait", 0>;
+def GridDepActionLaunchDependent : I32EnumCase<"launch_dependents", 1>;
+
+def GridDepActionKind : I32Enum<"GridDepActionKind", "Action kind for grid dependency control",
+ [GridDepActionWait, GridDepActionLaunchDependent]> {
+ let cppNamespace = "::mlir::NVVM";
+}
+def GridDepActionAttr : EnumAttr<NVVM_Dialect, GridDepActionKind, "grid_dep_action">;
+
+def NVVM_GriddepcontrolOp : NVVM_Op<"griddepcontrol", []> {
let description = [{
- Causes the executing thread to wait until all prerequisite grids in flight
+ If the $kind attribute is set to `wait`, it 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.
+ When the $kind is launch_dependents, it 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.
[For more information, see PTX ISA](https://docs.nvidia.com/cuda/parallel-thread-execution/#parallel-synchronization-and-communication-instructions-griddepcontrol)
}];
-}
-def NVVM_GriddepcontrolLaunchDependentsOp
- : NVVM_IntrOp<"griddepcontrol.launch.dependents", [], 0> {
- let assemblyFormat = "attr-dict";
-
- let description = [{
- 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.
+ let arguments = (ins GridDepActionAttr:$kind);
+ let assemblyFormat = "$kind attr-dict";
- [For more information, see PTX ISA](https://docs.nvidia.com/cuda/parallel-thread-execution/#parallel-synchronization-and-communication-instructions-griddepcontrol)
+ string llvmBuilder = [{
+ llvm::Intrinsic::ID id;
+ switch ($kind) {
+ case NVVM::GridDepActionKind::wait:
+ id = llvm::Intrinsic::nvvm_griddepcontrol_wait;
+ break;
+ case NVVM::GridDepActionKind::launch_dependents:
+ id = llvm::Intrinsic::nvvm_griddepcontrol_launch_dependents;
+ break;
+ }
+ createIntrinsicCall(builder, id);
}];
}
diff --git a/mlir/test/Dialect/LLVMIR/nvvm.mlir b/mlir/test/Dialect/LLVMIR/nvvm.mlir
index e99f27c7f10a3..5821c2eac99dd 100644
--- a/mlir/test/Dialect/LLVMIR/nvvm.mlir
+++ b/mlir/test/Dialect/LLVMIR/nvvm.mlir
@@ -524,15 +524,15 @@ func.func @wgmma_wait_group_sync_aligned() {
}
func.func @griddepcontrol_wait() {
- // CHECK: nvvm.griddepcontrol.wait
- nvvm.griddepcontrol.wait
+ // CHECK: nvvm.griddepcontrol wait
+ nvvm.griddepcontrol wait
return
}
func.func @griddepcontrol_launch_dependents()
{
- // CHECK: nvvm.griddepcontrol.launch.dependents
- nvvm.griddepcontrol.launch.dependents
+ // CHECK: nvvm.griddepcontrol launch_dependents
+ nvvm.griddepcontrol launch_dependents
return
}
diff --git a/mlir/test/Target/LLVMIR/nvvmir.mlir b/mlir/test/Target/LLVMIR/nvvmir.mlir
index 0996a8c7eb361..c8ba91efbff4d 100644
--- a/mlir/test/Target/LLVMIR/nvvmir.mlir
+++ b/mlir/test/Target/LLVMIR/nvvmir.mlir
@@ -796,7 +796,7 @@ llvm.func @nvvm_wgmma_wait_group_aligned() {
// CHECK-LABEL: @nvvm_griddepcontrol_wait
llvm.func @nvvm_griddepcontrol_wait() {
// CHECK: call void @llvm.nvvm.griddepcontrol.wait()
- nvvm.griddepcontrol.wait
+ nvvm.griddepcontrol wait
llvm.return
}
@@ -804,7 +804,7 @@ llvm.func @nvvm_griddepcontrol_wait() {
// CHECK-LABEL: @nvvm_griddepcontrol_launch_dependents
llvm.func @nvvm_griddepcontrol_launch_dependents() {
// CHECK: call void @llvm.nvvm.griddepcontrol.launch.dependents()
- nvvm.griddepcontrol.launch.dependents
+ nvvm.griddepcontrol launch_dependents
llvm.return
}
More information about the Mlir-commits
mailing list