Skip to content

Commit

Permalink
Use a BitSet for detecting accessible tiles
Browse files Browse the repository at this point in the history
Signed-off-by: Eddie Hung <eddie.hung@amd.com>
  • Loading branch information
eddieh-xlnx committed Sep 26, 2024
1 parent 8712ad9 commit f4f8222
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/com/xilinx/rapidwright/rwroute/CUFR.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected RouteNodeGraph createRouteNodeGraph() {

@Override
protected ConnectionState getConnectionState() {
return connectionState.computeIfAbsent(Thread.currentThread(), (k) -> new ConnectionState());
return connectionState.computeIfAbsent(Thread.currentThread(), (k) -> new ConnectionState(routingGraph.getTileCount(design)));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/com/xilinx/rapidwright/rwroute/PartialCUFR.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected RouteNodeGraph createRouteNodeGraph() {

@Override
protected ConnectionState getConnectionState() {
return connectionState.computeIfAbsent(Thread.currentThread(), (k) -> new ConnectionState());
return connectionState.computeIfAbsent(Thread.currentThread(), (k) -> new ConnectionState(routingGraph.getTileCount(design)));
}

@Override
Expand Down
35 changes: 25 additions & 10 deletions src/com/xilinx/rapidwright/rwroute/RWRoute.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
Expand Down Expand Up @@ -247,7 +248,7 @@ protected void initialize() {
minRerouteCriticality = config.getMinRerouteCriticality();
criticalConnections = new ArrayList<>();

connectionState = new ConnectionState();
connectionState = new ConnectionState(routingGraph.getTileCount(design));
routingGraph = createRouteNodeGraph();
if (config.isTimingDriven()) {
nodesDelays = new HashMap<>();
Expand Down Expand Up @@ -1482,6 +1483,10 @@ protected static class ConnectionState {
protected final PriorityQueue<PriorityQueueEntry> queue;
/** The list of nodes marked as a target for this connection */
protected final List<RouteNode> targets;
/** Connection-specific temporary list for RouteNode.getChildren() */
protected final List<Node> tempNodeList;
/** BitSet of Tile.getUniqueAddress() -es that are above/below/at sink tile */
protected final BitSet addressesBelowAboveAndAtSinkTile;

/** Connection to be routed */
protected Connection connection;
Expand All @@ -1496,13 +1501,11 @@ protected static class ConnectionState {
protected float dlyWeight;
protected float estDlyWeight;

/** Connection-specific temporary list for RouteNode.getChildren() */
protected List<Node> tempNodeList;

protected ConnectionState() {
protected ConnectionState(int tileCount) {
queue = new PriorityQueue<>();
targets = new ArrayList<>();
tempNodeList = new ArrayList<>();
addressesBelowAboveAndAtSinkTile = new BitSet(tileCount);
}
}

Expand Down Expand Up @@ -1731,7 +1734,7 @@ private void exploreAndExpand(ConnectionState state, RouteNode rnode, float upst
}
switch (childRNode.getType()) {
case WIRE:
if (!routingGraph.isAccessible(childRNode, connection)) {
if (!routingGraph.isAccessible(childRNode, state)) {
continue;
}
if (!config.isUseUTurnNodes() && childRNode.getDelay() > 10000) {
Expand All @@ -1743,7 +1746,7 @@ private void exploreAndExpand(ConnectionState state, RouteNode rnode, float upst
case PINBOUNCE:
// A PINBOUNCE can only be a target if this connection has an alternate sink
assert(!childRNode.isTarget() || connection.getAltSinkRnodes().isEmpty());
if (!isAccessiblePinbounce(childRNode, connection)) {
if (!isAccessiblePinbounce(childRNode, state)) {
continue;
}
break;
Expand Down Expand Up @@ -1789,13 +1792,13 @@ protected boolean isAccessible(RouteNode child, Connection connection) {
/**
* Checks if a NODE_PINBOUNCE is suitable to be used for routing to a target.
* @param child The PINBOUNCE rnode in question.
* @param connection The connection to route.
* @param state State from the connection that is being routed.
* @return true, if the PINBOUNCE rnode is in the same column as the target and within one INT tile of the target.
*/
protected boolean isAccessiblePinbounce(RouteNode child, Connection connection) {
protected boolean isAccessiblePinbounce(RouteNode child, ConnectionState state) {
assert(child.getType() == RouteNodeType.PINBOUNCE);

return routingGraph.isAccessible(child, connection);
return routingGraph.isAccessible(child, state);
}

protected boolean isAccessiblePinfeedI(RouteNode child, Connection connection) {
Expand Down Expand Up @@ -1958,6 +1961,18 @@ protected void prepareRouteConnection(ConnectionState state) {
// Sets the sink rnode(s) of the connection as the target(s)
connection.setAllTargets(state);

Tile sinkTile = connection.getSinkRnode().getTile();
state.addressesBelowAboveAndAtSinkTile.clear();
state.addressesBelowAboveAndAtSinkTile.set(sinkTile.getUniqueAddress());
Tile aboveSinkTile = sinkTile.getTileXYNeighbor(0, 1);
if (aboveSinkTile != null) {
state.addressesBelowAboveAndAtSinkTile.set(aboveSinkTile.getUniqueAddress());
}
Tile belowSinkTile = sinkTile.getTileXYNeighbor(0, -1);
if (belowSinkTile != null) {
state.addressesBelowAboveAndAtSinkTile.set(belowSinkTile.getUniqueAddress());
}

// Adds the source rnode to the queue
RouteNode sourceRnode = connection.getSourceRnode();
assert(sourceRnode.getPrev() == null);
Expand Down

0 comments on commit f4f8222

Please sign in to comment.