Skip to content

Commit 05ef19a

Browse files
yenjamesclaude
andcommitted
Add tile type filtering to sequential placer to ensure mem/shim tiles are placed correctly.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 9176b75 commit 05ef19a

5 files changed

Lines changed: 25 additions & 11 deletions

File tree

include/aie/Dialect/AIE/Transforms/AIEPlacer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ class SequentialPlacer : public Placer {
8686
std::optional<TileID> findTileWithCapacity(int targetCol,
8787
std::vector<TileID> &tiles,
8888
int requiredInputChannels,
89-
int requiredOutputChannels);
89+
int requiredOutputChannels,
90+
AIETileType requestedType);
9091

9192
void updateChannelUsage(TileID tile, bool isOutput, int numChannels);
9293

lib/Dialect/AIE/Transforms/AIEPlaceTiles.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ struct AIEPlaceTilesPass : AIEPlaceTilesBase<AIEPlaceTilesPass> {
8080
target.addLegalOp<TileOp>();
8181
target.addIllegalOp<LogicalTileOp>();
8282

83+
// Mark all other AIE dialect operations as legal
84+
// They will have their operands automatically updated when LogicalTileOp -> TileOp
85+
target.addLegalDialect<AIEDialect>();
86+
8387
RewritePatternSet patterns(&getContext());
8488
patterns.add<ConvertLogicalTileToTile>(device.getContext(), device,
8589
analyzer);

lib/Dialect/AIE/Transforms/AIEPlacer.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,10 @@ LogicalResult SequentialPlacer::place(ArrayRef<Operation *> logicalTiles,
189189
}
190190

191191
// Find tile with capacity near common column
192+
// Pass tile type to ensure we only search for matching tile types
192193
auto maybeTile = findTileWithCapacity(commonCol, availability.nonCompTiles,
193-
numInputChannels, numOutputChannels);
194+
numInputChannels, numOutputChannels,
195+
logicalTile.getTileType());
194196
if (!maybeTile)
195197
return logicalTile.emitError("no tile with sufficient DMA capacity");
196198

@@ -300,12 +302,14 @@ PlacementAnalysis::getPlacement(Operation *logicalTile) const {
300302
// Find tile with available DMA capacity near target column
301303
// This function checks capacity for BOTH input and output channels
302304
// simultaneously. For unidirectional tiles, pass 0 for the unused direction:
303-
// - Input-only: findTileWithCapacity(..., numInputChannels, 0)
304-
// - Output-only: findTileWithCapacity(..., 0, numOutputChannels)
305-
// - Both: findTileWithCapacity(..., numInputChannels, numOutputChannels)
305+
// - Input-only: findTileWithCapacity(..., numInputChannels, 0, type)
306+
// - Output-only: findTileWithCapacity(..., 0, numOutputChannels, type)
307+
// - Both: findTileWithCapacity(..., numInputChannels, numOutputChannels, type)
308+
// The requestedType parameter filters tiles to only consider matching types
309+
// (e.g., only MemTiles for MemTile logical tiles, only ShimNOCTiles for shims).
306310
std::optional<TileID> SequentialPlacer::findTileWithCapacity(
307311
int targetCol, std::vector<TileID> &tiles, int requiredInputChannels,
308-
int requiredOutputChannels) {
312+
int requiredOutputChannels, AIETileType requestedType) {
309313
// Search starting from target column, expanding outward
310314
int maxCol = targetModel->columns();
311315

@@ -315,6 +319,11 @@ std::optional<TileID> SequentialPlacer::findTileWithCapacity(
315319
continue;
316320

317321
for (auto &tile : tiles) {
322+
// Filter by tile type - only consider tiles of the requested type
323+
AIETileType tileType = targetModel->getTileType(tile.col, tile.row);
324+
if (tileType != requestedType)
325+
continue;
326+
318327
if (tile.col == searchCol) {
319328
// Check if tile has capacity for both input and output channels
320329
if (hasAvailableChannels(tile, requiredInputChannels,

test/place-tiles/sequential_placer/place_tiles_constrained.mlir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ module @mixed_constraints {
3737
// CHECK-DAG: %[[C1:.*]] = aie.tile(1, 2)
3838
%c1 = aie.logical_tile<CoreTile>(1, 2)
3939

40-
// First available should be (0, 2)
40+
// First available should be (0, 2) - sequential placement starts at column 0
4141
// CHECK-DAG: %[[C2:.*]] = aie.tile(0, 2)
4242
%c2 = aie.logical_tile<CoreTile>(?, ?)
43-
// Second available should be (2, 2) (skipping already used (1, 2))
44-
// CHECK-DAG: %[[C3:.*]] = aie.tile(2, 2)
43+
// Second available should be (0, 3) - column-major sequential (fill column 0 first)
44+
// CHECK-DAG: %[[C3:.*]] = aie.tile(0, 3)
4545
%c3 = aie.logical_tile<CoreTile>(?, ?)
4646

4747
// CHECK: aie.core(%[[C1]])
@@ -61,7 +61,7 @@ module @mixed_constraints {
6161
// CHECK-LABEL: @constrained_memtile_shimtile
6262
module @constrained_memtile_shimtile {
6363
aie.device(npu1) {
64-
// CHECK-DAG: %[[CORE:.*]] = aie.tile(1, 2)
64+
// CHECK-DAG: %[[CORE:.*]] = aie.tile(0, 2)
6565
%core = aie.logical_tile<CoreTile>(?, ?)
6666

6767
// MemTile fully constrained to (1, 1)

test/place-tiles/sequential_placer/place_tiles_objectfifo.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ module @multi_consumer {
6666
%shim = aie.logical_tile<ShimNOCTile>(?, ?)
6767
// CHECK-DAG: %[[CORE1:.*]] = aie.tile(0, 2)
6868
%core1 = aie.logical_tile<CoreTile>(?, ?)
69-
// CHECK-DAG: %[[CORE2:.*]] = aie.tile(1, 2)
69+
// CHECK-DAG: %[[CORE2:.*]] = aie.tile(0, 3)
7070
%core2 = aie.logical_tile<CoreTile>(?, ?)
7171

7272
// One producer, multiple consumers (needs 2 output channels from shim)

0 commit comments

Comments
 (0)