Skip to content

Commit bc4c175

Browse files
committed
vpr: Clarify heap pre/post pruning
1 parent 7b24eaa commit bc4c175

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

vpr/src/route/route_timing.cpp

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,8 +1594,8 @@ static void timing_driven_expand_cheapest(t_heap* cheapest,
15941594

15951595
int inode = cheapest->index;
15961596

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;
15991599

16001600
float new_total_cost = cheapest->cost;
16011601
float new_back_cost = cheapest->backward_path_cost;
@@ -1608,7 +1608,9 @@ static void timing_driven_expand_cheapest(t_heap* cheapest,
16081608
* than one with higher cost. Test whether or not I should disallow *
16091609
* re-expansion based on a higher total cost. */
16101610

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
16121614
VTR_LOGV_DEBUG(f_router_debug, " Better cost to %d\n", inode);
16131615
VTR_LOGV_DEBUG(f_router_debug, " New total cost: %g\n", new_total_cost);
16141616
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,
16261628
target_node,
16271629
router_stats);
16281630
} 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
16291633
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);
16321636
VTR_LOGV_DEBUG(f_router_debug, " New total cost: %g\n", new_total_cost);
16331637
VTR_LOGV_DEBUG(f_router_debug, " New back cost: %g\n", new_back_cost);
16341638
}
@@ -2081,20 +2085,23 @@ static void timing_driven_add_to_heap(const t_conn_cost_params cost_params,
20812085

20822086
auto& route_ctx = g_vpr_ctx.routing();
20832087

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;
20862090

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;
20892093

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.
20932102
add_to_heap(next);
20942103
++router_stats.heap_pushes;
2095-
}
2096-
2097-
else {
2104+
} else {
20982105
free_heap_data(next);
20992106
}
21002107
}

0 commit comments

Comments
 (0)