Skip to content

Commit a6c9e49

Browse files
committed
Feedback part1
1 parent 62be14d commit a6c9e49

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

mlir/include/mlir/Dialect/XeGPU/uArch/IntelGpuXe2.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ inline const uArch *getUArch(llvm::StringRef archName) {
270270
return PVCuArch::getInstance();
271271
else if (archName.equals_insensitive("bmg"))
272272
return BMGuArch::getInstance();
273+
else
274+
llvm_unreachable("No matching uArch found");
273275

274276
return nullptr;
275277
}

mlir/lib/Dialect/XeGPU/Transforms/XeGPUSubgroupDistribute.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ struct MoveFuncBodyToWarpOp : public OpRewritePattern<gpu::GPUFuncOp> {
200200
using OpRewritePattern<gpu::GPUFuncOp>::OpRewritePattern;
201201
LogicalResult matchAndRewrite(gpu::GPUFuncOp gpuFuncOp,
202202
PatternRewriter &rewriter) const override {
203+
auto uArch = getUArch(xegpu::getChipStr(gpuFuncOp).value_or(""));
204+
if (!uArch)
205+
return rewriter.notifyMatchFailure(
206+
gpuFuncOp, "Subgroup distribution requires target attribute attached "
207+
"to set the warp size");
203208
// If the function only contains a single void return, skip.
204209
if (llvm::all_of(gpuFuncOp.getBody().getOps(), [](Operation &op) {
205210
return isa<gpu::ReturnOp>(op) && !op.getNumOperands();
@@ -229,11 +234,6 @@ struct MoveFuncBodyToWarpOp : public OpRewritePattern<gpu::GPUFuncOp> {
229234
rewriter, newGpuFunc.getLoc(), rewriter.getIndexType(),
230235
/** upperBound = **/ mlir::IntegerAttr());
231236
ArrayRef<Type> gpuFuncResultType = gpuFuncOp.getFunctionType().getResults();
232-
auto uArch = getUArch(xegpu::getChipStr(gpuFuncOp).value_or(""));
233-
if (!uArch)
234-
return rewriter.notifyMatchFailure(
235-
gpuFuncOp, "Subgroup distribution requires target attribute attached "
236-
"to set the warp size");
237237
auto warpOp = gpu::WarpExecuteOnLane0Op::create(
238238
rewriter, laneId.getLoc(), gpuFuncResultType, laneId,
239239
uArch->getSubgroupSize(), newGpuFunc.getArguments(),
@@ -501,15 +501,14 @@ struct LoadNdDistribution final : public gpu::WarpDistributionPattern {
501501
warpOp, "warp result is not a xegpu::LoadNd op");
502502

503503
auto loadOp = operand->get().getDefiningOp<xegpu::LoadNdOp>();
504-
// Chip information is required to decide if the layout requires transpose
505-
// effect.
506-
auto chipStr = xegpu::getChipStr(loadOp);
507-
auto uArch = getUArch(chipStr.value_or(""));
504+
auto uArch = getUArch(xegpu::getChipStr(loadOp).value_or(""));
508505
if (!uArch)
509506
return rewriter.notifyMatchFailure(
510507
loadOp, "xegpu::LoadNdOp require target attribute attached to "
511508
"determine transpose "
512509
"requirement");
510+
// Chip information is required to decide if the layout requires transpose
511+
// effect.
513512
// Expecting offsets to be present.
514513
SmallVector<OpFoldResult> offsets = loadOp.getMixedOffsets();
515514
if (offsets.empty())

0 commit comments

Comments
 (0)