[Mlir-commits] [mlir] [MLIR][XeGPU] Extend Wg-to-Sg Distribution of Multi-Reduction Op for round-robin layout (PR #189988)
Nishant Patel
llvmlistbot at llvm.org
Mon Apr 6 09:19:50 PDT 2026
================
@@ -1330,26 +1331,33 @@ struct WgToSgMultiDimReductionOp
return success();
}
- // Step 2: cross-subgroup reduction using SLM
+ // Step 2: cross-subgroup reduction using SLM - allocating slm memory
auto slmStoreDataShape = sgSrcShape;
for (int64_t dim : reductionDims)
slmStoreDataShape[dim] = 1;
VectorType slmStoreDataType = VectorType::get(slmStoreDataShape, elemTy);
- Value slmStoreData;
- if (isScalarResult) {
- // Scalar result: broadcast scalar to vector<1x...x1> for SLM store
- slmStoreData = vector::BroadcastOp::create(
- rewriter, loc, slmStoreDataType, localReductions[0]);
- } else {
- slmStoreData = vector::ShapeCastOp::create(
- rewriter, loc, slmStoreDataType, localReductions[0]);
+ SmallVector<Value> slmStoreData;
+ for (auto localResult : localReductions) {
+ if (isScalarResult) {
+ // Scalar result: broadcast scalar to vector<1x...x1> for SLM store
+ slmStoreData.push_back(vector::BroadcastOp::create(
+ rewriter, loc, slmStoreDataType, localResult));
+ } else {
+ slmStoreData.push_back(vector::ShapeCastOp::create(
+ rewriter, loc, slmStoreDataType, localResult));
+ }
}
-
+ // for reduction dimension, SLM stores partial results from each subgroup
SmallVector<int64_t> slmShape(originalSrcShape.begin(),
originalSrcShape.end());
- // for reduction dimension, SLM stores partial results from each subgroup
- for (int64_t dim : reductionDims)
+ SmallVector<int> slmSgData(sgData.begin(), sgData.end());
+ SmallVector<int> slmSgLayout(sgLayout.begin(), sgLayout.end());
+ for (int dim : reductionDims) {
slmShape[dim] = sgLayout[dim];
+ slmSgData[dim] = sgLayout[dim];
+ }
+ xegpu::LayoutAttr slmStoreLayout =
----------------
nbpatel wrote:
what is the reason for this? why not just use sgLayout
https://github.com/llvm/llvm-project/pull/189988
More information about the Mlir-commits
mailing list