Skip to content

Instantly share code, notes, and snippets.

@bjacob
Last active April 18, 2024 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjacob/ef3e2c3fa87301fbf1da3275f69e95ab to your computer and use it in GitHub Desktop.
Save bjacob/ef3e2c3fa87301fbf1da3275f69e95ab to your computer and use it in GitHub Desktop.
diff --git a/compiler/src/iree/compiler/Codegen/LLVMCPU/KernelDispatch.cpp b/compiler/src/iree/compiler/Codegen/LLVMCPU/KernelDispatch.cpp
index 002c34f425..e4dd03268f 100644
--- a/compiler/src/iree/compiler/Codegen/LLVMCPU/KernelDispatch.cpp
+++ b/compiler/src/iree/compiler/Codegen/LLVMCPU/KernelDispatch.cpp
@@ -1506,7 +1506,8 @@ static void setX86VectorTileSizes(linalg::GenericOp genericOp,
SmallVectorImpl<int64_t> &vecTileSizes) {
vecTileSizes.append(numLoops, 0);
SmallVector<int64_t> staticLoopRanges = genericOp.getStaticLoopRanges();
- for (auto loopNum : llvm::seq<unsigned>(0, numLoops)) {
+ int64_t maxRemainingVecTileSize = 1024;
+ for (auto loopNum : llvm::reverse(llvm::seq<unsigned>(0, numLoops))) {
if (distTileSizes[loopNum]) {
vecTileSizes[loopNum] = getMaxVectorTileSize(
distTileSizes[loopNum], minTileSizes[loopNum], minTileSizes[loopNum],
@@ -1518,7 +1519,15 @@ static void setX86VectorTileSizes(linalg::GenericOp genericOp,
vecTileSizes[loopNum] =
staticLoopRanges[loopNum] == 1 ? 0 : minTileSizes[loopNum];
}
+ if (vecTileSizes[loopNum] > maxRemainingVecTileSize) {
+ vecTileSizes[loopNum] = maxRemainingVecTileSize;
+ maxRemainingVecTileSize = 1;
+ } else {
+ maxRemainingVecTileSize = std::max<int64_t>(1, maxRemainingVecTileSize / vecTileSizes[loopNum]);
+ }
}
+ llvm::dbgs() << "setX86VectorTileSizes:\n";
+ for (auto x : vecTileSizes) llvm::dbgs() << " " << x << "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment