Skip to content

Commit f7ec2fd

Browse files
author
Nathan Shreve
committed
Calculate target bb outside of timing_driven_expand_neighbours to avoid repeated calculations
1 parent 9e8db02 commit f7ec2fd

File tree

2 files changed

+36
-29
lines changed

2 files changed

+36
-29
lines changed

vpr/src/route/connection_router.cpp

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,29 @@ t_heap* ConnectionRouter<Heap>::timing_driven_route_connection_from_heap(RRNodeI
196196
const auto& device_ctx = g_vpr_ctx.device();
197197
auto& route_ctx = g_vpr_ctx.mutable_routing();
198198

199+
// Get bounding box for sink node used in timing_driven_expand_neighbour
200+
VTR_ASSERT_SAFE(sink_node != RRNodeId::INVALID());
201+
202+
t_bb target_bb;
203+
if (rr_graph_->node_type(sink_node) == SINK) { // We need to get a bounding box for the sink's entire tile
204+
vtr::Rect<int> tile_bb = grid_.get_tile_bb({rr_graph_->node_xlow(sink_node),
205+
rr_graph_->node_ylow(sink_node),
206+
rr_graph_->node_layer(sink_node)});
207+
208+
target_bb.xmin = tile_bb.xmin();
209+
target_bb.ymin = tile_bb.ymin();
210+
target_bb.xmax = tile_bb.xmax();
211+
target_bb.ymax = tile_bb.ymax();
212+
} else {
213+
target_bb.xmin = rr_graph_->node_xlow(sink_node);
214+
target_bb.ymin = rr_graph_->node_ylow(sink_node);
215+
target_bb.xmax = rr_graph_->node_xhigh(sink_node);
216+
target_bb.ymax = rr_graph_->node_yhigh(sink_node);
217+
}
218+
219+
target_bb.layer_min = rr_graph_->node_layer(RRNodeId(sink_node));
220+
target_bb.layer_max = rr_graph_->node_layer(RRNodeId(sink_node));
221+
199222
t_heap* cheapest = nullptr;
200223
while (!heap_.is_empty_heap()) {
201224
// cheapest t_heap in current route tree to be expanded on
@@ -225,7 +248,8 @@ t_heap* ConnectionRouter<Heap>::timing_driven_route_connection_from_heap(RRNodeI
225248
timing_driven_expand_cheapest(cheapest,
226249
sink_node,
227250
cost_params,
228-
bounding_box);
251+
bounding_box,
252+
target_bb);
229253

230254
rcv_path_manager.free_path_struct(cheapest->path_data);
231255
heap_.free(cheapest);
@@ -308,7 +332,8 @@ vtr::vector<RRNodeId, t_heap> ConnectionRouter<Heap>::timing_driven_find_all_sho
308332
timing_driven_expand_cheapest(cheapest,
309333
target_node,
310334
cost_params,
311-
bounding_box);
335+
bounding_box,
336+
t_bb());
312337

313338
if (cheapest_paths[inode].index == RRNodeId::INVALID() || cheapest_paths[inode].cost >= cheapest->cost) {
314339
VTR_LOGV_DEBUG(router_debug_, " Better cost to node %d: %g (was %g)\n", inode, cheapest->cost, cheapest_paths[inode].cost);
@@ -328,7 +353,8 @@ template<typename Heap>
328353
void ConnectionRouter<Heap>::timing_driven_expand_cheapest(t_heap* cheapest,
329354
RRNodeId target_node,
330355
const t_conn_cost_params& cost_params,
331-
const t_bb& bounding_box) {
356+
const t_bb& bounding_box,
357+
const t_bb& target_bb) {
332358
RRNodeId inode = cheapest->index;
333359

334360
t_rr_node_route_inf* route_inf = &rr_node_route_inf_[inode];
@@ -360,7 +386,7 @@ void ConnectionRouter<Heap>::timing_driven_expand_cheapest(t_heap* cheapest,
360386
update_cheapest(cheapest, route_inf);
361387

362388
timing_driven_expand_neighbours(cheapest, cost_params, bounding_box,
363-
target_node);
389+
target_node, target_bb);
364390
} else {
365391
// Post-heap prune, do not re-explore from the current/new partial path as it
366392
// has worse cost than the best partial path to this node found so far
@@ -376,31 +402,10 @@ template<typename Heap>
376402
void ConnectionRouter<Heap>::timing_driven_expand_neighbours(t_heap* current,
377403
const t_conn_cost_params& cost_params,
378404
const t_bb& bounding_box,
379-
RRNodeId target_node) {
405+
RRNodeId target_node,
406+
const t_bb& target_bb) {
380407
/* Puts all the rr_nodes adjacent to current on the heap. */
381408

382-
t_bb target_bb;
383-
if (target_node != RRNodeId::INVALID()) {
384-
if (rr_graph_->node_type(target_node) == SINK) { // We need to get a bounding box for the sink's entire tile
385-
vtr::Rect<int> tile_bb = grid_.get_tile_bb({rr_graph_->node_xlow(target_node),
386-
rr_graph_->node_ylow(target_node),
387-
rr_graph_->node_layer(target_node)});
388-
389-
target_bb.xmin = tile_bb.xmin();
390-
target_bb.ymin = tile_bb.ymin();
391-
target_bb.xmax = tile_bb.xmax();
392-
target_bb.ymax = tile_bb.ymax();
393-
} else {
394-
target_bb.xmin = rr_graph_->node_xlow(target_node);
395-
target_bb.ymin = rr_graph_->node_ylow(target_node);
396-
target_bb.xmax = rr_graph_->node_xhigh(target_node);
397-
target_bb.ymax = rr_graph_->node_yhigh(target_node);
398-
}
399-
400-
target_bb.layer_min = rr_graph_->node_layer(RRNodeId(target_node));
401-
target_bb.layer_max = rr_graph_->node_layer(RRNodeId(target_node));
402-
}
403-
404409
// For each node associated with the current heap element, expand all of it's neighbors
405410
RRNodeId from_node = current->index;
406411
auto edges = rr_nodes_.edge_range(from_node);

vpr/src/route/connection_router.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,16 @@ class ConnectionRouter : public ConnectionRouterInterface {
184184
t_heap* cheapest,
185185
RRNodeId target_node,
186186
const t_conn_cost_params& cost_params,
187-
const t_bb& bounding_box);
187+
const t_bb& bounding_box,
188+
const t_bb& target_bb);
188189

189190
// Expand each neighbor of the current node.
190191
void timing_driven_expand_neighbours(
191192
t_heap* current,
192193
const t_conn_cost_params& cost_params,
193194
const t_bb& bounding_box,
194-
RRNodeId target_node);
195+
RRNodeId target_node,
196+
const t_bb& target_bb);
195197

196198
// Conditionally adds to_node to the router heap (via path from from_node
197199
// via from_edge).

0 commit comments

Comments
 (0)