Skip to content

Commit

Permalink
[NFC]: Remove unused code in rewriteTensorPointerLoad (#1162)
Browse files Browse the repository at this point in the history
Signed-off-by: Tiotto, Ettore <ettore.tiotto@intel.com>
  • Loading branch information
etiotto authored May 21, 2024
1 parent 23a5617 commit 4604d7c
Showing 1 changed file with 35 additions and 44 deletions.
79 changes: 35 additions & 44 deletions third_party/intel/lib/TritonIntelGPUToLLVM/LoadStoreOpToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ using namespace mlir::triton::gpu;
using namespace mlir::triton::gpu::intel;

using ::mlir::LLVM::delinearize;
using ::mlir::LLVM::getSharedMemoryObjectFromStruct;
using ::mlir::LLVM::linearize;
using ::mlir::triton::gpu::getCTALayout;
using ::mlir::triton::gpu::getShapePerCTA;
using ::mlir::triton::gpu::getTotalElemsPerThread;
using ::mlir::triton::gpu::SharedEncodingAttr;

namespace {

Expand Down Expand Up @@ -102,6 +97,41 @@ Value redundantDataMask(Type valueTy, ConversionPatternRewriter &rewriter,
return mask;
}

/// Holds the values related to a block pointer.
/// It includes the base pointer, base width and height, row and column
/// stride, and offset base for X and Y.
struct BlockPointerValues {
Value base;
Value baseWidth;
Value baseHeight;
Value rowStride;
Value colStride;
Value offsetBaseX;
Value offsetBaseY;
};

// Unpack values as the params to 2DBlockLoad Payload: offsetBaseY,
// offsetBaseX, baseHeight, baseWidth, rowStride, colStride, base.
// FIXME: Only supports 2D matrices for now.
BlockPointerValues
getValuesFromBlockPointerStruct(Value blockPointerStruct,
ConversionPatternRewriter &rewriter) {
const SmallVector<Value> &elems = unpackLLElements(
blockPointerStruct.getLoc(), blockPointerStruct, rewriter);
assert(elems.size() == 7 &&
"unexpected number of values unpacked from a block pointer");
BlockPointerValues values{
.base = elems[6],
.baseWidth = elems[3],
.baseHeight = elems[2],
.rowStride = elems[4],
.colStride = elems[5],
.offsetBaseX = elems[1],
.offsetBaseY = elems[0],
};
return values;
}

// Contains some helper functions for both Load and Store conversions.
struct LoadStoreConversionBase {
explicit LoadStoreConversionBase(const triton::intel::TargetInfo &targetInfo,
Expand Down Expand Up @@ -147,41 +177,6 @@ struct LoadOpConversion
: ConvertTritonGPUOpToLLVMPattern<triton::LoadOp>(converter, benefit),
LoadStoreConversionBase(targetInfo, axisAnalysisPass) {}

/// Holds the values related to a block pointer.
/// It includes the base pointer, base width and height, row and column
/// stride, and offset base for X and Y.
struct BlockPointerValues {
Value base;
Value baseWidth;
Value baseHeight;
Value rowStride;
Value colStride;
Value offsetBaseX;
Value offsetBaseY;
};

// Unpack values as the params to 2DBlockLoad Payload: offsetBaseY,
// offsetBaseX, baseHeight, baseWidth, rowStride, colStride, base.
// FIXME: Only supports 2D matrices for now.
BlockPointerValues
getValuesFromBlockPointerStruct(Value blockPointerStruct,
ConversionPatternRewriter &rewriter) const {
const SmallVector<Value> &elems = unpackLLElements(
blockPointerStruct.getLoc(), blockPointerStruct, rewriter);
assert(elems.size() == 7 &&
"unexpected number of values unpacked from a block pointer");
BlockPointerValues values{
.base = elems[6],
.baseWidth = elems[3],
.baseHeight = elems[2],
.rowStride = elems[4],
.colStride = elems[5],
.offsetBaseX = elems[1],
.offsetBaseY = elems[0],
};
return values;
}

LogicalResult
rewriteTensorPointerLoad(triton::LoadOp op, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const {
Expand Down Expand Up @@ -266,10 +261,6 @@ struct LoadOpConversion
baseHeight = trunc(i32_ty, baseHeight);
rowStride = trunc(i32_ty, rowStride);

auto getIntAttr = [](IntegerType type, unsigned val) {
return mlir::IntegerAttr::get(type, val);
};

auto load2dOp = rewriter.create<TritonGEN::Matrix2DBlockLoadOp>(
loc, load2DGenXType, /*ptr*/ base, /*base_width*/
mul(baseWidth, i32_val(eltTy.getIntOrFloatBitWidth() / 8)),
Expand Down

0 comments on commit 4604d7c

Please sign in to comment.