[Mlir-commits] [mlir] 0e3d1ca - [MLIR][GPU] NFC: simplify kernel operand accessor implementations.

Christian Sigg llvmlistbot at llvm.org
Sat May 14 05:14:53 PDT 2022


Author: Christian Sigg
Date: 2022-05-14T14:14:42+02:00
New Revision: 0e3d1ca54a61c8f4556d099a3ea23585817aeffc

URL: https://github.com/llvm/llvm-project/commit/0e3d1ca54a61c8f4556d099a3ea23585817aeffc
DIFF: https://github.com/llvm/llvm-project/commit/0e3d1ca54a61c8f4556d099a3ea23585817aeffc.diff

LOG: [MLIR][GPU] NFC: simplify kernel operand accessor implementations.

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D125112

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/GPU/GPUOps.td
    mlir/lib/Dialect/GPU/IR/GPUDialect.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/GPU/GPUOps.td b/mlir/include/mlir/Dialect/GPU/GPUOps.td
index 7ff75b19f72a0..5a66c9d0ded06 100644
--- a/mlir/include/mlir/Dialect/GPU/GPUOps.td
+++ b/mlir/include/mlir/Dialect/GPU/GPUOps.td
@@ -426,15 +426,15 @@ def GPU_LaunchFuncOp : GPU_Op<"launch_func",
   ];
 
   let extraClassDeclaration = [{
-    /// The number of operands passed to the kernel function.
-    unsigned getNumKernelOperands();
-
     /// The name of the kernel's containing module.
     StringAttr getKernelModuleName();
 
     /// The name of the kernel.
     StringAttr getKernelName();
 
+    /// The number of operands passed to the kernel function.
+    unsigned getNumKernelOperands();
+
     /// The i-th operand passed to the kernel function.
     Value getKernelOperand(unsigned i);
 
@@ -444,10 +444,6 @@ def GPU_LaunchFuncOp : GPU_Op<"launch_func",
     /// Get the SSA values passed as operands to specify the block size.
     KernelDim3 getBlockSizeOperandValues();
 
-    /// The number of launch configuration operands, placed at the leading
-    /// positions of the operand list.
-    static constexpr unsigned kNumConfigOperands = 6;
-
     // This needs to quietly verify if attributes with names defined below are
     // present since it is run before the verifier of this op.
     friend LogicalResult GPUDialect::verifyOperationAttribute(Operation *,

diff  --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index efcb1300178b7..8d0e6da9a7b52 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -711,21 +711,15 @@ void LaunchFuncOp::build(OpBuilder &builder, OperationState &result,
                       builder.getI32VectorAttr(segmentSizes));
 }
 
-unsigned LaunchFuncOp::getNumKernelOperands() {
-  return getNumOperands() - asyncDependencies().size() - kNumConfigOperands -
-         (dynamicSharedMemorySize() ? 1 : 0);
-}
-
 StringAttr LaunchFuncOp::getKernelModuleName() {
   return kernel().getRootReference();
 }
 
 StringAttr LaunchFuncOp::getKernelName() { return kernel().getLeafReference(); }
 
-Value LaunchFuncOp::getKernelOperand(unsigned i) {
-  return getOperand(asyncDependencies().size() + kNumConfigOperands +
-                    (dynamicSharedMemorySize() ? 1 : 0) + i);
-}
+unsigned LaunchFuncOp::getNumKernelOperands() { return operands().size(); }
+
+Value LaunchFuncOp::getKernelOperand(unsigned i) { return operands()[i]; }
 
 KernelDim3 LaunchFuncOp::getGridSizeOperandValues() {
   auto operands = getOperands().drop_front(asyncDependencies().size());


        


More information about the Mlir-commits mailing list