Skip to content

Commit

Permalink
Make pathfinder aware of the arch-specific routing constraints (#657)
Browse files Browse the repository at this point in the history
  • Loading branch information
erwei-xilinx authored Sep 26, 2023
1 parent cb25fae commit 9236591
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
4 changes: 2 additions & 2 deletions include/aie/Dialect/AIE/Transforms/AIEPathfinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ class Pathfinder {

public:
Pathfinder();
Pathfinder(int maxcol, int maxrow);
void initializeGraph(int maxcol, int maxrow);
Pathfinder(int maxcol, int maxrow, DeviceOp &d);
void initializeGraph(int maxcol, int maxrow, DeviceOp &d);
void addFlow(Coord srcCoords, Port srcPort, Coord dstCoords, Port dstPort);
void addFixedConnection(Coord coord, Port port);
bool isLegal();
Expand Down
2 changes: 1 addition & 1 deletion lib/Dialect/AIE/Transforms/AIECreatePathfindFlows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class DynamicTileAnalysis {
maxrow = std::max(maxrow, tileOp.rowIndex());
}

pathfinder = Pathfinder(maxcol, maxrow);
pathfinder = Pathfinder(maxcol, maxrow, d);

// for each flow in the device, add it to pathfinder
// each source can map to multiple different destinations (fanout)
Expand Down
45 changes: 29 additions & 16 deletions lib/Dialect/AIE/Transforms/AIEPathfinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ WireBundle getConnectingBundle(WireBundle dir) {
}
}

Pathfinder::Pathfinder() { initializeGraph(0, 0); }
Pathfinder::Pathfinder() {}

Pathfinder::Pathfinder(int _maxcol, int _maxrow) {
initializeGraph(_maxcol, _maxrow);
Pathfinder::Pathfinder(int _maxcol, int _maxrow, DeviceOp &d) {
initializeGraph(_maxcol, _maxrow, d);
}

void Pathfinder::initializeGraph(int maxcol, int maxrow) {
void Pathfinder::initializeGraph(int maxcol, int maxrow, DeviceOp &d) {
const auto &targetModel = d.getTargetModel();
// make grid of switchboxes
for (int row = 0; row <= maxrow; row++) {
for (int col = 0; col <= maxcol; col++) {
Expand All @@ -54,20 +55,32 @@ void Pathfinder::initializeGraph(int maxcol, int maxrow) {
graph[id].pred = 0;
graph[id].processed = false;
if (row > 0) { // if not in row 0 add channel to North/South
auto north_edge = add_edge(id - maxcol - 1, id, graph).first;
graph[north_edge].bundle = WireBundle::North;
graph[north_edge].max_capacity = 6;
auto south_edge = add_edge(id, id - maxcol - 1, graph).first;
graph[south_edge].bundle = WireBundle::South;
graph[south_edge].max_capacity = 4;
if (auto max_capacity = targetModel.getNumSourceSwitchboxConnections(
col, row, WireBundle::South)) {
auto north_edge = add_edge(id - maxcol - 1, id, graph).first;
graph[north_edge].bundle = WireBundle::North;
graph[north_edge].max_capacity = max_capacity;
}
if (auto max_capacity = targetModel.getNumDestSwitchboxConnections(
col, row, WireBundle::South)) {
auto south_edge = add_edge(id, id - maxcol - 1, graph).first;
graph[south_edge].bundle = WireBundle::South;
graph[south_edge].max_capacity = max_capacity;
}
}
if (col > 0) { // if not in col 0 add channel to East/West
auto east_edge = add_edge(id - 1, id, graph).first;
graph[east_edge].bundle = WireBundle::East;
graph[east_edge].max_capacity = 4;
auto west_edge = add_edge(id, id - 1, graph).first;
graph[west_edge].bundle = WireBundle::West;
graph[west_edge].max_capacity = 4;
if (auto max_capacity = targetModel.getNumSourceSwitchboxConnections(
col, row, WireBundle::West)) {
auto east_edge = add_edge(id - 1, id, graph).first;
graph[east_edge].bundle = WireBundle::East;
graph[east_edge].max_capacity = max_capacity;
}
if (auto max_capacity = targetModel.getNumDestSwitchboxConnections(
col, row, WireBundle::West)) {
auto west_edge = add_edge(id, id - 1, graph).first;
graph[west_edge].bundle = WireBundle::West;
graph[west_edge].max_capacity = max_capacity;
}
}
}
}
Expand Down

0 comments on commit 9236591

Please sign in to comment.