Skip to content
Draft
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
8 changes: 7 additions & 1 deletion mlir/lib/Dialect/Rock/utility/loweringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,13 @@ computeCopyPerThread(Type elementType, int64_t copyPerThread, int64_t kPerBlock,
copyKPerThread = copyPerThread / copyDPerThread;
dim = GemmDimension::MorN;
} else {
copyKPerThread = math_util::gcd(maxVlen, copyPerThread);
// Cap the K-vectorization at kPerBlock: with narrow types (e.g. int4,
// maxVlen=32) the greedy gcd(maxVlen, copyPerThread) can exceed kPerBlock
// (e.g. 16), which makes a thread copy more K elements than the block tile
// holds -> "incoherent tuning parameters". Capping keeps the copy coherent
// (still divides copyPerThread and maxVlen; thread tiling is unchanged since
// copyKPerThread*copyDPerThread == copyPerThread).
copyKPerThread = math_util::gcd(math_util::gcd(maxVlen, copyPerThread), kPerBlock);
copyDPerThread = copyPerThread / copyKPerThread;
dim = GemmDimension::K;
}
Expand Down
Loading