[Mlir-commits] [mlir] [MLIR][ROCDL] Added summary and description to BallotOp (PR #85116)

Zahi Moudallal llvmlistbot at llvm.org
Wed Mar 13 11:50:11 PDT 2024


https://github.com/zahimoud updated https://github.com/llvm/llvm-project/pull/85116

>From 34130f377ebf243f9976517fc8c40d47059f6d31 Mon Sep 17 00:00:00 2001
From: Zahi Moudallal <zahi at openai.com>
Date: Wed, 13 Mar 2024 11:37:02 -0700
Subject: [PATCH 1/2] [MLIR][ROCDL] Added summary and description to BallotOp

---
 mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
index abb38a3df8068c..8c641b931de18e 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
@@ -162,10 +162,20 @@ def ROCDL_BallotOp :
   ROCDL_Op<"ballot">,
   Results<(outs LLVM_Type:$res)>,
   Arguments<(ins I1:$pred)> {
+  let summary = "Vote across thread group";
+
+  let description = [{
+      This operation applies a reduction to the source predicate across all the active threads within a warp, 
+      resulting in a destination predicate value that is uniform for every thread in the warp.
+
+      i1 -> i32
+  }];
+
   string llvmBuilder = [{
       $res = createIntrinsicCall(builder,
             llvm::Intrinsic::amdgcn_ballot, {$pred}, {llvm::Type::getInt32Ty(moduleTranslation.getLLVMContext())});
   }];
+
   let assemblyFormat = "$pred attr-dict `:` type($res)";
 }
 

>From 31632cc460715377642f519512ddb05298d4bf8f Mon Sep 17 00:00:00 2001
From: Zahi Moudallal <zahi at openai.com>
Date: Wed, 13 Mar 2024 11:49:53 -0700
Subject: [PATCH 2/2] [MLIR][ROCDL] Fixed documentation and return type.

---
 mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
index 8c641b931de18e..cfa366c3146518 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
@@ -165,15 +165,15 @@ def ROCDL_BallotOp :
   let summary = "Vote across thread group";
 
   let description = [{
-      This operation applies a reduction to the source predicate across all the active threads within a warp, 
-      resulting in a destination predicate value that is uniform for every thread in the warp.
+      Ballot provides a bit mask containing the 1-bit predicate value from each lane. 
+      The nth bit of the result contains the 1 bit contributed by the nth warp lane
 
-      i1 -> i32
+      i1 -> anyint
   }];
 
   string llvmBuilder = [{
       $res = createIntrinsicCall(builder,
-            llvm::Intrinsic::amdgcn_ballot, {$pred}, {llvm::Type::getInt32Ty(moduleTranslation.getLLVMContext())});
+            llvm::Intrinsic::amdgcn_ballot, {$pred}, {$res.getType()});
   }];
 
   let assemblyFormat = "$pred attr-dict `:` type($res)";



More information about the Mlir-commits mailing list