Skip to content

Commit 0e9e3a8

Browse files
erwei-xilinxclaude
andcommitted
[Path B] allocateLockOp: scope ID reservation to same-col LTOs
The cross-LTO lock-ID reservation logic added during Path B was too aggressive: any LogicalTileOp would walk locks from EVERY LTO of the same tile_type and union their IDs, even LTOs at different col hints that aie-place-tiles will resolve to physically-distinct tiles. For bf16_cascade (8 memtile cols × 10 locks each), this assigned IDs 0..79 across the 8 memtile LTOs instead of 0..9 per tile. NPU2 memtiles cap at lockID=63, so air-to-aie's verifier rejected the IR: 'aie.lock' op lock assigned invalid id (maximum is 63) The reservation only matters when LTOs MIGHT collapse to the same physical tile post-place. LTOs with different col hints are guaranteed to land on different cols (and therefore different physical tiles), so their lock IDs cannot collide. Restrict the reservation walk to LTOs sharing the same (col, tile_type) — same-col same-type LTOs are the only ones aie-place-tiles can fold together. Verified locally: - check-air-mlir: 383/392 pass (same as before, no regressions) - matrix_vector_multiplication/bf16_cascade: compiles cleanly through air-to-aie + aie-place-tiles + downstream pipelines - matrix_scalar_add, dual_herd_packet_switch, 33_triton: still compile cleanly Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0e03a23 commit 0e9e3a8

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

mlir/lib/Conversion/AIRToAIESchedulingUtils.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,31 @@ AIE::LockOp air::allocateLockOp(AIE::DeviceOp aie_device, AIE::TileLike tile,
9090
Operation *tileOp = tile.getOperation();
9191
bool tileIsLogical = isa<AIE::LogicalTileOp>(tileOp);
9292
// For logical tiles, multiple distinct LTOs can collapse onto the same
93-
// physical aie.tile during aie-place-tiles (mem/shim getOrCreate). To avoid
94-
// post-collapse lock-ID collisions, AIR walks all locks owned by ANY tile
95-
// of the same TileLike type and reserves their IDs as well — over-assigning
96-
// IDs is fine; collisions are not. The downstream `aie-assign-lock-ids`
97-
// pass would normalize anyway, but assigning conflict-free IDs at AIR-emit
98-
// time keeps lit-test CHECKs predictable.
93+
// physical aie.tile during aie-place-tiles only when they share the same
94+
// (col, tile_type) — different cols always resolve to different physical
95+
// tiles. Reserve IDs across same-col same-type LTOs so post-collapse
96+
// assignments don't collide. Reserving across ALL same-type LTOs (across
97+
// every col) blows the per-tile lock budget in workloads like
98+
// bf16_cascade where 8 memtile LTOs each need 10 locks: union'd IDs
99+
// become 0..79, but the per-tile max is 63.
99100
AIE::AIETileType tileType = tile.getTileType();
101+
std::optional<int32_t> tileCol;
102+
if (tileIsLogical)
103+
tileCol = cast<AIE::LogicalTileOp>(tileOp).getCol();
100104
aie_device.walk([&](AIE::LockOp l) {
101105
auto lockTileOp = l.getTile().getDefiningOp();
102106
bool ownerMatches = (lockTileOp == tileOp);
103107
if (!ownerMatches && tileIsLogical) {
104-
auto otherTileLike = dyn_cast_if_present<AIE::TileLike>(lockTileOp);
105-
if (otherTileLike && otherTileLike.getTileType() == tileType)
106-
ownerMatches = true;
108+
auto otherLT = dyn_cast_if_present<AIE::LogicalTileOp>(lockTileOp);
109+
if (otherLT && otherLT.getTileType() == tileType) {
110+
// Only reserve across LTOs that COULD share a physical tile post-
111+
// collapse: same col hint (or both unhinted, since aie-place-tiles
112+
// may put both at the same col). Differently-hinted LTOs always
113+
// resolve to different cols.
114+
auto otherCol = otherLT.getCol();
115+
if (tileCol == otherCol)
116+
ownerMatches = true;
117+
}
107118
}
108119
if (!ownerMatches)
109120
return;

0 commit comments

Comments
 (0)