[Mlir-commits] [mlir] [MLIR][XeGPU] Add support for subgroup_id_range (PR #148661)
Nishant Patel
llvmlistbot at llvm.org
Wed Jul 16 18:03:27 PDT 2025
================
@@ -174,8 +174,42 @@ struct WgToSgCreateNdOp : public OpConversionPattern<xegpu::CreateNdDescOp> {
sgDataDim[i] = rewriter.create<arith::ConstantIndexOp>(loc, sgShape[i]);
}
+ // Check if there is warp specialization.
+ auto isWarpSpecialized = [](Operation *op, int64_t &startOfRange,
+ int64_t &endOfRange) -> bool {
+ Operation *parent = op->getParentOp();
+ // Find the outermost scf::IfOp with xegpu.sg_id_range.
+ while (parent) {
+ if (auto ifOp = dyn_cast<scf::IfOp>(parent)) {
+ if (auto attr = llvm::dyn_cast_or_null<xegpu::RangeAttr>(
+ ifOp->getAttr("sg_id_range"))) {
+ startOfRange = attr.getStart().getInt();
+ endOfRange = attr.getEnd().getInt();
+ break;
+ }
+ }
+ parent = parent->getParentOp();
+ }
+ // Return false if startOfRange is 0
+ return (startOfRange > 0 && endOfRange > startOfRange);
+ };
+
+ int64_t startOfRange = -1, endOfRange = -1;
+ bool warpSpecialized = isWarpSpecialized(op, startOfRange, endOfRange);
+
+ // If warp specialization is detected, adjust the subgroup id accordingly
+ Value adjustedSgId = linearSgId;
+ if (warpSpecialized) {
----------------
nbpatel wrote:
verify that the number of the subgroups in the sg_layout are less than the number of subgroups specified by the sg_id_range?
https://github.com/llvm/llvm-project/pull/148661
More information about the Mlir-commits
mailing list