Skip to content

Commit f5d541c

Browse files
authored
[Backend] Reorder return values in emitHardwareTuple (NFC) (#5390)
@lezcano pointed out in another PR that the order is confusing because typically we list the lane ID, warp ID, and blockID in this order.
1 parent 99506b7 commit f5d541c

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

include/triton/Conversion/TritonGPUToLLVM/Utility.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,8 +1123,8 @@ emitBaseIndexForLayout(Location loc, RewriterBase &rewriter,
11231123
return idx;
11241124
}
11251125

1126-
// Emit code to compute the (blockId, warpId, laneId) for the current thread.
1127-
std::tuple</*blockId=*/Value, /*warpId=*/Value, /*laneId=*/Value>
1126+
// Emit code to compute the (laneId, warpId, blockId) for the current thread.
1127+
std::tuple</*laneId=*/Value, /*warpId=*/Value, /*blockId=*/Value>
11281128
emitHardwareTuple(Location loc, RewriterBase &rewriter,
11291129
const TargetInfoBase &target, bool withCTAOffset,
11301130
unsigned threadsPerWarp);

lib/Conversion/TritonGPUToLLVM/GatherOpToLLVM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ void GatherOpConversion::emitWarpLocalGather(
258258
SmallVector<Value> idxValues =
259259
unpackLLElements(loc, adaptor.getIndices(), rewriter);
260260

261-
auto [blockId, warpId, laneId] =
261+
auto [laneId, warpId, blockId] =
262262
emitHardwareTuple(loc, rewriter, targetInfo, /*withCTAOffset=*/true,
263263
srcLayout.getInDimSize(kLane));
264264

lib/Conversion/TritonGPUToLLVM/Utility.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ std::tuple<Value, Value, Value> emitHardwareTuple(Location loc,
110110
Value warpId = udiv(threadId, threadsPerWarp);
111111
Value blockId =
112112
withCTAOffset ? target.getClusterCTAId(rewriter, loc) : i32_val(0);
113-
return {blockId, warpId, laneId};
113+
return {laneId, warpId, blockId};
114114
}
115115

116116
SmallVector<SmallVector<Value>>
@@ -130,7 +130,7 @@ emitIndices(Location loc, RewriterBase &rewriter, const TargetInfoBase &target,
130130
StringAttr kWarp = str_attr("warp");
131131
StringAttr kBlock = str_attr("block");
132132

133-
auto [blockId, warpId, laneId] = emitHardwareTuple(
133+
auto [laneId, warpId, blockId] = emitHardwareTuple(
134134
loc, rewriter, target, withCTAOffset, ll->getInDimSize(kLane));
135135
unsigned rank = shape.size();
136136
SmallVector<SmallVector<Value>> ret;
@@ -353,7 +353,7 @@ bool emitTransferBetweenRegistersAndShared(
353353
std::min(regToSharedLayout->getNumConsecutiveInOut(),
354354
maxVecElems.value_or(std::numeric_limits<int>::max()));
355355

356-
auto [blockId, warpId, laneId] =
356+
auto [laneId, warpId, blockId] =
357357
emitHardwareTuple(loc, rewriter, target, /*withCTAOffset=*/false,
358358
regToSharedLayout->getInDimSize(kLane));
359359

@@ -746,7 +746,7 @@ SmallVector<Value> getMultiDimOffset(Attribute layout, Location loc,
746746
auto instrShape = mmaLayout.getInstrShape();
747747
SmallVector<Value> mmaColIdx(2);
748748
SmallVector<Value> mmaRowIdx(2);
749-
auto [blockId, warpId, laneId] = emitHardwareTuple(
749+
auto [laneId, warpId, blockId] = emitHardwareTuple(
750750
loc, rewriter, targetInfo, /*withCTAOffset=*/false, 32);
751751
// TODO: fix the bug in MMAEncodingAttr document
752752
SmallVector<Value> multiDimWarpId(2);

0 commit comments

Comments
 (0)