@@ -1594,8 +1594,8 @@ static void timing_driven_expand_cheapest(t_heap* cheapest,
1594
1594
1595
1595
int inode = cheapest->index ;
1596
1596
1597
- float old_total_cost = route_ctx.rr_node_route_inf [inode].path_cost ;
1598
- float old_back_cost = route_ctx.rr_node_route_inf [inode].backward_path_cost ;
1597
+ float best_total_cost = route_ctx.rr_node_route_inf [inode].path_cost ;
1598
+ float best_back_cost = route_ctx.rr_node_route_inf [inode].backward_path_cost ;
1599
1599
1600
1600
float new_total_cost = cheapest->cost ;
1601
1601
float new_back_cost = cheapest->backward_path_cost ;
@@ -1608,7 +1608,9 @@ static void timing_driven_expand_cheapest(t_heap* cheapest,
1608
1608
* than one with higher cost. Test whether or not I should disallow *
1609
1609
* re-expansion based on a higher total cost. */
1610
1610
1611
- if (old_total_cost > new_total_cost && old_back_cost > new_back_cost) {
1611
+ if (best_total_cost > new_total_cost && best_back_cost > new_back_cost) {
1612
+ // Explore from this node, since the current/new partial path has the best cost
1613
+ // found so far
1612
1614
VTR_LOGV_DEBUG (f_router_debug, " Better cost to %d\n " , inode);
1613
1615
VTR_LOGV_DEBUG (f_router_debug, " New total cost: %g\n " , new_total_cost);
1614
1616
VTR_LOGV_DEBUG (f_router_debug, " New back cost: %g\n " , new_back_cost);
@@ -1626,9 +1628,11 @@ static void timing_driven_expand_cheapest(t_heap* cheapest,
1626
1628
target_node,
1627
1629
router_stats);
1628
1630
} else {
1631
+ // Post-heap prune, do not re-explore from the current/new partial path as it
1632
+ // has worse cost than the best partial path to this node found so far
1629
1633
VTR_LOGV_DEBUG (f_router_debug, " Worse cost to %d\n " , inode);
1630
- VTR_LOGV_DEBUG (f_router_debug, " Old total cost: %g\n " , old_total_cost );
1631
- VTR_LOGV_DEBUG (f_router_debug, " Old back cost: %g\n " , old_back_cost );
1634
+ VTR_LOGV_DEBUG (f_router_debug, " Old total cost: %g\n " , best_total_cost );
1635
+ VTR_LOGV_DEBUG (f_router_debug, " Old back cost: %g\n " , best_back_cost );
1632
1636
VTR_LOGV_DEBUG (f_router_debug, " New total cost: %g\n " , new_total_cost);
1633
1637
VTR_LOGV_DEBUG (f_router_debug, " New back cost: %g\n " , new_back_cost);
1634
1638
}
@@ -2081,20 +2085,23 @@ static void timing_driven_add_to_heap(const t_conn_cost_params cost_params,
2081
2085
2082
2086
auto & route_ctx = g_vpr_ctx.routing ();
2083
2087
2084
- float old_next_total_cost = route_ctx.rr_node_route_inf [to_node].path_cost ;
2085
- float old_next_back_cost = route_ctx.rr_node_route_inf [to_node].backward_path_cost ;
2088
+ float best_total_cost = route_ctx.rr_node_route_inf [to_node].path_cost ;
2089
+ float best_back_cost = route_ctx.rr_node_route_inf [to_node].backward_path_cost ;
2086
2090
2087
- float new_next_total_cost = next->cost ;
2088
- float new_next_back_cost = next->backward_path_cost ;
2091
+ float new_total_cost = next->cost ;
2092
+ float new_back_cost = next->backward_path_cost ;
2089
2093
2090
- if (old_next_total_cost > new_next_total_cost && old_next_back_cost > new_next_back_cost) {
2091
- // Add node to the heap only if the current cost is less than its historic cost, since
2092
- // there is no point in for the router to expand more expensive paths.
2094
+ VTR_ASSERT_SAFE (next->index == to_node);
2095
+
2096
+ if (new_total_cost < best_total_cost && new_back_cost < best_back_cost) {
2097
+ // Add node to the heap only if the cost via the current partial path is less than the
2098
+ // best known cost, since there is no reason for the router to expand more expensive paths.
2099
+ //
2100
+ // Pre-heap prune to keep the heap small, by not putting paths which are known to be
2101
+ // sub-optimal (at this point in time) into the heap.
2093
2102
add_to_heap (next);
2094
2103
++router_stats.heap_pushes ;
2095
- }
2096
-
2097
- else {
2104
+ } else {
2098
2105
free_heap_data (next);
2099
2106
}
2100
2107
}
0 commit comments