Skip to content

[MLIR][NVVM] Combine griddepcontrol Ops #152525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 30 additions & 13 deletions mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -2995,30 +2995,47 @@ 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 : I32EnumAttrCase<"wait", 0>;
def GridDepActionLaunchDependent : I32EnumAttrCase<"launch_dependents", 1>;

def GridDepActionKind : I32EnumAttr<"GridDepKind", "Action kind for grid dependency control",
[GridDepActionWait, GridDepActionLaunchDependent]> {
let genSpecializedAttr = 0;
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);
}];
}

Expand Down
8 changes: 4 additions & 4 deletions mlir/test/Dialect/LLVMIR/nvvm.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -535,15 +535,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
}

Expand Down
15 changes: 13 additions & 2 deletions mlir/test/Target/LLVMIR/nvvmir.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -766,15 +766,15 @@ 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
}

// -----
// 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
}

Expand Down Expand Up @@ -918,3 +918,14 @@ llvm.func @nvvm_dot_accumulate_2way(%a: vector<2xi16>, %b: vector<4xi8>, %c: i32
%7 = nvvm.dot.accumulate.2way %a <signed>, %b <signed>, %c {b_hi = true}: vector<2xi16>, vector<4xi8>
llvm.return
}

// -----

// CHECK-LABEL: @nvvm_pmevent
llvm.func @nvvm_pmevent() {
// CHECK: call void @llvm.nvvm.pm.event.mask(i16 15000)
nvvm.pmevent mask = 15000
// CHECK: call void @llvm.nvvm.pm.event.mask(i16 4)
nvvm.pmevent mask = 4
llvm.return
}
Loading