10
10
#include " router_stats.h"
11
11
#include " spatial_route_tree_lookup.h"
12
12
13
+ #include " d_ary_heap.h"
14
+
15
+ // `node_t` is a simplified version of `t_heap`, and is used as a bundle of node
16
+ // information in the functions inside the routing loop.
17
+ struct node_t {
18
+ float total_cost;
19
+ float backward_path_cost;
20
+ float R_upstream;
21
+ RREdgeId prev_edge;
22
+ t_heap_path* path_data;
23
+ };
24
+
13
25
// Prune the heap when it contains 4x the number of nodes in the RR graph.
14
- constexpr size_t kHeapPruneFactor = 4 ;
26
+ // constexpr size_t kHeapPruneFactor = 4;
15
27
16
28
// This class encapsolates the timing driven connection router. This class
17
29
// routes from some initial set of sources (via the input rt tree) to a
@@ -46,8 +58,13 @@ class ConnectionRouter : public ConnectionRouterInterface {
46
58
, router_stats_(nullptr )
47
59
, router_debug_(false ) {
48
60
heap_.init_heap (grid);
49
- heap_.set_prune_limit (rr_nodes_.size (), kHeapPruneFactor * rr_nodes_.size ());
61
+ // heap_.set_prune_limit(rr_nodes_.size(), kHeapPruneFactor * rr_nodes_.size());
50
62
only_opin_inter_layer = (grid.get_num_layers () > 1 ) && inter_layer_connections_limited_to_opin (*rr_graph);
63
+ rcv_path_data.resize (rr_node_route_inf.size ());
64
+ }
65
+
66
+ ~ConnectionRouter () {
67
+ VTR_LOG (" Serial Connection Router is being destroyed. Time spent computing SSSP: %.3f seconds\n ." , this ->sssp_total_time .count () / 1000000.0 );
51
68
}
52
69
53
70
// Clear's the modified list. Should be called after reset_path_costs
@@ -58,7 +75,12 @@ class ConnectionRouter : public ConnectionRouterInterface {
58
75
59
76
// Reset modified data in rr_node_route_inf based on modified_rr_node_inf.
60
77
void reset_path_costs () final {
78
+ // Reset the node info stored in rr_node_route_inf variable
61
79
::reset_path_costs (modified_rr_node_inf_);
80
+ // Reset the node info stored inside the connection router
81
+ for (const auto & node : modified_rr_node_inf_) {
82
+ rcv_path_data[node] = nullptr ;
83
+ }
62
84
}
63
85
64
86
/* * Finds a path from the route tree rooted at rt_root to sink_node.
@@ -137,17 +159,17 @@ class ConnectionRouter : public ConnectionRouterInterface {
137
159
}
138
160
139
161
// Update the route path to the node pointed to by cheapest.
140
- inline void update_cheapest (t_heap* cheapest) {
141
- update_cheapest (cheapest, &rr_node_route_inf_[cheapest-> index ]);
162
+ inline void update_cheapest (const node_t & cheapest, RRNodeId inode ) {
163
+ update_cheapest (cheapest, inode, &rr_node_route_inf_[inode ]);
142
164
}
143
165
144
- inline void update_cheapest (t_heap* cheapest, t_rr_node_route_inf* route_inf) {
166
+ inline void update_cheapest (const node_t & cheapest, RRNodeId inode , t_rr_node_route_inf* route_inf) {
145
167
// Record final link to target
146
- add_to_mod_list (cheapest-> index );
168
+ add_to_mod_list (inode );
147
169
148
- route_inf->prev_edge = cheapest-> prev_edge () ;
149
- route_inf->path_cost = cheapest-> cost ;
150
- route_inf->backward_path_cost = cheapest-> backward_path_cost ;
170
+ route_inf->prev_edge = cheapest. prev_edge ;
171
+ route_inf->path_cost = cheapest. total_cost ;
172
+ route_inf->backward_path_cost = cheapest. backward_path_cost ;
151
173
}
152
174
153
175
/* * Common logic from timing_driven_route_connection_from_route_tree and
@@ -159,7 +181,7 @@ class ConnectionRouter : public ConnectionRouterInterface {
159
181
* @param[in] bounding_box Keep search confined to this bounding box
160
182
* @return bool Signal to retry this connection with a full-device bounding box,
161
183
* @return t_heap* Heap element describing the path found. */
162
- std::tuple< bool , t_heap*> timing_driven_route_connection_common_setup (
184
+ bool timing_driven_route_connection_common_setup (
163
185
const RouteTreeNode& rt_root,
164
186
RRNodeId sink_node,
165
187
const t_conn_cost_params& cost_params,
@@ -174,24 +196,26 @@ class ConnectionRouter : public ConnectionRouterInterface {
174
196
//
175
197
// Returns either the last element of the path, or nullptr if no path is
176
198
// found
177
- t_heap* timing_driven_route_connection_from_heap (
199
+ void timing_driven_route_connection_from_heap (
178
200
RRNodeId sink_node,
179
201
const t_conn_cost_params& cost_params,
180
202
const t_bb& bounding_box);
181
203
182
204
// Expand this current node if it is a cheaper path.
183
205
void timing_driven_expand_cheapest (
184
- t_heap* cheapest,
206
+ RRNodeId from_node,
207
+ float new_total_cost,
185
208
RRNodeId target_node,
186
209
const t_conn_cost_params& cost_params,
187
210
const t_bb& bounding_box,
188
211
const t_bb& target_bb);
189
212
190
213
// Expand each neighbor of the current node.
191
214
void timing_driven_expand_neighbours (
192
- t_heap* current,
215
+ const node_t & current,
193
216
const t_conn_cost_params& cost_params,
194
217
const t_bb& bounding_box,
218
+ RRNodeId from_node,
195
219
RRNodeId target_node,
196
220
const t_bb& target_bb);
197
221
@@ -201,7 +225,7 @@ class ConnectionRouter : public ConnectionRouterInterface {
201
225
// RR nodes outside bounding box specified in bounding_box are not added
202
226
// to the heap.
203
227
void timing_driven_expand_neighbour (
204
- t_heap* current,
228
+ const node_t & current,
205
229
RRNodeId from_node,
206
230
RREdgeId from_edge,
207
231
RRNodeId to_node,
@@ -214,15 +238,15 @@ class ConnectionRouter : public ConnectionRouterInterface {
214
238
// non-configurable edges
215
239
void timing_driven_add_to_heap (
216
240
const t_conn_cost_params& cost_params,
217
- const t_heap* current,
241
+ const node_t & current,
218
242
RRNodeId from_node,
219
243
RRNodeId to_node,
220
244
RREdgeId from_edge,
221
245
RRNodeId target_node);
222
246
223
247
// Calculates the cost of reaching to_node
224
248
void evaluate_timing_driven_node_costs (
225
- t_heap * to,
249
+ node_t * to,
226
250
const t_conn_cost_params& cost_params,
227
251
RRNodeId from_node,
228
252
RRNodeId to_node,
@@ -234,8 +258,6 @@ class ConnectionRouter : public ConnectionRouterInterface {
234
258
const t_conn_cost_params& cost_params,
235
259
const t_bb& bounding_box);
236
260
237
- void empty_heap_annotating_node_route_inf ();
238
-
239
261
// Adds the route tree rooted at rt_node to the heap, preparing it to be
240
262
// used as branch-points for further routing.
241
263
void add_route_tree_to_heap (const RouteTreeNode& rt_node,
@@ -281,13 +303,17 @@ class ConnectionRouter : public ConnectionRouterInterface {
281
303
std::vector<RRNodeId> modified_rr_node_inf_;
282
304
RouterStats* router_stats_;
283
305
const ConnectionParameters* conn_params_;
284
- HeapImplementation heap_;
306
+ DAryHeap heap_;
285
307
bool router_debug_;
286
308
287
309
bool only_opin_inter_layer;
288
310
311
+ // Timing
312
+ std::chrono::microseconds sssp_total_time{0 };
313
+
289
314
// The path manager for RCV, keeps track of the route tree as a set, also manages the allocation of the heap types
290
315
PathManager rcv_path_manager;
316
+ vtr::vector<RRNodeId, t_heap_path*> rcv_path_data;
291
317
};
292
318
293
319
/* * Construct a connection router that uses the specified heap type.
0 commit comments