3
3
/* * @file Impls for DecompNetlistRouter */
4
4
5
5
#include " DecompNetlistRouter.h"
6
+ #include " globals.h"
6
7
#include " netlist_routers.h"
7
8
#include " route_net.h"
8
9
#include " sink_sampling.h"
@@ -21,15 +22,21 @@ inline RouteIterResults DecompNetlistRouter<HeapType>::route_netlist(int itry, f
21
22
_pres_fac = pres_fac;
22
23
_worst_neg_slack = worst_neg_slack;
23
24
25
+ vtr::Timer t;
26
+
24
27
/* Organize netlist into a PartitionTree.
25
28
* Nets in a given level of nodes are guaranteed to not have any overlapping bounding boxes, so they can be routed in parallel. */
26
- PartitionTree tree (_net_list);
29
+ if (!_tree){
30
+ _tree = PartitionTree (_net_list);
31
+ PartitionTreeDebug::log (" Iteration " + std::to_string (itry) + " : built partition tree in " + std::to_string (t.elapsed_sec ()) + " s" );
32
+ }
27
33
28
- vtr::Timer t;
34
+ /* Remove all virtual nets: we will create them for each iteration */
35
+ _tree->clear_vnets ();
29
36
30
37
/* 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. */
31
38
tbb::task_group g;
32
- route_partition_tree_node (g, tree. root ());
39
+ route_partition_tree_node (g, _tree-> root ());
33
40
g.wait ();
34
41
PartitionTreeDebug::log (" Routing all nets took " + std::to_string (t.elapsed_sec ()) + " s" );
35
42
@@ -38,12 +45,20 @@ inline RouteIterResults DecompNetlistRouter<HeapType>::route_netlist(int itry, f
38
45
for (auto & results : _results_th) {
39
46
out.stats .combine (results.stats );
40
47
out.rerouted_nets .insert (out.rerouted_nets .end (), results.rerouted_nets .begin (), results.rerouted_nets .end ());
48
+ out.bb_updated_nets .insert (out.bb_updated_nets .end (), results.bb_updated_nets .begin (), results.bb_updated_nets .end ());
41
49
out.is_routable &= results.is_routable ;
42
50
}
43
51
44
52
return out;
45
53
}
46
54
55
+ /* TODO: Handle this in route_netlist */
56
+ template <typename HeapType>
57
+ void DecompNetlistRouter<HeapType>::handle_bb_updated_nets(const std::vector<ParentNetId>& nets) {
58
+ VTR_ASSERT (_tree);
59
+ _tree->update_nets (nets);
60
+ }
61
+
47
62
template <typename HeapType>
48
63
void DecompNetlistRouter<HeapType>::set_rcv_enabled(bool x) {
49
64
if (x)
@@ -124,6 +139,9 @@ inline bool should_decompose_vnet(const VirtualNet& vnet, const PartitionTreeNod
124
139
template <typename HeapType>
125
140
void DecompNetlistRouter<HeapType>::route_partition_tree_node(tbb::task_group& g, PartitionTreeNode& node) {
126
141
auto & route_ctx = g_vpr_ctx.mutable_routing ();
142
+ vtr::Timer t;
143
+
144
+ std::vector<ParentNetId> nets (node.nets .begin (), node.nets .end ());
127
145
128
146
/* Sort so that nets with the most sinks are routed first.
129
147
* We want to interleave virtual nets with regular ones, so sort an "index vector"
@@ -133,15 +151,14 @@ void DecompNetlistRouter<HeapType>::route_partition_tree_node(tbb::task_group& g
133
151
std::vector<size_t > order (node.nets .size () + node.vnets .size ());
134
152
std::iota (order.begin (), order.end (), 0 );
135
153
std::sort (order.begin (), order.end (), [&](size_t i, size_t j) -> bool {
136
- ParentNetId id1 = i < node.nets .size () ? node. nets [i] : node.vnets [i - node. nets .size ()].net_id ;
137
- ParentNetId id2 = j < node.nets .size () ? node. nets [j] : node.vnets [j - node. nets .size ()].net_id ;
154
+ ParentNetId id1 = i < node.nets .size () ? nets[i] : node.vnets [i - nets.size ()].net_id ;
155
+ ParentNetId id2 = j < node.nets .size () ? nets[j] : node.vnets [j - nets.size ()].net_id ;
138
156
return _net_list.net_sinks (id1).size () > _net_list.net_sinks (id2).size ();
139
157
});
140
158
141
- vtr::Timer t;
142
159
for (size_t i : order) {
143
- if (i < node. nets .size ()) { /* Regular net (not decomposed) */
144
- ParentNetId net_id = node. nets [i];
160
+ if (i < nets.size ()) { /* Regular net (not decomposed) */
161
+ ParentNetId net_id = nets[i];
145
162
if (!should_route_net (_net_list, net_id, _connections_inf, _budgeting_inf, _worst_neg_slack, true ))
146
163
continue ;
147
164
/* Setup the net (reset or prune) only once here in the flow. Then all calls to route_net turn off auto-setup */
@@ -194,6 +211,7 @@ void DecompNetlistRouter<HeapType>::route_partition_tree_node(tbb::task_group& g
194
211
if (flags.retry_with_full_bb ) {
195
212
/* ConnectionRouter thinks we should grow the BB. Do that and leave this net unrouted for now */
196
213
route_ctx.route_bb [net_id] = full_device_bb ();
214
+ _results_th.local ().bb_updated_nets .push_back (net_id);
197
215
/* Disable decomposition for nets like this: they're already problematic */
198
216
_is_decomp_disabled[net_id] = true ;
199
217
continue ;
@@ -212,7 +230,7 @@ void DecompNetlistRouter<HeapType>::route_partition_tree_node(tbb::task_group& g
212
230
continue ;
213
231
}
214
232
}
215
- /* Route the full vnet. Again we don't care about the flags, they should be handled by the regular path */
233
+ /* Route the full vnet. We don't care about the flags, they should be handled by the regular path */
216
234
auto sink_mask = get_vnet_sink_mask (vnet);
217
235
route_net (
218
236
_routers_th.local (),
@@ -284,7 +302,7 @@ inline void make_vnet_pair(ParentNetId net_id, const t_bb& bb, Axis cutline_axis
284
302
285
303
template <typename HeapType>
286
304
bool DecompNetlistRouter<HeapType>::decompose_and_route_net(ParentNetId net_id, const PartitionTreeNode& node, VirtualNet& left, VirtualNet& right) {
287
- auto & route_ctx = g_vpr_ctx.routing ();
305
+ auto & route_ctx = g_vpr_ctx.mutable_routing ();
288
306
auto & net_bb = route_ctx.route_bb [net_id];
289
307
290
308
/* Sample enough sinks to provide branch-off points to the virtual nets we create */
@@ -508,6 +526,7 @@ inline bool get_reduction_mask(ParentNetId net_id, Axis cutline_axis, int cutlin
508
526
template <typename HeapType>
509
527
vtr::dynamic_bitset<> DecompNetlistRouter<HeapType>::get_decomposition_mask(ParentNetId net_id, const PartitionTreeNode& node) {
510
528
const auto & route_ctx = g_vpr_ctx.routing ();
529
+
511
530
const RouteTree& tree = route_ctx.route_trees [net_id].value ();
512
531
size_t num_sinks = tree.num_sinks ();
513
532
@@ -521,6 +540,7 @@ vtr::dynamic_bitset<> DecompNetlistRouter<HeapType>::get_decomposition_mask(Pare
521
540
bool is_reduced = get_reduction_mask (net_id, node.cutline_axis , node.cutline_pos , out);
522
541
523
542
bool source_on_cutline = is_close_to_cutline (tree.root ().inode , node.cutline_axis , node.cutline_pos , 1 );
543
+
524
544
if (!is_reduced || source_on_cutline)
525
545
convex_hull_downsample (net_id, route_ctx.route_bb [net_id], out);
526
546
0 commit comments