Skip to content

Commit 911e6b8

Browse files
authored
Merge pull request #2512 from AlexandreSinger/feature_remove_prev_node
[Route][Heap] Removed prev_node From t_heap
2 parents 2233544 + e28a410 commit 911e6b8

File tree

5 files changed

+15
-35
lines changed

5 files changed

+15
-35
lines changed

vpr/src/route/connection_router.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ void ConnectionRouter<Heap>::timing_driven_expand_cheapest(t_heap* cheapest,
374374
VTR_LOGV_DEBUG(router_debug_, " New back cost: %g\n", new_back_cost);
375375
VTR_LOGV_DEBUG(router_debug_, " Setting path costs for associated node %d (from %d edge %zu)\n",
376376
cheapest->index,
377-
cheapest->prev_node(),
378-
size_t(cheapest->prev_edge()));
377+
static_cast<size_t>(rr_graph_->edge_src_node(cheapest->prev_edge())),
378+
static_cast<size_t>(cheapest->prev_edge()));
379379

380380
update_cheapest(cheapest, route_inf);
381381

@@ -601,7 +601,6 @@ void ConnectionRouter<Heap>::timing_driven_add_to_heap(const t_conn_cost_params&
601601
next_ptr->backward_path_cost = next.backward_path_cost;
602602
next_ptr->index = to_node;
603603
next_ptr->set_prev_edge(from_edge);
604-
next_ptr->set_prev_node(from_node);
605604

606605
if (rcv_path_manager.is_enabled() && current->path_data) {
607606
next_ptr->path_data->path_rr = current->path_data->path_rr;
@@ -924,7 +923,7 @@ void ConnectionRouter<Heap>::add_route_tree_node_to_heap(
924923
describe_rr_node(device_ctx.rr_graph, device_ctx.grid, device_ctx.rr_indexed_data, inode, is_flat_).c_str());
925924

926925
push_back_node(&heap_, rr_node_route_inf_,
927-
inode, tot_cost, RRNodeId::INVALID(), RREdgeId::INVALID(),
926+
inode, tot_cost, RREdgeId::INVALID(),
928927
backward_path_cost, R_upstream);
929928
} else {
930929
float expected_total_cost = compute_node_cost_using_rcv(cost_params, inode, target_node, rt_node.Tdel, 0, R_upstream);
@@ -1191,4 +1190,4 @@ std::unique_ptr<ConnectionRouterInterface> make_connection_router(e_heap_type he
11911190
VPR_FATAL_ERROR(VPR_ERROR_ROUTE, "Unknown heap_type %d",
11921191
heap_type);
11931192
}
1194-
}
1193+
}

vpr/src/route/heap_type.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ HeapStorage::alloc() {
2929
temp_ptr->R_upstream = 0.;
3030
temp_ptr->index = RRNodeId::INVALID();
3131
temp_ptr->path_data = nullptr;
32-
temp_ptr->set_prev_node(RRNodeId::INVALID());
3332
temp_ptr->set_prev_edge(RREdgeId::INVALID());
3433
return (temp_ptr);
3534
}

