Skip to content

Commit 5a56a94

Browse files
authored
Merge pull request #2502 from AlexandreSinger/feature_remove_prev_node
[Route][Types] Clean Up rr_node_route_inf
2 parents 6921a93 + cd7c398 commit 5a56a94

File tree

10 files changed

+16
-62
lines changed

10 files changed

+16
-62
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 & 9 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.
@@ -1729,20 +1726,15 @@ constexpr bool is_src_sink(e_rr_type type) { return (type == SOURCE || type == S
17291726
* is being used.
17301727
* @param backward_path_cost Total cost of the path up to and including this
17311728
* node.
1732-
* @param target_flag Is this node a target (sink) for the current routing?
1733-
* Number of times this node must be reached to fully route.
17341729
* @param occ The current occupancy of the associated rr node
17351730
*/
17361731
struct t_rr_node_route_inf {
1737-
RRNodeId prev_node;
17381732
RREdgeId prev_edge;
17391733

17401734
float acc_cost;
17411735
float path_cost;
17421736
float backward_path_cost;
17431737

1744-
short target_flag;
1745-
17461738
public: //Accessors
17471739
short occ() const { return occ_; }
17481740

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 & 33 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
}
@@ -315,34 +314,6 @@ float get_rr_cong_cost(RRNodeId inode, float pres_fac) {
315314
return (cost);
316315
}
317316

318-
/* Mark all the SINKs of this net as targets by setting their target flags *
319-
* to the number of times the net must connect to each SINK. Note that *
320-
* this number can occasionally be greater than 1 -- think of connecting *
321-
* the same net to two inputs of an and-gate (and-gate inputs are logically *
322-
* equivalent, so both will connect to the same SINK). */
323-
void mark_ends(const Netlist<>& net_list, ParentNetId net_id) {
324-
unsigned int ipin;
325-
RRNodeId inode;
326-
327-
auto& route_ctx = g_vpr_ctx.mutable_routing();
328-
329-
for (ipin = 1; ipin < net_list.net_pins(net_id).size(); ipin++) {
330-
inode = route_ctx.net_rr_terminals[net_id][ipin];
331-
route_ctx.rr_node_route_inf[inode].target_flag++;
332-
}
333-
}
334-
335-
/** like mark_ends, but only performs it for the remaining sinks of a net */
336-
void mark_remaining_ends(ParentNetId net_id) {
337-
auto& route_ctx = g_vpr_ctx.mutable_routing();
338-
const auto& tree = route_ctx.route_trees[net_id].value();
339-
340-
for (int sink_pin : tree.get_remaining_isinks()) {
341-
RRNodeId inode = route_ctx.net_rr_terminals[net_id][sink_pin];
342-
++route_ctx.rr_node_route_inf[inode].target_flag;
343-
}
344-
}
345-
346317
//Calculates how many (and allocates space for) OPINs which must be reserved to
347318
//respect 'instance' equivalence.
348319
//
@@ -448,12 +419,10 @@ void reset_rr_node_route_structs() {
448419
for (const RRNodeId& rr_id : device_ctx.rr_graph.nodes()) {
449420
auto& node_inf = route_ctx.rr_node_route_inf[rr_id];
450421

451-
node_inf.prev_node = RRNodeId::INVALID();
452422
node_inf.prev_edge = RREdgeId::INVALID();
453423
node_inf.acc_cost = 1.0;
454424
node_inf.path_cost = std::numeric_limits<float>::infinity();
455425
node_inf.backward_path_cost = std::numeric_limits<float>::infinity();
456-
node_inf.target_flag = 0;
457426
node_inf.set_occ(0);
458427
}
459428
}
@@ -937,8 +906,8 @@ void print_rr_node_route_inf() {
937906
for (size_t inode = 0; inode < route_ctx.rr_node_route_inf.size(); ++inode) {
938907
const auto& inf = route_ctx.rr_node_route_inf[RRNodeId(inode)];
939908
if (!std::isinf(inf.path_cost)) {
940-
RRNodeId prev_node = inf.prev_node;
941909
RREdgeId prev_edge = inf.prev_edge;
910+
RRNodeId prev_node = rr_graph.edge_src_node(prev_edge);
942911
auto switch_id = rr_graph.rr_nodes().edge_switch(prev_edge);
943912
VTR_LOG("rr_node: %d prev_node: %d prev_edge: %zu",
944913
inode, prev_node, (size_t)prev_edge);
@@ -973,8 +942,8 @@ void print_rr_node_route_inf_dot() {
973942
for (size_t inode = 0; inode < route_ctx.rr_node_route_inf.size(); ++inode) {
974943
const auto& inf = route_ctx.rr_node_route_inf[RRNodeId(inode)];
975944
if (!std::isinf(inf.path_cost)) {
976-
RRNodeId prev_node = inf.prev_node;
977945
RREdgeId prev_edge = inf.prev_edge;
946+
RRNodeId prev_node = rr_graph.edge_src_node(prev_edge);
978947
auto switch_id = rr_graph.rr_nodes().edge_switch(prev_edge);
979948

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

vpr/src/route/route_common.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,6 @@ inline float get_single_rr_cong_cost(RRNodeId inode, float pres_fac) {
113113
return cost;
114114
}
115115

116-
void mark_ends(const Netlist<>& net_list, ParentNetId net_id);
117-
118-
void mark_remaining_ends(ParentNetId net_id);
119-
120116
void add_to_mod_list(RRNodeId inode, std::vector<RRNodeId>& modified_rr_node_inf);
121117

122118
void init_route_structs(const Netlist<>& net_list,

vpr/src/route/route_net.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ void setup_net(int itry,
4242

4343
// since all connections will be rerouted for this net, clear all of net's forced reroute flags
4444
connections_inf.clear_force_reroute_for_net(net_id);
45-
46-
// when we don't prune the tree, we also don't know the sink node indices
47-
// thus we'll use functions that act on pin indices like mark_ends instead
48-
// of their versions that act on node indices directly like mark_remaining_ends
49-
mark_ends(net_list, net_id);
5045
} else {
5146
profiling::net_rebuild_start();
5247

@@ -92,9 +87,6 @@ void setup_net(int itry,
9287
// congestion should've been pruned away
9388
VTR_ASSERT_SAFE(tree->is_uncongested());
9489

95-
// mark remaining ends
96-
mark_remaining_ends(net_id);
97-
9890
// mark the lookup (rr_node_route_inf) for existing tree elements as NO_PREVIOUS so add_to_path stops when it reaches one of them
9991
update_rr_route_inf_from_tree(tree->root());
10092
}
@@ -125,7 +117,6 @@ void update_rr_route_inf_from_tree(const RouteTreeNode& rt_node) {
125117

126118
for (auto& node : rt_node.all_nodes()) {
127119
RRNodeId inode = node.inode;
128-
route_ctx.rr_node_route_inf[inode].prev_node = RRNodeId::INVALID();
129120
route_ctx.rr_node_route_inf[inode].prev_edge = RREdgeId::INVALID();
130121

131122
// path cost should be unset

vpr/src/route/route_net.tpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,6 @@ inline NetResultFlags route_sink(ConnectionRouter& router,
448448

449449
profiling::sink_criticality_end(cost_params.criticality);
450450

451-
RRNodeId inode(cheapest.index);
452-
route_ctx.rr_node_route_inf[inode].target_flag--; /* Connected to this SINK. */
453-
454451
vtr::optional<const RouteTreeNode&> new_branch, new_sink;
455452
std::tie(new_branch, new_sink) = tree.update_from_heap(&cheapest, target_pin, ((high_fanout) ? &spatial_rt_lookup : nullptr), is_flat);
456453

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)