Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use stride instead of order to determine block attr #2349

Merged
merged 5 commits into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,27 @@ struct TritonIntelGPUMaterializeBlockPointerPass
LDBG("Found make tensor ptr op: " << makeTensorPtrOp);
auto ptrType = cast<tt::PointerType>(makeTensorPtrOp.getType());
auto tensorType = cast<RankedTensorType>(ptrType.getPointeeType());
ArrayRef<int32_t> order = makeTensorPtrOp.getOrder();
unsigned rank = order.size();
Operation::operand_range shape = makeTensorPtrOp.getShape();
unsigned rank = shape.size();
LDBG("Rank: " << rank);
if (rank == 1)
return;

unsigned fastChangeDim = order[0];
Operation::operand_range strides = makeTensorPtrOp.getStrides();
int fastChangeDim = -1;
for (size_t i = 0; i < strides.size(); ++i) {
if (mlir::triton::gpu::intel::isConstant(strides[i], 1)) {
fastChangeDim = i;
break;
}
}

LDBG("Fast change dim: " << fastChangeDim);
if (fastChangeDim >= (rank - 2)) {
Operation::operand_range strides = makeTensorPtrOp.getStrides();
if (fastChangeDim < 0) {
return;
}

if (fastChangeDim >= (rank - 2)) {
// HW 2D block read instruction only supports contiguous access.
Value fastChangeStride = strides[fastChangeDim];
LLVM_DEBUG({
Expand All @@ -77,7 +87,8 @@ struct TritonIntelGPUMaterializeBlockPointerPass
Value pitch =
strides[(fastChangeDim == rank - 1) ? rank - 2 : rank - 1];
LDBG("Pitch: " << pitch);
if (!ttgi::isDivisible(pitch, 64 / tensorType.getElementTypeBitWidth()))
if (!ttgi::isDivisible(pitch,
128 / tensorType.getElementTypeBitWidth()))
return;

loadOp->setAttr(ttgi::TritonIntelGPUDialect::getBlockIOAttrName(),
Expand Down