vpr/src/route/heap_type.h

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,6 @@ struct t_heap {
4545
// Managed by PathManager class
4646
t_heap_path* path_data;
4747

48-
/** Previous node and edge IDs. These are not StrongIds for performance & brevity
49-
* reasons: StrongIds can't be trivially placed into an anonymous union (see below) */
50-
struct t_prev {
51-
uint32_t node;
52-
uint32_t edge;
53-
static_assert(sizeof(uint32_t) == sizeof(RRNodeId));
54-
static_assert(sizeof(uint32_t) == sizeof(RREdgeId));
55-
};
56-
5748
t_heap* next_heap_item() const {
5849
return u.next;
5950
}
@@ -62,30 +53,25 @@ struct t_heap {
6253
u.next = next;
6354
}
6455

65-
/** Get prev_node.
66-
* Be careful: will return 0 (a valid id!) if uninitialized. */
67-
constexpr RRNodeId prev_node() const {
68-
return RRNodeId(u.prev.node);
69-
}
70-
71-
inline void set_prev_node(RRNodeId node) {
72-
u.prev.node = size_t(node);
73-
}
74-
7556
/** Get prev_edge.
7657
* Be careful: will return 0 (a valid id!) if uninitialized. */
7758
constexpr RREdgeId prev_edge() const {
78-
return RREdgeId(u.prev.edge);
59+
static_assert(sizeof(uint32_t) == sizeof(RREdgeId));
60+
return RREdgeId(u.prev_edge);
7961
}
8062

8163
inline void set_prev_edge(RREdgeId edge) {
82-
u.prev.edge = size_t(edge);
64+
static_assert(sizeof(uint32_t) == sizeof(RREdgeId));
65+
u.prev_edge = size_t(edge);
8366
}
8467

8568
private:
8669
union {
8770
t_heap* next = nullptr;
88-
t_prev prev;
71+
// The previous edge is not a StrongId for performance & brevity
72+
// reasons: StrongIds can't be trivially placed into an anonymous
73+
// union.
74+
uint32_t prev_edge;
8975
} u;
9076
};
9177

vpr/src/route/route_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ void reserve_locally_used_opins(HeapInterface* heap, float pres_fac, float acc_f
810810
//Add the OPIN to the heap according to it's congestion cost
811811
cost = get_rr_cong_cost(to_node, pres_fac);
812812
add_node_to_heap(heap, route_ctx.rr_node_route_inf,
813-
to_node, cost, RRNodeId::INVALID(), RREdgeId::INVALID(),
813+
to_node, cost, RREdgeId::INVALID(),
814814
0., 0.);
815815
}
816816

vpr/src/route/route_common.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ t_heap* prepare_to_add_node_to_heap(
159159
const RouteInf& rr_node_route_inf,
160160
RRNodeId inode,
161161
float total_cost,
162-
RRNodeId prev_node,
163162
RREdgeId prev_edge,
164163
float backward_path_cost,
165164
float R_upstream) {
@@ -170,7 +169,6 @@ t_heap* prepare_to_add_node_to_heap(
170169

171170
hptr->index = inode;
172171
hptr->cost = total_cost;
173-
hptr->set_prev_node(prev_node);
174172
hptr->set_prev_edge(prev_edge);
175173
hptr->backward_path_cost = backward_path_cost;
176174
hptr->R_upstream = R_upstream;
@@ -184,13 +182,12 @@ void add_node_to_heap(
184182
const RouteInf& rr_node_route_inf,
185183
RRNodeId inode,
186184
float total_cost,
187-
RRNodeId prev_node,
188185
RREdgeId prev_edge,
189186
float backward_path_cost,
190187
float R_upstream) {
191188
t_heap* hptr = prepare_to_add_node_to_heap(
192189
heap,
193-
rr_node_route_inf, inode, total_cost, prev_node,
190+
rr_node_route_inf, inode, total_cost,
194191
prev_edge, backward_path_cost, R_upstream);
195192
if (hptr) {
196193
heap->add_to_heap(hptr);
@@ -206,13 +203,12 @@ void push_back_node(
206203
const RouteInf& rr_node_route_inf,
207204
RRNodeId inode,
208205
float total_cost,
209-
RRNodeId prev_node,
210206
RREdgeId prev_edge,
211207
float backward_path_cost,
212208
float R_upstream) {
213209
t_heap* hptr = prepare_to_add_node_to_heap(
214210
heap,
215-
rr_node_route_inf, inode, total_cost, prev_node, prev_edge,
211+
rr_node_route_inf, inode, total_cost, prev_edge,
216212
backward_path_cost, R_upstream);
217213
if (hptr) {
218214
heap->push_back(hptr);

0 commit comments

Comments
 (0)