Skip to content

Commit cd7c398

Browse files
[Route][Types] Removed prev_node from t_rr_node_route_inf
Removed the prev_node member of t_rr_node_route_inf since the information can easily be found by getting the source of the previous edge. This will reduce the size of the data that needs to be collected during routing. This may also make the route function a bit faster since the previous node does not need to be stored during the wave expansion; however, this may make reconstructing the path slower. Also updated the comment in the t_rr_node_route_inf struct regarding the prev_edge member, since it was no longer accurate. The edge ID used to be an index into the edges of the previous node; however, that has since changed to a globally unique ID within the RR Graph.
1 parent 3afd2ed commit cd7c398

File tree

8 files changed

+16
-14
lines changed

8 files changed

+16
-14
lines changed

libs/librrgraph/src/base/rr_graph_storage.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,11 @@ class t_rr_graph_storage {
336336
return ret;
337337
}
338338

339+
/** @brief Get the source node for the specified edge. */
340+
RRNodeId edge_src_node(const RREdgeId& edge) const {
341+
return edge_src_node_[edge];
342+
}
343+
339344
/** @brief Get the destination node for the specified edge. */
340345
RRNodeId edge_sink_node(const RREdgeId& edge) const {
341346
return edge_dest_node_[edge];

libs/librrgraph/src/base/rr_graph_view.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,12 @@ class RRGraphView {
321321
inline short edge_switch(RRNodeId id, t_edge_size iedge) const {
322322
return node_storage_.edge_switch(id, iedge);
323323
}
324+
325+
/** @brief Get the source node for the specified edge. */
326+
inline RRNodeId edge_src_node(const RREdgeId edge_id) const {
327+
return node_storage_.edge_src_node(edge_id);
328+
}
329+
324330
/** @brief Get the destination node for the iedge'th edge from specified RRNodeId.
325331
* This method should generally not be used, and instead first_edge and
326332
* last_edge should be used.*/

vpr/src/base/vpr_types.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,10 +1717,7 @@ constexpr bool is_src_sink(e_rr_type type) { return (type == SOURCE || type == S
17171717
* @brief Extra information about each rr_node needed only during routing
17181718
* (i.e. during the maze expansion).
17191719
*
1720-
* @param prev_node Index of the previous node (on the lowest cost path known
1721-
* to reach this node); used to generate the traceback.
1722-
* If there is no predecessor, prev_node = NO_PREVIOUS.
1723-
* @param prev_edge Index of the edge (from 0 to num_edges-1 of prev_node)
1720+
* @param prev_edge ID of the edge (globally unique edge ID in the RR Graph)
17241721
* that was used to reach this node from the previous node.
17251722
* If there is no predecessor, prev_edge = NO_PREVIOUS.
17261723
* @param acc_cost Accumulated cost term from previous Pathfinder iterations.
@@ -1732,7 +1729,6 @@ constexpr bool is_src_sink(e_rr_type type) { return (type == SOURCE || type == S
17321729
* @param occ The current occupancy of the associated rr node
17331730
*/
17341731
struct t_rr_node_route_inf {
1735-
RRNodeId prev_node;
17361732
RREdgeId prev_edge;
17371733

17381734
float acc_cost;

vpr/src/route/connection_router.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ class ConnectionRouter : public ConnectionRouterInterface {
145145
//Record final link to target
146146
add_to_mod_list(cheapest->index);
147147

148-
route_inf->prev_node = cheapest->prev_node();
149148
route_inf->prev_edge = cheapest->prev_edge();
150149
route_inf->path_cost = cheapest->cost;
151150
route_inf->backward_path_cost = cheapest->backward_path_cost;

vpr/src/route/route_common.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ void reset_path_costs(const std::vector<RRNodeId>& visited_rr_nodes) {
286286
for (auto node : visited_rr_nodes) {
287287
route_ctx.rr_node_route_inf[node].path_cost = std::numeric_limits<float>::infinity();
288288
route_ctx.rr_node_route_inf[node].backward_path_cost = std::numeric_limits<float>::infinity();
289-
route_ctx.rr_node_route_inf[node].prev_node = RRNodeId::INVALID();
290289
route_ctx.rr_node_route_inf[node].prev_edge = RREdgeId::INVALID();
291290
}
292291
}
@@ -420,7 +419,6 @@ void reset_rr_node_route_structs() {
420419
for (const RRNodeId& rr_id : device_ctx.rr_graph.nodes()) {
421420
auto& node_inf = route_ctx.rr_node_route_inf[rr_id];
422421

423-
node_inf.prev_node = RRNodeId::INVALID();
424422
node_inf.prev_edge = RREdgeId::INVALID();
425423
node_inf.acc_cost = 1.0;
426424
node_inf.path_cost = std::numeric_limits<float>::infinity();
@@ -908,8 +906,8 @@ void print_rr_node_route_inf() {
908906
for (size_t inode = 0; inode < route_ctx.rr_node_route_inf.size(); ++inode) {
909907
const auto& inf = route_ctx.rr_node_route_inf[RRNodeId(inode)];
910908
if (!std::isinf(inf.path_cost)) {
911-
RRNodeId prev_node = inf.prev_node;
912909
RREdgeId prev_edge = inf.prev_edge;
910+
RRNodeId prev_node = rr_graph.edge_src_node(prev_edge);
913911
auto switch_id = rr_graph.rr_nodes().edge_switch(prev_edge);
914912
VTR_LOG("rr_node: %d prev_node: %d prev_edge: %zu",
915913
inode, prev_node, (size_t)prev_edge);
@@ -944,8 +942,8 @@ void print_rr_node_route_inf_dot() {
944942
for (size_t inode = 0; inode < route_ctx.rr_node_route_inf.size(); ++inode) {
945943
const auto& inf = route_ctx.rr_node_route_inf[RRNodeId(inode)];
946944
if (!std::isinf(inf.path_cost)) {
947-
RRNodeId prev_node = inf.prev_node;
948945
RREdgeId prev_edge = inf.prev_edge;
946+
RRNodeId prev_node = rr_graph.edge_src_node(prev_edge);
949947
auto switch_id = rr_graph.rr_nodes().edge_switch(prev_edge);
950948

951949
if (prev_node.is_valid() && prev_edge.is_valid()) {

vpr/src/route/route_net.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ void update_rr_route_inf_from_tree(const RouteTreeNode& rt_node) {
117117

118118
for (auto& node : rt_node.all_nodes()) {
119119
RRNodeId inode = node.inode;
120-
route_ctx.rr_node_route_inf[inode].prev_node = RRNodeId::INVALID();
121120
route_ctx.rr_node_route_inf[inode].prev_edge = RREdgeId::INVALID();
122121

123122
// path cost should be unset

vpr/src/route/route_path_manager.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ void PathManager::insert_backwards_path_into_traceback(t_heap_path* path_data, f
4545
for (unsigned i = 1; i < path_data->edge.size() - 1; i++) {
4646
RRNodeId node_2 = path_data->path_rr[i];
4747
RREdgeId edge = path_data->edge[i - 1];
48-
route_ctx.rr_node_route_inf[node_2].prev_node = path_data->path_rr[i - 1];
4948
route_ctx.rr_node_route_inf[node_2].prev_edge = edge;
5049
route_ctx.rr_node_route_inf[node_2].path_cost = cost;
5150
route_ctx.rr_node_route_inf[node_2].backward_path_cost = backward_path_cost;

vpr/src/route/route_tree.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ RouteTree::add_subtree_from_heap(t_heap* hptr, int target_net_pin_index, bool is
532532
* new_branch_inodes: [sink, nodeN-1, nodeN-2, ... node 1] of length N
533533
* and new_branch_iswitches: [N-1->sink, N-2->N-1, ... 2->1, 1->found_node] of length N */
534534
RREdgeId edge = hptr->prev_edge();
535-
RRNodeId new_inode = RRNodeId(hptr->prev_node());
535+
RRNodeId new_inode = rr_graph.edge_src_node(edge);
536536
RRSwitchId new_iswitch = RRSwitchId(rr_graph.rr_nodes().edge_switch(edge));
537537

538538
/* build a path, looking up rr nodes and switches from rr_node_route_inf */
@@ -541,7 +541,7 @@ RouteTree::add_subtree_from_heap(t_heap* hptr, int target_net_pin_index, bool is
541541
new_branch_inodes.push_back(new_inode);
542542
new_branch_iswitches.push_back(new_iswitch);
543543
edge = route_ctx.rr_node_route_inf[new_inode].prev_edge;
544-
new_inode = RRNodeId(route_ctx.rr_node_route_inf[new_inode].prev_node);
544+
new_inode = rr_graph.edge_src_node(edge);
545545
new_iswitch = RRSwitchId(rr_graph.rr_nodes().edge_switch(edge));
546546
}
547547
new_branch_iswitches.push_back(new_iswitch);

0 commit comments

Comments
 (0)