[Mlir-commits] [mlir] [mlir][nvvm] Introduce `cp.async.bulk.wait_group` (PR #77917)
Guray Ozen
llvmlistbot at llvm.org
Fri Jan 12 04:43:28 PST 2024
https://github.com/grypp created https://github.com/llvm/llvm-project/pull/77917
This PR introduces `cp.async.bulk.wait_group` Op to NVVM dialect. It wait for completion of bulk async-groups.
For more details:
https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-bulk-wait-group
>From 52cc5fef756013b9a264a159e8ab9247bc6d40cd Mon Sep 17 00:00:00 2001
From: Guray Ozen <guray.ozen at gmail.com>
Date: Fri, 12 Jan 2024 13:42:47 +0100
Subject: [PATCH] [mlir][nvvm] Introduce cp.async.bulk.wait_group
This PR introduces `cp.async.bulk.wait_group` Op to NVVM dialect. It wait for completion of bulk async-groups.
For more details:
https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-bulk-wait-group
---
mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td | 29 +++++++++++++++++++
.../Conversion/NVVMToLLVM/nvvm-to-llvm.mlir | 17 +++++++++++
2 files changed, 46 insertions(+)
diff --git a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
index 1941c4dece1b86..c5f68a2ebe3952 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
@@ -1547,6 +1547,35 @@ def NVVM_CpAsyncBulkCommitGroupOp : NVVM_PTXBuilder_Op<"cp.async.bulk.commit.gro
}];
}
+def NVVM_CpAsyncBulkWaitGroupOp : NVVM_PTXBuilder_Op<"cp.async.bulk.wait_group">,
+ Arguments<(ins
+ ConfinedAttr<I32Attr, [IntMinValue<0>]>:$group,
+ OptionalAttr<UnitAttr>:$read)>
+{
+ let assemblyFormat = "$group attr-dict";
+ let description = [{
+ Op waits for completion of the most recent bulk async-groups.
+
+ The `$group` operand tells waiting has to be done until for $group or fewer
+ of the most recent bulk async-groups. If `$group` is 0, the op wait until
+ all the most recent bulk async-groups have completed.
+
+ The `$read` indicates that the waiting has to be done until all the bulk
+ async operations in the specified bulk async-group have completed reading
+ from their source locations.
+
+ [For more information, see PTX ISA]
+ (https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-bulk-wait-group)
+ }];
+
+ let extraClassDefinition = [{
+ std::string $cppClass::getPtx() {
+ auto ptx = std::string("cp.async.bulk.wait_group");
+ if(getRead()) ptx += ".read";
+ ptx += " %0;"; return ptx; }
+ }];
+}
+
def NVVM_CpAsyncBulkTensorGlobalToSharedClusterOp :
NVVM_Op<"cp.async.bulk.tensor.shared.cluster.global",
diff --git a/mlir/test/Conversion/NVVMToLLVM/nvvm-to-llvm.mlir b/mlir/test/Conversion/NVVMToLLVM/nvvm-to-llvm.mlir
index 2ee92e3d9527a6..a9487bdf3bd218 100644
--- a/mlir/test/Conversion/NVVMToLLVM/nvvm-to-llvm.mlir
+++ b/mlir/test/Conversion/NVVMToLLVM/nvvm-to-llvm.mlir
@@ -644,6 +644,23 @@ func.func @cp_bulk_commit() {
func.return
}
+// -----
+
+func.func @cp_bulk_wait_group() {
+ // CHECK: %[[S0:.+]] = llvm.mlir.constant(1 : i32) : i32
+ // CHECK: llvm.inline_asm has_side_effects asm_dialect = att "cp.async.bulk.wait_group $0;", "n" %[[S0]] : (i32) -> ()
+ // CHECK: %[[S1:.+]] = llvm.mlir.constant(0 : i32) : i32
+ // CHECK: llvm.inline_asm has_side_effects asm_dialect = att "cp.async.bulk.wait_group $0;", "n" %[[S1]] : (i32) -> ()
+ // CHECK: %[[S2:.+]] = llvm.mlir.constant(5 : i32) : i32
+ // CHECK: llvm.inline_asm has_side_effects asm_dialect = att "cp.async.bulk.wait_group.read $0;", "n" %[[S2]] : (i32) -> ()
+ // CHECK: %[[S3:.+]] = llvm.mlir.constant(0 : i32) : i32
+ // CHECK: llvm.inline_asm has_side_effects asm_dialect = att "cp.async.bulk.wait_group.read $0;", "n" %[[S3]] : (i32) -> ()
+ nvvm.cp.async.bulk.wait_group 1
+ nvvm.cp.async.bulk.wait_group 0
+ nvvm.cp.async.bulk.wait_group 5 {read}
+ nvvm.cp.async.bulk.wait_group 0 {read}
+ func.return
+}
// -----
More information about the Mlir-commits
mailing list