Skip to content

Commit 1649c52

Browse files
committed
remove index ops
1 parent 6aa4aef commit 1649c52

File tree

1 file changed

+0
-71
lines changed

1 file changed

+0
-71
lines changed

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

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,63 +1544,6 @@ struct PrefetchNdDistribution final : public gpu::WarpDistributionPattern {
15441544
}
15451545
};
15461546

1547-
/// Generic pattern for sinking a GPU index operations feeding into yield op
1548-
/// of an enclosing `gpu.warp_execute_on_lane_0` region. The original index op
1549-
/// becomes dead and an equivalent copy of the index op is created outside the
1550-
/// warp op.
1551-
/// Example:
1552-
/// ```
1553-
/// %r = gpu.warp_execute_on_lane_0(%laneid) -> (index) {
1554-
/// ...
1555-
/// %index = gpu.block_id x : index
1556-
/// gpu.yield %index
1557-
/// }
1558-
/// ...
1559-
/// ```
1560-
/// To
1561-
/// ```
1562-
/// %r:2 = gpu.warp_execute_on_lane_0(%laneid) -> (index) {
1563-
/// ...
1564-
/// %dead = gpu.block_id x : index
1565-
/// gpu.yield %dead
1566-
/// }
1567-
/// %0 = gpu.block_id x : index
1568-
/// ...
1569-
/// ```
1570-
template <typename IndexOp>
1571-
struct GpuIndexOpDistribution final : public gpu::WarpDistributionPattern {
1572-
using gpu::WarpDistributionPattern::WarpDistributionPattern;
1573-
LogicalResult matchAndRewrite(gpu::WarpExecuteOnLane0Op subgroupOp,
1574-
PatternRewriter &rewriter) const override {
1575-
OpOperand *operand = getWarpResult(subgroupOp, llvm::IsaPred<IndexOp>);
1576-
if (!operand)
1577-
return rewriter.notifyMatchFailure(subgroupOp,
1578-
"warp result is not a gpu index op");
1579-
Operation *indexOp = operand->get().getDefiningOp<IndexOp>();
1580-
unsigned operandIdx = operand->getOperandNumber();
1581-
SmallVector<Value, 3> newYieldValues;
1582-
SmallVector<Type, 3> newYieldTypes;
1583-
for (Value operand : indexOp->getOperands()) {
1584-
newYieldValues.push_back(operand);
1585-
newYieldTypes.push_back(operand.getType());
1586-
}
1587-
SmallVector<size_t> newRetIndices;
1588-
gpu::WarpExecuteOnLane0Op newWarpOp = moveRegionToNewWarpOpAndAppendReturns(
1589-
rewriter, subgroupOp, newYieldValues, newYieldTypes, newRetIndices);
1590-
rewriter.setInsertionPointAfter(newWarpOp);
1591-
SmallVector<Value> newIndexOperands;
1592-
for (size_t i : newRetIndices) {
1593-
newIndexOperands.push_back(newWarpOp.getResult(i));
1594-
}
1595-
auto newIndexOp = rewriter.create<IndexOp>(
1596-
newWarpOp.getLoc(), newIndexOperands,
1597-
removeTemporaryLayoutAttributes(indexOp->getAttrs()));
1598-
Value distributedVal = newWarpOp.getResult(operandIdx);
1599-
rewriter.replaceAllUsesWith(distributedVal, newIndexOp);
1600-
return success();
1601-
}
1602-
};
1603-
16041547
} // namespace
16051548

16061549
namespace {
@@ -1621,20 +1564,6 @@ void xegpu::populateXeGPUSubgroupDistributePatterns(
16211564
patterns.add<CreateNdDescDistribution, StoreNdDistribution,
16221565
LoadNdDistribution, DpasDistribution, PrefetchNdDistribution,
16231566
UpdateNdOffsetDistribution>(patterns.getContext());
1624-
// TODO: Is this the right place to add these patterns?
1625-
patterns.add<GpuIndexOpDistribution<gpu::BlockIdOp>,
1626-
GpuIndexOpDistribution<gpu::BlockDimOp>,
1627-
GpuIndexOpDistribution<gpu::SubgroupIdOp>,
1628-
GpuIndexOpDistribution<gpu::SubgroupSizeOp>,
1629-
GpuIndexOpDistribution<gpu::NumSubgroupsOp>,
1630-
GpuIndexOpDistribution<gpu::ClusterDimOp>,
1631-
GpuIndexOpDistribution<gpu::ClusterDimBlocksOp>,
1632-
GpuIndexOpDistribution<gpu::ClusterIdOp>,
1633-
GpuIndexOpDistribution<gpu::ClusterBlockIdOp>,
1634-
GpuIndexOpDistribution<gpu::GridDimOp>,
1635-
GpuIndexOpDistribution<gpu::ThreadIdOp>,
1636-
GpuIndexOpDistribution<gpu::LaneIdOp>,
1637-
GpuIndexOpDistribution<gpu::GlobalIdOp>>(patterns.getContext());
16381567
}
16391568

16401569
void XeGPUSubgroupDistributePass::runOnOperation() {

0 commit comments

Comments
 (0)