[Mlir-commits] [mlir] [ROCDL] Added BallotOp and lit test (PR #84856)
Zahi Moudallal
llvmlistbot at llvm.org
Mon Mar 11 17:49:14 PDT 2024
https://github.com/zahimoud updated https://github.com/llvm/llvm-project/pull/84856
>From dbc76932171cc85af7c4584a3fd1569864c44bb7 Mon Sep 17 00:00:00 2001
From: Zahi Moudallal <zahi at openai.com>
Date: Mon, 11 Mar 2024 17:06:23 -0700
Subject: [PATCH] [ROCDL] Added BallotOp and lit test
---
mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td | 12 ++++++++++++
mlir/test/Target/LLVMIR/rocdl.mlir | 7 +++++++
2 files changed, 19 insertions(+)
diff --git a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
index 32b5a1c016b6f8..bf6b85e8da916d 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
@@ -158,6 +158,18 @@ Arguments<(ins I32:$index,
}];
}
+def ROCDL_BallotOp :
+ ROCDL_Op<"ballot">,
+ Results<(outs LLVM_Type:$res)>,
+ Arguments<(ins I1:$pred)> {
+ string llvmBuilder = [{
+ $res = createIntrinsicCall(builder,
+ llvm::Intrinsic::amdgcn_ballot, {$pred});
+ }];
+ let assemblyFormat = [{
+ $pred attr-dict `:` type($res)
+ }];
+}
//===----------------------------------------------------------------------===//
// Thread index and Block index
diff --git a/mlir/test/Target/LLVMIR/rocdl.mlir b/mlir/test/Target/LLVMIR/rocdl.mlir
index d35acb0475e6f8..af16a6d325080a 100644
--- a/mlir/test/Target/LLVMIR/rocdl.mlir
+++ b/mlir/test/Target/LLVMIR/rocdl.mlir
@@ -88,6 +88,13 @@ llvm.func @rocdl.bpermute(%src : i32) -> i32 {
llvm.return %0 : i32
}
+llvm.func @rocdl.ballot(%pred : i1) -> i32 {
+ // CHECK-LABEL: rocdl.ballot
+ // CHECK: call i32 @llvm.amdgcn.ballot
+ %0 = rocdl.ballot %pred : (i1) -> i32
+ llvm.return %0 : i32
+}
+
llvm.func @rocdl.waitcnt() {
// CHECK-LABEL: rocdl.waitcnt
// CHECK-NEXT: call void @llvm.amdgcn.s.waitcnt(i32 0)
More information about the Mlir-commits
mailing list