[Mlir-commits] [mlir] d741435 - [MLIR][ROCDL] Added `SchedGroupBarrier` and `IglpOpt` ops (#112237)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Oct 15 14:54:42 PDT 2024
Author: ravil-mobile
Date: 2024-10-15T22:54:39+01:00
New Revision: d741435d776a1381bfb0d588f912c7ee7819d921
URL: https://github.com/llvm/llvm-project/commit/d741435d776a1381bfb0d588f912c7ee7819d921
DIFF: https://github.com/llvm/llvm-project/commit/d741435d776a1381bfb0d588f912c7ee7819d921.diff
LOG: [MLIR][ROCDL] Added `SchedGroupBarrier` and `IglpOpt` ops (#112237)
This PR adds missing `sched.group.barrier` and `rocdl.iglp.opt` ops to
the ROCDL dialect (see
[here](https://github.com/llvm/llvm-project/blob/ec78f0da0e9b1b8e2b2323e434ea742e272dd913/clang/include/clang/Basic/BuiltinsAMDGPU.def#L66-L68)).
The ops are converted to the corresponding intrinsic calls during the
translation from MLIR to LLVM IRs. This intrinsics are hints to the
instruction scheduler of the AMDGPU backend.
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 b80d9ae88910c4..c40ae4b1016b49 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
@@ -297,6 +297,24 @@ def ROCDL_SchedBarrier : ROCDL_IntrOp<"sched.barrier", [], [], [], 0>,
"createIntrinsicCall(builder, llvm::Intrinsic::amdgcn_sched_barrier,builder.getInt32(op.getMask()));";
}
+def ROCDL_SchedGroupBarrier : ROCDL_IntrOp<"sched.group.barrier", [], [], [], 0>,
+ Arguments<(ins I32Attr:$mask, I32Attr:$size, I32Attr:$groupId)> {
+ let results = (outs);
+ let assemblyFormat = "$mask `,` $size `,` $groupId attr-dict";
+ string llvmBuilder = [{
+ createIntrinsicCall(builder,
+ llvm::Intrinsic::amdgcn_sched_group_barrier,
+ {builder.getInt32(op.getMask()), builder.getInt32(op.getSize()), builder.getInt32(op.getGroupId())});
+ }];
+}
+
+def ROCDL_IglpOpt : ROCDL_IntrOp<"iglp.opt", [], [], [], 0>,
+ Arguments<(ins I32Attr:$variant)> {
+ let results = (outs);
+ let assemblyFormat = "$variant attr-dict";
+ string llvmBuilder =
+ "createIntrinsicCall(builder, llvm::Intrinsic::amdgcn_iglp_opt,builder.getInt32(op.getVariant()));";
+}
//===---------------------------------------------------------------------===//
// Xdlops intrinsics
diff --git a/mlir/test/Dialect/LLVMIR/rocdl.mlir b/mlir/test/Dialect/LLVMIR/rocdl.mlir
index 397d66d92bc5d5..4afa839aa3ea1b 100644
--- a/mlir/test/Dialect/LLVMIR/rocdl.mlir
+++ b/mlir/test/Dialect/LLVMIR/rocdl.mlir
@@ -41,6 +41,18 @@ func.func @rocdl.sched_barrier() {
llvm.return
}
+func.func @rocdl_sched_group_barrier() {
+ // CHECK: rocdl.sched.group.barrier
+ rocdl.sched.group.barrier 8, 1, 0
+ llvm.return
+}
+
+func.func @rocdl_iglp_opt() {
+ // CHECK: rocdl.iglp.opt
+ rocdl.iglp.opt 0
+ llvm.return
+}
+
func.func @rocdl.setprio() {
// CHECK: rocdl.s.setprio
rocdl.s.setprio 0
diff --git a/mlir/test/Target/LLVMIR/rocdl.mlir b/mlir/test/Target/LLVMIR/rocdl.mlir
index 97276b087b7e93..2f34070147be47 100644
--- a/mlir/test/Target/LLVMIR/rocdl.mlir
+++ b/mlir/test/Target/LLVMIR/rocdl.mlir
@@ -179,6 +179,22 @@ llvm.func @rocdl.schedbarrier() {
llvm.return
}
+llvm.func @rocdl.sched.group.barrier() {
+ // CHECK-LABEL: rocdl.sched.group.barrier
+ // CHECK-NEXT: call void @llvm.amdgcn.sched.group.barrier(i32 8, i32 1, i32 0)
+ rocdl.sched.group.barrier 8, 1, 0
+ llvm.return
+}
+
+llvm.func @rocdl.iglp.opt() {
+ // CHECK-LABEL: rocdl.iglp.opt
+ // CHECK-NEXT: call void @llvm.amdgcn.iglp.opt(i32 0)
+ rocdl.iglp.opt 0
+ // CHECK-NEXT: call void @llvm.amdgcn.iglp.opt(i32 1)
+ rocdl.iglp.opt 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