Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d540887

Browse files
committedMar 23, 2024
duplicate rr_node_route_inf for decomp router
1 parent e5af061 commit d540887

24 files changed

+137
-168
lines changed
 

‎utils/route_diag/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static void do_one_route(const Netlist<>& net_list,
139139
tree.print();
140140
VTR_LOG("\n");
141141

142-
VTR_ASSERT_MSG(route_ctx.rr_node_route_inf[tree.root().inode].occ() <= rr_graph.node_capacity(tree.root().inode), "SOURCE should never be congested");
142+
VTR_ASSERT_MSG(route_ctx.rr_node_occ_inf[tree.root().inode].occ() <= rr_graph.node_capacity(tree.root().inode), "SOURCE should never be congested");
143143
} else {
144144
VTR_LOG("Routing failed");
145145
}

‎vpr/src/base/old_traceback.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void print_traceback(const t_trace* trace) {
130130
VTR_LOG("*"); //Reached non-configurably
131131
}
132132

133-
if (route_ctx.rr_node_route_inf[inode].occ() > rr_graph.node_capacity(inode)) {
133+
if (route_ctx.rr_node_occ_inf[inode].occ() > rr_graph.node_capacity(inode)) {
134134
VTR_LOG(" x"); //Overused
135135
}
136136
VTR_LOG("\n");

‎vpr/src/base/vpr_context.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,8 @@ struct RoutingContext : public Context {
435435

436436
vtr::vector<RRNodeId, t_rr_node_route_inf> rr_node_route_inf; /* [0..device_ctx.num_rr_nodes-1] */
437437

438+
vtr::vector<RRNodeId, t_rr_node_occ_inf> rr_node_occ_inf; /* [0..device_ctx.num_rr_nodes-1] */
439+
438440
vtr::vector<ParentNetId, std::vector<std::vector<int>>> net_terminal_groups;
439441

440442
vtr::vector<ParentNetId, std::vector<int>> net_terminal_group_num;

‎vpr/src/base/vpr_types.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,31 +1723,36 @@ constexpr bool is_src_sink(e_rr_type type) { return (type == SOURCE || type == S
17231723
* @param prev_edge Index of the edge (from 0 to num_edges-1 of prev_node)
17241724
* that was used to reach this node from the previous node.
17251725
* If there is no predecessor, prev_edge = NO_PREVIOUS.
1726-
* @param acc_cost Accumulated cost term from previous Pathfinder iterations.
17271726
* @param path_cost Total cost of the path up to and including this node +
17281727
* the expected cost to the target if the timing_driven router
17291728
* is being used.
17301729
* @param backward_path_cost Total cost of the path up to and including this
17311730
* 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.
1734-
* @param occ The current occupancy of the associated rr node
17351731
*/
17361732
struct t_rr_node_route_inf {
17371733
RRNodeId prev_node;
17381734
RREdgeId prev_edge;
17391735

1740-
float acc_cost;
17411736
float path_cost;
17421737
float backward_path_cost;
1738+
};
17431739

1744-
short target_flag;
1740+
/**
1741+
* @brief Occupancy related routing information about each rr_node.
1742+
*
1743+
* @param acc_cost Accumulated cost term from previous Pathfinder iterations.
1744+
* @param target_flag Is this node a target (sink) for the current routing?
1745+
* Number of times this node must be reached to fully route.
1746+
* @param occ The current occupancy of the associated rr node
1747+
*/
1748+
struct t_rr_node_occ_inf {
1749+
float acc_cost;
17451750

17461751
public: //Accessors
1747-
short occ() const { return occ_; }
1752+
inline short occ() const { return occ_; }
17481753

17491754
public: //Mutators
1750-
void set_occ(int new_occ) { occ_ = new_occ; }
1755+
inline void set_occ(int new_occ) { occ_ = new_occ; }
17511756

17521757
private: //Data
17531758
short occ_ = 0;

‎vpr/src/draw/draw_basic.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ void draw_congestion(ezgl::renderer* g) {
306306
float max_congestion_ratio = min_congestion_ratio;
307307
auto congested_rr_nodes = collect_congested_rr_nodes();
308308
for (RRNodeId inode : congested_rr_nodes) {
309-
short occ = route_ctx.rr_node_route_inf[inode].occ();
309+
short occ = route_ctx.rr_node_occ_inf[inode].occ();
310310
short capacity = rr_graph.node_capacity(inode);
311311

312312
float congestion_ratio = float(occ) / capacity;
@@ -328,10 +328,10 @@ void draw_congestion(ezgl::renderer* g) {
328328
//Sort the nodes in ascending order of value for drawing, this ensures high
329329
//valued nodes are not overdrawn by lower value ones (e.g-> when zoomed-out far)
330330
auto cmp_ascending_acc_cost = [&](RRNodeId lhs_node, RRNodeId rhs_node) {
331-
short lhs_occ = route_ctx.rr_node_route_inf[lhs_node].occ();
331+
short lhs_occ = route_ctx.rr_node_occ_inf[lhs_node].occ();
332332
short lhs_capacity = rr_graph.node_capacity(lhs_node);
333333

334-
short rhs_occ = route_ctx.rr_node_route_inf[rhs_node].occ();
334+
short rhs_occ = route_ctx.rr_node_occ_inf[rhs_node].occ();
335335
short rhs_capacity = rr_graph.node_capacity(rhs_node);
336336

337337
float lhs_cong_ratio = float(lhs_occ) / lhs_capacity;
@@ -369,7 +369,7 @@ void draw_congestion(ezgl::renderer* g) {
369369
int transparency_factor = get_rr_node_transparency(inode);
370370
if (!draw_state->draw_layer_display[layer_num].visible)
371371
continue;
372-
short occ = route_ctx.rr_node_route_inf[inode].occ();
372+
short occ = route_ctx.rr_node_occ_inf[inode].occ();
373373
short capacity = rr_graph.node_capacity(inode);
374374

375375
float congestion_ratio = float(occ) / capacity;
@@ -414,7 +414,7 @@ void draw_routing_costs(ezgl::renderer* g) {
414414
auto& route_ctx = g_vpr_ctx.routing();
415415
g->set_line_width(0);
416416

417-
VTR_ASSERT(!route_ctx.rr_node_route_inf.empty());
417+
VTR_ASSERT(!route_ctx.rr_node_occ_inf.empty());
418418

419419
float min_cost = std::numeric_limits<float>::infinity();
420420
float max_cost = -min_cost;

‎vpr/src/route/DecompNetlistRouter.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/** @file Parallel and net-decomposing case for NetlistRouter. Works like
44
* \see ParallelNetlistRouter, but tries to "decompose" nets and assign them to
55
* the next level of the partition tree where possible. */
6+
#include "globals.h"
67
#include "netlist_routers.h"
78

89
#include <tbb/task_group.h>
@@ -37,7 +38,8 @@ class DecompNetlistRouter : public NetlistRouter {
3738
const RoutingPredictor& routing_predictor,
3839
const vtr::vector<ParentNetId, std::vector<std::unordered_map<RRNodeId, int>>>& choking_spots,
3940
bool is_flat)
40-
: _routers_th(_make_router(router_lookahead, is_flat))
41+
: _rr_node_route_infs_th(g_vpr_ctx.routing().rr_node_route_inf) /* Copy existing route_inf to all threads */
42+
, _routers_th([router_lookahead, is_flat, this] { return _make_router(router_lookahead, is_flat); }) /* Call make_router on demand */
4143
, _net_list(net_list)
4244
, _router_opts(router_opts)
4345
, _connections_inf(connections_inf)
@@ -80,7 +82,6 @@ class DecompNetlistRouter : public NetlistRouter {
8082

8183
ConnectionRouter<HeapType> _make_router(const RouterLookahead* router_lookahead, bool is_flat) {
8284
auto& device_ctx = g_vpr_ctx.device();
83-
auto& route_ctx = g_vpr_ctx.mutable_routing();
8485

8586
return ConnectionRouter<HeapType>(
8687
device_ctx.grid,
@@ -89,11 +90,13 @@ class DecompNetlistRouter : public NetlistRouter {
8990
&device_ctx.rr_graph,
9091
device_ctx.rr_rc_data,
9192
device_ctx.rr_graph.rr_switch(),
92-
route_ctx.rr_node_route_inf,
93+
_rr_node_route_infs_th.local(),
9394
is_flat);
9495
}
9596

9697
/* Context fields. Most of them will be forwarded to route_net (see route_net.tpp) */
98+
/** Per-thread storage for rr_node_route_infs (we need them to route 1 net with several threads) */
99+
tbb::enumerable_thread_specific<vtr::vector<RRNodeId, t_rr_node_route_inf>> _rr_node_route_infs_th;
97100
/** Per-thread storage for ConnectionRouters. */
98101
tbb::enumerable_thread_specific<ConnectionRouter<HeapType>> _routers_th;
99102
const Netlist<>& _net_list;

‎vpr/src/route/DecompNetlistRouter.tpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ inline RouteIterResults DecompNetlistRouter<HeapType>::route_netlist(int itry, f
2525
* Nets in a given level of nodes are guaranteed to not have any overlapping bounding boxes, so they can be routed in parallel. */
2626
PartitionTree tree(_net_list);
2727

28+
vtr::Timer t;
29+
2830
/* Put the root node on the task queue, which will add its child nodes when it's finished. Wait until the entire tree gets routed. */
2931
tbb::task_group g;
3032
route_partition_tree_node(g, tree.root());
3133
g.wait();
34+
PartitionTreeDebug::log("Routing all nets took " + std::to_string(t.elapsed_sec()) + " s");
3235

3336
/* Combine results from threads */
3437
RouteIterResults out;
@@ -37,6 +40,7 @@ inline RouteIterResults DecompNetlistRouter<HeapType>::route_netlist(int itry, f
3740
out.rerouted_nets.insert(out.rerouted_nets.end(), results.rerouted_nets.begin(), results.rerouted_nets.end());
3841
out.is_routable &= results.is_routable;
3942
}
43+
4044
return out;
4145
}
4246

@@ -147,7 +151,8 @@ void DecompNetlistRouter<HeapType>::route_partition_tree_node(tbb::task_group& g
147151
_net_list,
148152
_connections_inf,
149153
_router_opts,
150-
_worst_neg_slack);
154+
_worst_neg_slack,
155+
_rr_node_route_infs_th.local());
151156
/* Try decomposing the net. */
152157
if (should_decompose_net(net_id, node)) {
153158
VirtualNet left_vnet, right_vnet;
@@ -177,6 +182,7 @@ void DecompNetlistRouter<HeapType>::route_partition_tree_node(tbb::task_group& g
177182
_worst_neg_slack,
178183
_routing_predictor,
179184
_choking_spots[net_id],
185+
_rr_node_route_infs_th.local(),
180186
_is_flat,
181187
route_ctx.route_bb[net_id],
182188
false);
@@ -225,6 +231,7 @@ void DecompNetlistRouter<HeapType>::route_partition_tree_node(tbb::task_group& g
225231
_worst_neg_slack,
226232
_routing_predictor,
227233
_choking_spots[vnet.net_id],
234+
_rr_node_route_infs_th.local(),
228235
_is_flat,
229236
vnet.clipped_bb,
230237
false,
@@ -301,6 +308,7 @@ bool DecompNetlistRouter<HeapType>::decompose_and_route_net(ParentNetId net_id,
301308
_worst_neg_slack,
302309
_routing_predictor,
303310
_choking_spots[net_id],
311+
_rr_node_route_infs_th.local(),
304312
_is_flat,
305313
net_bb,
306314
false,
@@ -402,6 +410,7 @@ bool DecompNetlistRouter<HeapType>::decompose_and_route_vnet(VirtualNet& vnet, c
402410
_worst_neg_slack,
403411
_routing_predictor,
404412
_choking_spots[vnet.net_id],
413+
_rr_node_route_infs_th.local(),
405414
_is_flat,
406415
vnet.clipped_bb,
407416
false,

‎vpr/src/route/ParallelNetlistRouter.tpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ void ParallelNetlistRouter<HeapType>::route_partition_tree_node(tbb::task_group&
6565
_worst_neg_slack,
6666
_routing_predictor,
6767
_choking_spots[net_id],
68+
route_ctx.rr_node_route_inf,
6869
_is_flat,
6970
route_ctx.route_bb[net_id]);
7071

‎vpr/src/route/SerialNetlistRouter.tpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ inline RouteIterResults SerialNetlistRouter<HeapType>::route_netlist(int itry, f
3535
worst_neg_slack,
3636
_routing_predictor,
3737
_choking_spots[net_id],
38+
route_ctx.rr_node_route_inf,
3839
_is_flat,
3940
route_ctx.route_bb[net_id]);
4041

‎vpr/src/route/check_route.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ void recompute_occupancy_from_scratch(const Netlist<>& net_list, bool is_flat) {
480480

481481
/* First set the occupancy of everything to zero. */
482482
for (RRNodeId inode : device_ctx.rr_graph.nodes())
483-
route_ctx.rr_node_route_inf[inode].set_occ(0);
483+
route_ctx.rr_node_occ_inf[inode].set_occ(0);
484484

485485
/* Now go through each net and count the tracks and pins used everywhere */
486486

@@ -493,7 +493,7 @@ void recompute_occupancy_from_scratch(const Netlist<>& net_list, bool is_flat) {
493493

494494
for (auto& rt_node : route_ctx.route_trees[net_id].value().all_nodes()) {
495495
RRNodeId inode = rt_node.inode;
496-
route_ctx.rr_node_route_inf[inode].set_occ(route_ctx.rr_node_route_inf[inode].occ() + 1);
496+
route_ctx.rr_node_occ_inf[inode].set_occ(route_ctx.rr_node_occ_inf[inode].occ() + 1);
497497
}
498498
}
499499

@@ -510,7 +510,7 @@ void recompute_occupancy_from_scratch(const Netlist<>& net_list, bool is_flat) {
510510
for (int ipin = 0; ipin < num_local_opins; ipin++) {
511511
RRNodeId inode = route_ctx.clb_opins_used_locally[cluster_blk_id][iclass][ipin];
512512
VTR_ASSERT(inode && size_t(inode) < device_ctx.rr_graph.num_nodes());
513-
route_ctx.rr_node_route_inf[inode].set_occ(route_ctx.rr_node_route_inf[inode].occ() + 1);
513+
route_ctx.rr_node_occ_inf[inode].set_occ(route_ctx.rr_node_occ_inf[inode].occ() + 1);
514514
}
515515
}
516516
}

‎vpr/src/route/connection_router.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -900,10 +900,6 @@ void ConnectionRouter<Heap>::add_route_tree_node_to_heap(
900900
float backward_path_cost = cost_params.criticality * rt_node.Tdel;
901901
float R_upstream = rt_node.R_upstream;
902902

903-
/* Don't push to heap if not in bounding box: no-op for serial router, important for parallel router */
904-
if (!inside_bb(rt_node.inode, net_bb))
905-
return;
906-
907903
// after budgets are loaded, calculate delay cost as described by RCV paper
908904
/* R. Fung, V. Betz and W. Chow, "Slack Allocation and Routing to Improve FPGA Timing While
909905
* Repairing Short-Path Violations," in IEEE Transactions on Computer-Aided Design of
@@ -1021,11 +1017,6 @@ t_bb ConnectionRouter<Heap>::add_high_fanout_route_tree_to_heap(
10211017
continue;
10221018
}
10231019

1024-
/* In case of the parallel router, we may be dealing with a virtual net
1025-
* so prune the nodes from the HF lookup against the bounding box just in case */
1026-
if (!inside_bb(rr_node_to_add, net_bounding_box))
1027-
continue;
1028-
10291020
if (!has_path_to_sink(rr_nodes_, rr_graph_, RRNodeId(rt_node.inode), target_node, only_opin_inter_layer)) {
10301021
continue;
10311022
}
@@ -1035,14 +1026,18 @@ t_bb ConnectionRouter<Heap>::add_high_fanout_route_tree_to_heap(
10351026
// Expand HF BB to include the node (clip by original BB)
10361027
expand_highfanout_bounding_box(highfanout_bb, net_bounding_box, rr_node_to_add, rr_graph_);
10371028

1038-
if (is_flat_) {
1039-
if (rr_graph_->node_type(rr_node_to_add) == CHANY || rr_graph_->node_type(rr_node_to_add) == CHANX) {
1029+
/* In case of the parallel router, we may be dealing with a virtual net.
1030+
* Still push nodes outside the BB to the heap, but don't count them towards nodes_added */
1031+
if(inside_bb(rr_node_to_add, net_bounding_box)){
1032+
if (is_flat_) {
1033+
if (rr_graph_->node_type(rr_node_to_add) == CHANY || rr_graph_->node_type(rr_node_to_add) == CHANX) {
1034+
chan_nodes_added++;
1035+
}
1036+
} else {
10401037
chan_nodes_added++;
10411038
}
1042-
} else {
1043-
chan_nodes_added++;
1039+
nodes_added++;
10441040
}
1045-
nodes_added++;
10461041
}
10471042

10481043
constexpr int SINGLE_BIN_MIN_NODES = 2;

‎vpr/src/route/connection_router.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ class ConnectionRouter : public ConnectionRouterInterface {
5656
modified_rr_node_inf_.clear();
5757
}
5858

59-
// Reset modified data in rr_node_route_inf based on modified_rr_node_inf.
59+
/** Reset modified data in rr_node_route_inf based on modified_rr_node_inf_ */
6060
void reset_path_costs() final {
61-
::reset_path_costs(modified_rr_node_inf_);
61+
for (auto node : modified_rr_node_inf_) {
62+
rr_node_route_inf_[node].path_cost = std::numeric_limits<float>::infinity();
63+
rr_node_route_inf_[node].backward_path_cost = std::numeric_limits<float>::infinity();
64+
rr_node_route_inf_[node].prev_node = RRNodeId::INVALID();
65+
rr_node_route_inf_[node].prev_edge = RREdgeId::INVALID();
66+
}
6267
}
6368

6469
/** Finds a path from the route tree rooted at rt_root to sink_node.

‎vpr/src/route/overuse_report.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void log_overused_nodes_status(int max_logged_overused_rr_nodes) {
5353
//Print overuse info body
5454
int overuse_index = 0;
5555
for (RRNodeId inode : rr_graph.nodes()) {
56-
int overuse = route_ctx.rr_node_route_inf[inode].occ() - rr_graph.node_capacity(inode);
56+
int overuse = route_ctx.rr_node_occ_inf[inode].occ() - rr_graph.node_capacity(inode);
5757

5858
if (overuse > 0) {
5959
log_single_overused_node_status(overuse_index, inode);
@@ -103,7 +103,7 @@ void report_overused_nodes(const Netlist<>& net_list,
103103
/* Report basic rr node info */
104104
os << "Overused RR node #" << inode << '\n';
105105
os << "Node id = " << size_t(node_id) << '\n';
106-
os << "Occupancy = " << route_ctx.rr_node_route_inf[node_id].occ() << '\n';
106+
os << "Occupancy = " << route_ctx.rr_node_occ_inf[node_id].occ() << '\n';
107107
os << "Capacity = " << rr_graph.node_capacity(node_id) << "\n\n";
108108

109109
/* Report selective info based on the rr node type */
@@ -179,7 +179,7 @@ void generate_overused_nodes_to_congested_net_lookup(const Netlist<>& net_list,
179179

180180
for (auto& rt_node : route_ctx.route_trees[net_id].value().all_nodes()) {
181181
RRNodeId inode = rt_node.inode;
182-
int overuse = route_ctx.rr_node_route_inf[inode].occ() - rr_graph.node_capacity(inode);
182+
int overuse = route_ctx.rr_node_occ_inf[inode].occ() - rr_graph.node_capacity(inode);
183183
if (overuse > 0) {
184184
nodes_to_nets_lookup[inode].insert(net_id);
185185
}
@@ -394,7 +394,7 @@ static void log_single_overused_node_status(int overuse_index, RRNodeId node_id)
394394
VTR_LOG(" %7d", size_t(node_id));
395395

396396
//Occupancy
397-
VTR_LOG(" %10d", route_ctx.rr_node_route_inf[node_id].occ());
397+
VTR_LOG(" %10d", route_ctx.rr_node_occ_inf[node_id].occ());
398398

399399
//Capacity
400400
VTR_LOG(" %9d", rr_graph.node_capacity(node_id));

‎vpr/src/route/route.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ bool route(const Netlist<>& net_list,
309309
float iter_cumm_time = iteration_timer.elapsed_sec();
310310
float iter_elapsed_time = iter_cumm_time - prev_iter_cumm_time;
311311

312+
PartitionTreeDebug::log("Iteration " + std::to_string(itry) + " took " + std::to_string(iter_elapsed_time) + " s");
313+
312314
//Output progress
313315
print_route_status(itry, iter_elapsed_time, pres_fac, num_net_bounding_boxes_updated, iter_results.stats, overuse_info, wirelength_info, timing_info, est_success_iteration);
314316

0 commit comments

Comments
 (0)
Please sign in to comment.