Skip to content

Commit cbb4551

Browse files
committed
vpr: Rename t_heap::previous -> t_heap::nodes
Also update t_heap comments to clarify data members
1 parent 01a82e7 commit cbb4551

File tree

5 files changed

+45
-35
lines changed

5 files changed

+45
-35
lines changed

vpr/src/route/route_breadth_first.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static bool breadth_first_route_net(ClusterNetId net_id, float bend_cost) {
204204
VTR_LOG(" New best cost %g\n", new_pcost);
205205
#endif
206206

207-
for (t_heap_prev prev : current->previous) {
207+
for (t_heap_prev prev : current->nodes) {
208208
#ifdef ROUTER_DEBUG
209209
VTR_LOG(" Setting routing paths for associated node %d\n", prev.to_node);
210210
#endif
@@ -420,7 +420,7 @@ static void breadth_first_expand_non_configurable_recurr(const float path_cost,
420420
current->cost = std::min(current->cost, new_path_cost);
421421

422422
//Record how we reached this node
423-
current->previous.emplace_back(to_node, from_node, iconn);
423+
current->nodes.emplace_back(to_node, from_node, iconn);
424424

425425
//Consider any non-configurable edges which must be expanded for correctness
426426
auto& device_ctx = g_vpr_ctx.device();

vpr/src/route/route_common.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static int num_linked_f_pointer_allocated = 0;
9797
* */
9898

9999
/******************** Subroutines local to route_common.c *******************/
100-
static t_trace_branch traceback_branch(int node, const std::vector<t_heap_prev>& previous, std::unordered_set<int>& main_branch_visited);
100+
static t_trace_branch traceback_branch(int node, const std::vector<t_heap_prev>& nodes, std::unordered_set<int>& main_branch_visited);
101101
static std::pair<t_trace*,t_trace*> add_trace_non_configurable(t_trace* head, t_trace* tail, int node, std::unordered_set<int>& visited);
102102
static std::pair<t_trace*,t_trace*> add_trace_non_configurable_recurr(int node, std::unordered_set<int>& visited, int depth=0);
103103

@@ -562,7 +562,7 @@ update_traceback(t_heap *hptr, ClusterNetId net_id) {
562562

563563
VTR_ASSERT_SAFE(validate_trace_nodes(route_ctx.trace[net_id].head, trace_nodes));
564564

565-
t_trace_branch branch = traceback_branch(hptr->index, hptr->previous, trace_nodes);
565+
t_trace_branch branch = traceback_branch(hptr->index, hptr->nodes, trace_nodes);
566566

567567
VTR_ASSERT_SAFE(validate_trace_nodes(branch.head, trace_nodes));
568568

@@ -581,7 +581,7 @@ update_traceback(t_heap *hptr, ClusterNetId net_id) {
581581

582582
//Traces back a new routing branch starting from the specified 'node' and working backwards to any existing routing.
583583
//Returns the new branch, and also updates trace_nodes for any new nodes which are included in the branches traceback.
584-
static t_trace_branch traceback_branch(int node, const std::vector<t_heap_prev>& previous, std::unordered_set<int>& trace_nodes) {
584+
static t_trace_branch traceback_branch(int node, const std::vector<t_heap_prev>& nodes, std::unordered_set<int>& trace_nodes) {
585585
auto& device_ctx = g_vpr_ctx.device();
586586
auto& route_ctx = g_vpr_ctx.routing();
587587

@@ -604,7 +604,7 @@ static t_trace_branch traceback_branch(int node, const std::vector<t_heap_prev>&
604604

605605
std::vector<int> new_nodes_added_to_traceback = {node};
606606

607-
for (t_heap_prev prev : previous) {
607+
for (t_heap_prev prev : nodes) {
608608
int inode = prev.from_node;
609609
int iedge = prev.from_edge;
610610

@@ -811,8 +811,8 @@ void node_to_heap(int inode, float total_cost, int prev_node, int prev_edge,
811811
t_heap* hptr = alloc_heap_data();
812812
hptr->index = inode;
813813
hptr->cost = total_cost;
814-
VTR_ASSERT(hptr->previous.empty());
815-
hptr->previous.emplace_back(inode, prev_node, prev_edge);
814+
VTR_ASSERT(hptr->nodes.empty());
815+
hptr->nodes.emplace_back(inode, prev_node, prev_edge);
816816
hptr->backward_path_cost = backward_path_cost;
817817
hptr->R_upstream = R_upstream;
818818
add_to_heap(hptr);
@@ -1290,7 +1290,7 @@ namespace heap_ {
12901290
t_heap* hptr = alloc_heap_data();
12911291
hptr->index = inode;
12921292
hptr->cost = total_cost;
1293-
hptr->previous.emplace_back(inode, prev_node, prev_edge);
1293+
hptr->nodes.emplace_back(inode, prev_node, prev_edge);
12941294
hptr->backward_path_cost = backward_path_cost;
12951295
hptr->R_upstream = R_upstream;
12961296
push_back(hptr);
@@ -1412,7 +1412,7 @@ alloc_heap_data() {
14121412
temp_ptr->backward_path_cost = 0.;
14131413
temp_ptr->R_upstream = 0.;
14141414
temp_ptr->index = OPEN;
1415-
temp_ptr->previous.clear();
1415+
temp_ptr->nodes.clear();
14161416
return (temp_ptr);
14171417
}
14181418

@@ -1430,7 +1430,7 @@ void invalidate_heap_entries(int sink_node, int ipin_node) {
14301430

14311431
for (int i = 1; i < heap_tail; i++) {
14321432
if (heap[i]->index == sink_node) {
1433-
for (t_heap_prev prev : heap[i]->previous) {
1433+
for (t_heap_prev prev : heap[i]->nodes) {
14341434
if (prev.from_node == ipin_node) {
14351435
heap[i]->index = OPEN; /* Invalid. */
14361436
break;

vpr/src/route/route_common.h

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,44 @@ struct t_heap_prev {
1414
};
1515

1616

17-
/* Used by the heap as its fundamental data structure. *
18-
* index: Index (ID) of this routing resource node. *
19-
* cost: Cost up to and including this node. *
20-
* u.prev_node: Index (ID) of the predecessor to this node for *
21-
* use in traceback. NO_PREVIOUS if none. *
22-
* u.next: pointer to the next s_heap structure in the free *
23-
* linked list. Not used when on the heap. *
24-
* prev_edge: Index of the edge (between 0 and num_edges-1) used to *
25-
* connect the previous node to this one. NO_PREVIOUS if *
26-
* there is no previous node. *
27-
* backward_path_cost: Used only by the timing-driven router. The "known" *
28-
* cost of the path up to and including this node. *
29-
* In this case, the .cost member contains not only *
30-
* the known backward cost but also an expected cost *
31-
* to the target. *
32-
* R_upstream: Used only by the timing-driven router. Stores the upstream *
33-
* resistance to ground from this node, including the *
34-
* resistance of the node itself (device_ctx.rr_nodes[index].R).*/
17+
/* Used by the heap as its fundamental data structure.
18+
* Each heap element represents a partial route.
19+
*
20+
* next: pointer to the next s_heap structure in the free
21+
* linked list. Not used when on the heap.
22+
*
23+
* cost: The cost used to sort heap.
24+
* For the timing-driven router this is the backward_path_cost +
25+
* expected cost to the target.
26+
* For the breadth-first router it is the node cost to reach this
27+
* point.
28+
* backward_path_cost: Used only by the timing-driven router. The "known"
29+
* cost of the path up to and including this node.
30+
* In this case, the .cost member contains not only
31+
* the known backward cost but also an expected cost
32+
* to the target.
33+
* R_upstream: Used only by the timing-driven router. Stores the upstream
34+
* resistance to ground from this node, including the
35+
* resistance of the node itself (device_ctx.rr_nodes[index].R).
36+
*
37+
* index: The RR node index associated with the costs/R_upstream values
38+
* nodes: The set of nodes represented by this heap element.
39+
* Usually this contains a single element corresponding to index.
40+
* However in some cases (e.g. non-configurable edges) multiple RR
41+
* nodes may be required to be used together. In such cases each
42+
* node will be inclued in 'nodes' and 'cost', 'backward_path_cost',
43+
* R_upstream will be those associated with the lowest cost node (who's
44+
* index is stored in 'index' for reference).
45+
*/
3546
struct t_heap {
3647
t_heap *next = nullptr;
3748

3849
float cost = 0.;
3950
float backward_path_cost = 0.;
4051
float R_upstream = 0.;
41-
int index = OPEN;
4252

43-
std::vector<t_heap_prev> previous;
53+
int index = OPEN;
54+
std::vector<t_heap_prev> nodes;
4455
};
4556

4657
/******* Subroutines in route_common used only by other router modules ******/

vpr/src/route/route_timing.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ static void timing_driven_expand_cheapest(t_heap* cheapest,
14001400
if (old_total_cost > new_total_cost && old_back_cost > new_back_cost) {
14011401

14021402
VTR_LOGV_DEBUG(f_router_debug, " Better cost to %d\n", inode);
1403-
for (t_heap_prev prev : cheapest->previous) {
1403+
for (t_heap_prev prev : cheapest->nodes) {
14041404
VTR_LOGV_DEBUG(f_router_debug, " Setting path costs for assicated node %d (from %d edge %d)\n", prev.to_node, prev.from_node, prev.from_edge);
14051405

14061406
add_to_mod_list(prev.to_node, modified_rr_node_inf);
@@ -1744,7 +1744,6 @@ static void timing_driven_expand_neighbours(t_heap *current,
17441744

17451745
//For each node associated with the current heap element, expand all of it's neighbours
17461746
for (const t_heap_prev& prev : current->nodes) {
1747-
17481747
int num_edges = device_ctx.rr_nodes[prev.to_node].num_edges();
17491748
for (int iconn = 0; iconn < num_edges; iconn++) {
17501749
int to_node = device_ctx.rr_nodes[prev.to_node].edge_sink_node(iconn);
@@ -1889,7 +1888,7 @@ static void timing_driven_expand_node(const t_conn_cost_params cost_params,
18891888
from_node, to_node, iconn, target_node);
18901889

18911890
//Record how we reached this node
1892-
current->previous.emplace_back(to_node, from_node, iconn);
1891+
current->nodes.emplace_back(to_node, from_node, iconn);
18931892

18941893
//Since this heap element may represent multiple (non-configurably connected) nodes,
18951894
//keep the minimum cost to the target

vpr/src/route/route_tree_timing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ add_subtree_to_route_tree(t_heap *hptr, t_rt_node ** sink_rt_node_ptr) {
305305
downstream_rt_node = sink_rt_node;
306306

307307
std::unordered_set<int> main_branch_visited;
308-
for (t_heap_prev prev : hptr->previous) {
308+
for (t_heap_prev prev : hptr->nodes) {
309309
inode = prev.from_node;
310310
iedge = prev.from_edge;
311311
iswitch = device_ctx.rr_nodes[inode].edge_switch(iedge);

0 commit comments

Comments
 (0)