[Mlir-commits] [mlir] 16140ff - [mlir][ROCDL] Add synchronization primitives (#80888)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Feb 13 10:29:52 PST 2024
Author: Giuseppe Rossini
Date: 2024-02-13T12:29:49-06:00
New Revision: 16140ff219b68f61fedf92df13019d89a4990a47
URL: https://github.com/llvm/llvm-project/commit/16140ff219b68f61fedf92df13019d89a4990a47
DIFF: https://github.com/llvm/llvm-project/commit/16140ff219b68f61fedf92df13019d89a4990a47.diff
LOG: [mlir][ROCDL] Add synchronization primitives (#80888)
This PR adds two LLVM intrinsics to MLIR:
- llvm.amdgcn.s.setprio which sets the priority of a wave for the GPU
scheduler
- llvm.amdgcn.sched.barrier which sets a software barrier so that the
scheduler cannot move instructions around
Added:
Modified:
mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
mlir/test/Dialect/LLVMIR/rocdl.mlir
mlir/test/Target/LLVMIR/rocdl.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
index 638e46a2f9c752..962c159e68a2ee 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
@@ -192,6 +192,22 @@ def ROCDL_BarrierOp : ROCDL_Op<"barrier"> {
let assemblyFormat = "attr-dict";
}
+def ROCDL_SetPrioOp : ROCDL_IntrOp<"s.setprio", [], [], [], 0>,
+ Arguments<(ins I16Attr:$priority)> {
+ let results = (outs);
+ let assemblyFormat = "$priority attr-dict";
+ string llvmBuilder =
+ "createIntrinsicCall(builder, llvm::Intrinsic::amdgcn_s_setprio,builder.getInt16(op.getPriority()));";
+}
+
+def ROCDL_SchedBarrier : ROCDL_IntrOp<"sched.barrier", [], [], [], 0>,
+ Arguments<(ins I32Attr:$mask)> {
+ let results = (outs);
+ let assemblyFormat = "$mask attr-dict";
+ string llvmBuilder =
+ "createIntrinsicCall(builder, llvm::Intrinsic::amdgcn_sched_barrier,builder.getInt32(op.getMask()));";
+}
+
//===---------------------------------------------------------------------===//
// Xdlops intrinsics
diff --git a/mlir/test/Dialect/LLVMIR/rocdl.mlir b/mlir/test/Dialect/LLVMIR/rocdl.mlir
index 5a14df9ef9f8dc..89e8e7836c3a0c 100644
--- a/mlir/test/Dialect/LLVMIR/rocdl.mlir
+++ b/mlir/test/Dialect/LLVMIR/rocdl.mlir
@@ -35,6 +35,18 @@ func.func @rocdl.barrier() {
llvm.return
}
+func.func @rocdl.sched_barrier() {
+ // CHECK: rocdl.sched.barrier
+ rocdl.sched.barrier 0
+ llvm.return
+}
+
+func.func @rocdl.setprio() {
+ // CHECK: rocdl.s.setprio
+ rocdl.s.setprio 0
+ llvm.return
+}
+
func.func @rocdl.xdlops(%arg0 : f32, %arg1 : f32,
%arg2 : vector<32xf32>, %arg3 : i32,
%arg4 : vector<16xf32>, %arg5 : vector<4xf32>,
diff --git a/mlir/test/Target/LLVMIR/rocdl.mlir b/mlir/test/Target/LLVMIR/rocdl.mlir
index 26123300d74888..06b78650c8d010 100644
--- a/mlir/test/Target/LLVMIR/rocdl.mlir
+++ b/mlir/test/Target/LLVMIR/rocdl.mlir
@@ -90,6 +90,22 @@ llvm.func @rocdl.barrier() {
llvm.return
}
+llvm.func @rocdl.setprio() {
+ // CHECK: call void @llvm.amdgcn.s.setprio(i16 0)
+ rocdl.s.setprio 0
+ // CHECK-NEXT: call void @llvm.amdgcn.s.setprio(i16 1)
+ rocdl.s.setprio 1
+ llvm.return
+}
+
+llvm.func @rocdl.schedbarrier() {
+ // CHECK: call void @llvm.amdgcn.sched.barrier(i32 0)
+ rocdl.sched.barrier 0
+ // CHECK-NEXT: call void @llvm.amdgcn.sched.barrier(i32 1)
+ rocdl.sched.barrier 1
+ llvm.return
+}
+
llvm.func @rocdl.xdlops(%arg0 : f32, %arg1 : f32,
%arg2 : vector<32 x f32>, %arg3: i32,
%arg4 : vector<16 x f32>, %arg5 : vector<4xf32>,
More information about the Mlir-commits
mailing list