@@ -64,7 +64,7 @@ static std::pair<float, int> run_dijkstra(RRNodeId start_node,
64
64
std::vector<util::Search_Path>* paths,
65
65
util::RoutingCosts* routing_costs);
66
66
67
- float ExtendedMapLookahead::get_src_opin_cost (RRNodeId from_node, int delta_x, int delta_y, float criticality_fac ) const {
67
+ std::pair< float , float > ExtendedMapLookahead::get_src_opin_cost (RRNodeId from_node, int delta_x, int delta_y, const t_conn_cost_params& params ) const {
68
68
auto & device_ctx = g_vpr_ctx.device ();
69
69
auto & rr_graph = device_ctx.rr_nodes ;
70
70
@@ -96,12 +96,14 @@ float ExtendedMapLookahead::get_src_opin_cost(RRNodeId from_node, int delta_x, i
96
96
// The cost estimate should still be *extremely* large compared to a typical delay, and
97
97
// so should ensure that the router de-prioritizes exploring this path, but does not
98
98
// forbid the router from trying.
99
- return std::numeric_limits<float >::max () / 1e12 ;
99
+ float max = std::numeric_limits<float >::max () / 1e12 ;
100
+ return std::make_pair (max, max);
100
101
} else {
101
102
// From the current SOURCE/OPIN we look-up the wiretypes which are reachable
102
103
// and then add the estimates from those wire types for the distance of interest.
103
104
// If there are multiple options we use the minimum value.
104
- float expected_cost = std::numeric_limits<float >::infinity ();
105
+ float expected_delay_cost = std::numeric_limits<float >::infinity ();
106
+ float expected_cong_cost = std::numeric_limits<float >::infinity ();
105
107
106
108
for (const auto & kv : this ->src_opin_delays [tile_index][from_ptc]) {
107
109
const util::t_reachable_wire_inf& reachable_wire_inf = kv.second ;
@@ -119,14 +121,15 @@ float ExtendedMapLookahead::get_src_opin_cost(RRNodeId from_node, int delta_x, i
119
121
cost_entry = cost_map_.find_cost (reachable_wire_inf.wire_seg_index , delta_x, delta_y);
120
122
}
121
123
122
- float this_cost = (criticality_fac ) * (reachable_wire_inf.congestion + cost_entry.congestion )
123
- + ( 1 . - criticality_fac ) * (reachable_wire_inf.delay + cost_entry.delay );
124
+ float this_delay_cost = (1 . - params. criticality ) * (reachable_wire_inf.delay + cost_entry.delay );
125
+ float this_cong_cost = (params. criticality ) * (reachable_wire_inf.congestion + cost_entry.congestion );
124
126
125
- expected_cost = std::min (this_cost, expected_cost);
127
+ expected_delay_cost = std::min (expected_delay_cost, this_delay_cost);
128
+ expected_cong_cost = std::min (expected_cong_cost, this_cong_cost);
126
129
}
127
130
128
- VTR_ASSERT (std::isfinite (expected_cost ));
129
- return expected_cost ;
131
+ VTR_ASSERT (std::isfinite (expected_delay_cost) && std::isfinite (expected_cong_cost ));
132
+ return std::make_pair (expected_delay_cost, expected_cong_cost) ;
130
133
}
131
134
132
135
VTR_ASSERT_SAFE_MSG (false ,
@@ -163,13 +166,14 @@ float ExtendedMapLookahead::get_chan_ipin_delays(RRNodeId to_node) const {
163
166
//
164
167
// The from_node can be of one of the following types: CHANX, CHANY, SOURCE, OPIN
165
168
// The to_node is always a SINK
166
- float ExtendedMapLookahead::get_map_cost (RRNodeId from_node,
167
- RRNodeId to_node,
168
- float criticality_fac) const {
169
- if (from_node == to_node) {
170
- return 0 .f ;
169
+ std::pair<float , float > ExtendedMapLookahead::get_expected_delay_and_cong (int inode, int target_node, const t_conn_cost_params& params, float /* R_upstream*/ ) const {
170
+ if (inode == target_node) {
171
+ return std::make_pair (0 ., 0 .);
171
172
}
172
173
174
+ RRNodeId from_node (inode);
175
+ RRNodeId to_node (target_node);
176
+
173
177
auto & device_ctx = g_vpr_ctx.device ();
174
178
auto & rr_graph = device_ctx.rr_nodes ;
175
179
@@ -185,7 +189,9 @@ float ExtendedMapLookahead::get_map_cost(RRNodeId from_node,
185
189
186
190
e_rr_type from_type = rr_graph.node_type (from_node);
187
191
if (from_type == SOURCE || from_type == OPIN) {
188
- return this ->get_src_opin_cost (from_node, dx, dy, criticality_fac);
192
+ return this ->get_src_opin_cost (from_node, dx, dy, params);
193
+ } else if (from_type == IPIN) {
194
+ return std::make_pair (0 ., 0 .);
189
195
}
190
196
191
197
int from_seg_index = cost_map_.node_to_segment (size_t (from_node));
@@ -197,7 +203,8 @@ float ExtendedMapLookahead::get_map_cost(RRNodeId from_node,
197
203
" Not connected %d (%s, %d) -> %d (%s)\n " ,
198
204
size_t (from_node), device_ctx.rr_nodes [size_t (from_node)].type_string (), from_seg_index,
199
205
size_t (to_node), device_ctx.rr_nodes [size_t (to_node)].type_string ());
200
- return std::numeric_limits<float >::infinity ();
206
+ float infinity = std::numeric_limits<float >::infinity ();
207
+ return std::make_pair (infinity, infinity);
201
208
}
202
209
203
210
float expected_delay = cost_entry.delay ;
@@ -216,16 +223,19 @@ float ExtendedMapLookahead::get_map_cost(RRNodeId from_node,
216
223
float site_pin_delay = this ->get_chan_ipin_delays (to_node);
217
224
expected_delay += site_pin_delay;
218
225
219
- float expected_cost = criticality_fac * expected_delay + (1.0 - criticality_fac) * expected_congestion;
226
+ float expected_delay_cost = params.criticality * expected_delay;
227
+ float expected_cong_cost = (1.0 - params.criticality ) * expected_congestion;
228
+
229
+ float expected_cost = expected_delay_cost + expected_cong_cost;
220
230
221
231
VTR_LOGV_DEBUG (f_router_debug, " Requested lookahead from node %d to %d\n " , size_t (from_node), size_t (to_node));
222
232
const std::string& segment_name = device_ctx.rr_segments [from_seg_index].name ;
223
233
VTR_LOGV_DEBUG (f_router_debug, " Lookahead returned %s (%d) with distance (%zd, %zd)\n " ,
224
234
segment_name.c_str (), from_seg_index,
225
235
dx, dy);
226
- VTR_LOGV_DEBUG (f_router_debug, " Lookahead delay: %g\n " , expected_delay );
227
- VTR_LOGV_DEBUG (f_router_debug, " Lookahead congestion: %g\n " , expected_congestion );
228
- VTR_LOGV_DEBUG (f_router_debug, " Criticality: %g\n " , criticality_fac );
236
+ VTR_LOGV_DEBUG (f_router_debug, " Lookahead delay: %g\n " , expected_delay_cost );
237
+ VTR_LOGV_DEBUG (f_router_debug, " Lookahead congestion: %g\n " , expected_cong_cost );
238
+ VTR_LOGV_DEBUG (f_router_debug, " Criticality: %g\n " , params. criticality );
229
239
VTR_LOGV_DEBUG (f_router_debug, " Lookahead cost: %g\n " , expected_cost);
230
240
VTR_LOGV_DEBUG (f_router_debug, " Site pin delay: %g\n " , site_pin_delay);
231
241
@@ -239,7 +249,7 @@ float ExtendedMapLookahead::get_map_cost(RRNodeId from_node,
239
249
VTR_ASSERT (0 );
240
250
}
241
251
242
- return expected_cost ;
252
+ return std::make_pair (expected_delay_cost, expected_cong_cost) ;
243
253
}
244
254
245
255
// Adds a best cost routing path from start_node_ind to node_ind to routing costs
@@ -560,20 +570,23 @@ float ExtendedMapLookahead::get_expected_cost(
560
570
int current_node,
561
571
int target_node,
562
572
const t_conn_cost_params& params,
563
- float /* R_upstream*/ ) const {
573
+ float R_upstream) const {
564
574
auto & device_ctx = g_vpr_ctx.device ();
565
575
566
576
t_rr_type rr_type = device_ctx.rr_nodes [current_node].type ();
567
577
568
578
if (rr_type == CHANX || rr_type == CHANY || rr_type == SOURCE || rr_type == OPIN) {
569
- return get_map_cost (
570
- RRNodeId (current_node), RRNodeId (target_node), params.criticality );
579
+ float delay_cost, cong_cost;
580
+
581
+ // Get the total cost using the combined delay and congestion costs
582
+ std::tie (delay_cost, cong_cost) = get_expected_delay_and_cong (current_node, target_node, params, R_upstream);
583
+ return delay_cost + cong_cost;
571
584
} else if (rr_type == IPIN) { /* Change if you're allowing route-throughs */
572
585
// This is to return only the cost between the IPIN and SINK. No need to
573
586
// query the cost map, as the routing of this connection is almost done.
574
- return ( device_ctx.rr_indexed_data [SINK_COST_INDEX].base_cost ) ;
587
+ return device_ctx.rr_indexed_data [SINK_COST_INDEX].base_cost ;
575
588
} else { /* Change this if you want to investigate route-throughs */
576
- return ( 0 .) ;
589
+ return 0 . ;
577
590
}
578
591
}
579
592
0 commit comments