From f4f8222be8529191b7baf1c95c8f7c64a2858672 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Thu, 26 Sep 2024 11:55:51 -0700 Subject: [PATCH] Use a BitSet for detecting accessible tiles Signed-off-by: Eddie Hung --- src/com/xilinx/rapidwright/rwroute/CUFR.java | 2 +- .../rapidwright/rwroute/PartialCUFR.java | 2 +- .../xilinx/rapidwright/rwroute/RWRoute.java | 35 +++++++++++++------ 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/com/xilinx/rapidwright/rwroute/CUFR.java b/src/com/xilinx/rapidwright/rwroute/CUFR.java index 856a3af46..1711718f0 100644 --- a/src/com/xilinx/rapidwright/rwroute/CUFR.java +++ b/src/com/xilinx/rapidwright/rwroute/CUFR.java @@ -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 diff --git a/src/com/xilinx/rapidwright/rwroute/PartialCUFR.java b/src/com/xilinx/rapidwright/rwroute/PartialCUFR.java index 57613f7ab..b3c24fa13 100644 --- a/src/com/xilinx/rapidwright/rwroute/PartialCUFR.java +++ b/src/com/xilinx/rapidwright/rwroute/PartialCUFR.java @@ -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 diff --git a/src/com/xilinx/rapidwright/rwroute/RWRoute.java b/src/com/xilinx/rapidwright/rwroute/RWRoute.java index 1ea57640f..b5d83f953 100644 --- a/src/com/xilinx/rapidwright/rwroute/RWRoute.java +++ b/src/com/xilinx/rapidwright/rwroute/RWRoute.java @@ -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; @@ -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<>(); @@ -1482,6 +1483,10 @@ protected static class ConnectionState { protected final PriorityQueue queue; /** The list of nodes marked as a target for this connection */ protected final List targets; + /** Connection-specific temporary list for RouteNode.getChildren() */ + protected final List tempNodeList; + /** BitSet of Tile.getUniqueAddress() -es that are above/below/at sink tile */ + protected final BitSet addressesBelowAboveAndAtSinkTile; /** Connection to be routed */ protected Connection connection; @@ -1496,13 +1501,11 @@ protected static class ConnectionState { protected float dlyWeight; protected float estDlyWeight; - /** Connection-specific temporary list for RouteNode.getChildren() */ - protected List tempNodeList; - - protected ConnectionState() { + protected ConnectionState(int tileCount) { queue = new PriorityQueue<>(); targets = new ArrayList<>(); tempNodeList = new ArrayList<>(); + addressesBelowAboveAndAtSinkTile = new BitSet(tileCount); } } @@ -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) { @@ -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; @@ -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) { @@ -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);