Skip to content

Commit 7c63199

Browse files
committed
clip HF BB by original BB
1 parent ff4a9e9 commit 7c63199

16 files changed

+171
-167
lines changed

vpr/src/route/connection_router.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -964,16 +964,21 @@ void ConnectionRouter<Heap>::add_route_tree_node_to_heap(
964964
}
965965
}
966966

967-
static t_bb adjust_highfanout_bounding_box(t_bb highfanout_bb) {
968-
t_bb bb = highfanout_bb;
967+
/* Expand bb by inode's extents and clip against net_bb */
968+
inline void expand_highfanout_bounding_box(t_bb& bb, const t_bb& net_bb, RRNodeId inode, const RRGraphView* rr_graph) {
969+
bb.xmin = std::max<int>(net_bb.xmin, std::min<int>(bb.xmin, rr_graph->node_xlow(inode)));
970+
bb.ymin = std::max<int>(net_bb.ymin, std::min<int>(bb.ymin, rr_graph->node_ylow(inode)));
971+
bb.xmax = std::min<int>(net_bb.xmax, std::max<int>(bb.xmax, rr_graph->node_xhigh(inode)));
972+
bb.ymax = std::min<int>(net_bb.ymax, std::max<int>(bb.ymax, rr_graph->node_yhigh(inode)));
973+
}
969974

975+
/* Expand bb by HIGH_FANOUT_BB_FAC and clip against net_bb */
976+
inline void adjust_highfanout_bounding_box(t_bb& bb, const t_bb& net_bb) {
970977
constexpr int HIGH_FANOUT_BB_FAC = 3;
971-
bb.xmin -= HIGH_FANOUT_BB_FAC;
972-
bb.ymin -= HIGH_FANOUT_BB_FAC;
973-
bb.xmax += HIGH_FANOUT_BB_FAC;
974-
bb.ymax += HIGH_FANOUT_BB_FAC;
975-
976-
return bb;
978+
bb.xmin = std::max<int>(net_bb.xmin, bb.xmin - HIGH_FANOUT_BB_FAC);
979+
bb.ymin = std::max<int>(net_bb.ymin, bb.ymin - HIGH_FANOUT_BB_FAC);
980+
bb.xmax = std::min<int>(net_bb.xmax, bb.xmax + HIGH_FANOUT_BB_FAC);
981+
bb.ymax = std::min<int>(net_bb.ymax, bb.ymax + HIGH_FANOUT_BB_FAC);
977982
}
978983

979984
template<typename Heap>
@@ -1032,11 +1037,8 @@ t_bb ConnectionRouter<Heap>::add_high_fanout_route_tree_to_heap(
10321037
// Put the node onto the heap
10331038
add_route_tree_node_to_heap(rt_node, target_node, cost_params, true);
10341039

1035-
// Update Bounding Box
1036-
highfanout_bb.xmin = std::min<int>(highfanout_bb.xmin, rr_graph_->node_xlow(rr_node_to_add));
1037-
highfanout_bb.ymin = std::min<int>(highfanout_bb.ymin, rr_graph_->node_ylow(rr_node_to_add));
1038-
highfanout_bb.xmax = std::max<int>(highfanout_bb.xmax, rr_graph_->node_xhigh(rr_node_to_add));
1039-
highfanout_bb.ymax = std::max<int>(highfanout_bb.ymax, rr_graph_->node_yhigh(rr_node_to_add));
1040+
// Expand HF BB to include the node (clip by original BB)
1041+
expand_highfanout_bounding_box(highfanout_bb, net_bounding_box, rr_node_to_add, rr_graph_);
10401042
if (is_flat_) {
10411043
if (rr_graph_->node_type(rr_node_to_add) == CHANY || rr_graph_->node_type(rr_node_to_add) == CHANX) {
10421044
chan_nodes_added++;
@@ -1062,15 +1064,14 @@ t_bb ConnectionRouter<Heap>::add_high_fanout_route_tree_to_heap(
10621064
if (done) break;
10631065
}
10641066

1065-
t_bb bounding_box = net_bounding_box;
10661067
if (nodes_added == 0) { //If the target bin, and it's surrounding bins were empty, just add the full route tree
10671068
add_route_tree_to_heap(rt_root, target_node, cost_params, true);
1069+
return net_bounding_box;
10681070
} else {
10691071
//We found nearby routing, replace original bounding box to be localized around that routing
1070-
bounding_box = adjust_highfanout_bounding_box(highfanout_bb);
1072+
adjust_highfanout_bounding_box(highfanout_bb, net_bounding_box);
1073+
return highfanout_bb;
10711074
}
1072-
1073-
return bounding_box;
10741075
}
10751076

10761077
std::unique_ptr<ConnectionRouterInterface> make_connection_router(e_heap_type heap_type,

vpr/src/route/route.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "read_route.h"
77
#include "route.h"
88
#include "route_common.h"
9+
#include "route_debug.h"
910
#include "route_export.h"
1011
#include "route_profiling.h"
1112
#include "route_utils.h"

vpr/src/route/route_common.cpp

Lines changed: 13 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "draw_global.h"
66
#include "place_and_route.h"
77
#include "route_common.h"
8+
#include "route_export.h"
89
#include "rr_graph.h"
910

1011
/* The numbering relation between the channels and clbs is: *
@@ -36,7 +37,7 @@
3637
* chan_width_y[0] chan_width_y[1] *
3738
* */
3839

39-
/******************** Subroutines local to route_common.c *******************/
40+
/******************** Subroutines local to route_common.cpp *******************/
4041
static vtr::vector<ParentNetId, std::vector<RRNodeId>> load_net_rr_terminals(const RRGraphView& rr_graph,
4142
const Netlist<>& net_list,
4243
bool is_flat);
@@ -74,7 +75,7 @@ void save_routing(vtr::vector<ParentNetId, vtr::optional<RouteTree>>& best_routi
7475
saved_clb_opins_used_locally = clb_opins_used_locally;
7576
}
7677

77-
/* Empties route_ctx.current_rt and copies over best_routing onto it.
78+
/* Empties route_ctx.route_trees and copies over best_routing onto it.
7879
* Also restores the locally used opin data. */
7980
void restore_routing(vtr::vector<ParentNetId, vtr::optional<RouteTree>>& best_routing,
8081
t_clb_opins_used& clb_opins_used_locally,
@@ -117,46 +118,6 @@ void get_serial_num(const Netlist<>& net_list) {
117118
VTR_LOG("Serial number (magic cookie) for the routing is: %d\n", serial_num);
118119
}
119120

120-
void try_graph(int width_fac,
121-
const t_router_opts& router_opts,
122-
t_det_routing_arch* det_routing_arch,
123-
std::vector<t_segment_inf>& segment_inf,
124-
t_chan_width_dist chan_width_dist,
125-
t_direct_inf* directs,
126-
int num_directs,
127-
bool is_flat) {
128-
auto& device_ctx = g_vpr_ctx.mutable_device();
129-
130-
t_graph_type graph_type;
131-
t_graph_type graph_directionality;
132-
if (router_opts.route_type == GLOBAL) {
133-
graph_type = GRAPH_GLOBAL;
134-
graph_directionality = GRAPH_BIDIR;
135-
} else {
136-
graph_type = (det_routing_arch->directionality == BI_DIRECTIONAL ? GRAPH_BIDIR : GRAPH_UNIDIR);
137-
graph_directionality = (det_routing_arch->directionality == BI_DIRECTIONAL ? GRAPH_BIDIR : GRAPH_UNIDIR);
138-
}
139-
140-
/* Set the channel widths */
141-
t_chan_width chan_width = init_chan(width_fac, chan_width_dist, graph_directionality);
142-
143-
/* Free any old routing graph, if one exists. */
144-
free_rr_graph();
145-
146-
/* Set up the routing resource graph defined by this FPGA architecture. */
147-
int warning_count;
148-
create_rr_graph(graph_type,
149-
device_ctx.physical_tile_types,
150-
device_ctx.grid,
151-
chan_width,
152-
det_routing_arch,
153-
segment_inf,
154-
router_opts,
155-
directs, num_directs,
156-
&warning_count,
157-
is_flat);
158-
}
159-
160121
/** This routine checks to see if this is a resource-feasible routing.
161122
* That is, are all rr_node capacity limitations respected? It assumes
162123
* that the occupancy arrays are up to date when it is called. */
@@ -211,10 +172,9 @@ vtr::vector<RRNodeId, std::set<ClusterNetId>> collect_rr_node_nets() {
211172
return rr_node_nets;
212173
}
213174

175+
/** Updates pathfinder's occupancy by either adding or removing the
176+
* usage of a resource node. */
214177
void pathfinder_update_single_node_occupancy(RRNodeId inode, int add_or_sub) {
215-
/* Updates pathfinder's occupancy by either adding or removing the
216-
* usage of a resource node. */
217-
218178
auto& route_ctx = g_vpr_ctx.mutable_routing();
219179

220180
int occ = route_ctx.rr_node_route_inf[inode].occ() + add_or_sub;
@@ -223,14 +183,13 @@ void pathfinder_update_single_node_occupancy(RRNodeId inode, int add_or_sub) {
223183
VTR_ASSERT(occ >= 0);
224184
}
225185

186+
/** This routine recomputes the acc_cost (accumulated congestion cost) of each
187+
* routing resource for the pathfinder algorithm after all nets have been routed.
188+
* It updates the accumulated cost to by adding in the number of extra signals
189+
* sharing a resource right now (i.e. after each complete iteration) times acc_fac.
190+
* THIS ROUTINE ASSUMES THE OCCUPANCY VALUES IN RR_NODE ARE UP TO DATE.
191+
* This routine also creates a new overuse info for the current routing iteration. */
226192
void pathfinder_update_acc_cost_and_overuse_info(float acc_fac, OveruseInfo& overuse_info) {
227-
/* This routine recomputes the acc_cost (accumulated congestion cost) of each *
228-
* routing resource for the pathfinder algorithm after all nets have been routed. *
229-
* It updates the accumulated cost to by adding in the number of extra signals *
230-
* sharing a resource right now (i.e. after each complete iteration) times acc_fac. *
231-
* THIS ROUTINE ASSUMES THE OCCUPANCY VALUES IN RR_NODE ARE UP TO DATE. *
232-
* This routine also creates a new overuse info for the current routing iteration. */
233-
234193
auto& device_ctx = g_vpr_ctx.device();
235194
const auto& rr_graph = device_ctx.rr_graph;
236195
auto& route_ctx = g_vpr_ctx.mutable_routing();
@@ -264,20 +223,6 @@ void pathfinder_update_cost_from_route_tree(const RouteTreeNode& root, int add_o
264223
}
265224
}
266225

267-
float update_pres_fac(float new_pres_fac) {
268-
/* This routine should take the new value of the present congestion factor *
269-
* and propagate it to all the relevant data fields in the vpr flow. *
270-
* Currently, it only updates the pres_fac used by the drawing functions */
271-
#ifndef NO_GRAPHICS
272-
273-
// Only updates the drawing pres_fac if graphics is enabled
274-
get_draw_state_vars()->pres_fac = new_pres_fac;
275-
276-
#endif // NO_GRAPHICS
277-
278-
return new_pres_fac;
279-
}
280-
281226
/* Call this before you route any nets. It frees any old route trees and
282227
* sets the list of rr_nodes touched to empty. */
283228
void init_route_structs(const Netlist<>& net_list,
@@ -442,12 +387,9 @@ static t_clb_opins_used alloc_and_load_clb_opins_used_locally() {
442387
return (clb_opins_used_locally);
443388
}
444389

445-
/*the trace lists are only freed after use by the timing-driven placer */
446-
/*Do not free them after use by the router, since stats, and draw */
447-
/*routines use the trace values */
390+
/* Frees the temporary storage needed only during the routing. The
391+
* final routing result is not freed. */
448392
void free_route_structs() {
449-
/* Frees the temporary storage needed only during the routing. The *
450-
* final routing result is not freed. */
451393
auto& route_ctx = g_vpr_ctx.mutable_routing();
452394

453395
if (route_ctx.route_bb.size() != 0) {

vpr/src/route/route_common.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
#pragma once
22

3-
/** @file More router utils (mostly used by the connection router) */
3+
/** @file More router utils: some used by the connection router, some by other
4+
* router files and some used globally */
45

56
#include <vector>
67
#include "clustered_netlist.h"
78
#include "rr_node_fwd.h"
89
#include "router_stats.h"
910
#include "globals.h"
1011

11-
/******* Subroutines in route_common used only by other router modules ******/
12+
bool feasible_routing();
13+
1214
vtr::vector<ParentNetId, t_bb> load_route_bb(const Netlist<>& net_list,
1315
int bb_factor);
1416

@@ -23,8 +25,6 @@ void pathfinder_update_acc_cost_and_overuse_info(float acc_fac, OveruseInfo& ove
2325
/** Update pathfinder cost of all nodes under root (including root) */
2426
void pathfinder_update_cost_from_route_tree(const RouteTreeNode& root, int add_or_sub);
2527

26-
float update_pres_fac(float new_pres_fac);
27-
2828
void reset_path_costs(const std::vector<RRNodeId>& visited_rr_nodes);
2929

3030
float get_rr_cong_cost(RRNodeId inode, float pres_fac);

vpr/src/route/route_debug.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "route_debug.h"
2+
3+
std::atomic_bool f_router_debug = false;
4+
5+
void enable_router_debug(
6+
const t_router_opts& router_opts,
7+
ParentNetId net,
8+
RRNodeId sink_rr,
9+
int router_iteration,
10+
ConnectionRouterInterface* router) {
11+
bool active_net_debug = (router_opts.router_debug_net >= -1);
12+
bool active_sink_debug = (router_opts.router_debug_sink_rr >= 0);
13+
bool active_iteration_debug = (router_opts.router_debug_iteration >= 0);
14+
15+
bool match_net = (ParentNetId(router_opts.router_debug_net) == net || router_opts.router_debug_net == -1);
16+
bool match_sink = (router_opts.router_debug_sink_rr == int(size_t((sink_rr))) || router_opts.router_debug_sink_rr < 0);
17+
bool match_iteration = (router_opts.router_debug_iteration == router_iteration || router_opts.router_debug_iteration < 0);
18+
19+
f_router_debug = active_net_debug || active_sink_debug || active_iteration_debug;
20+
21+
if (active_net_debug) f_router_debug = f_router_debug && match_net;
22+
if (active_sink_debug) f_router_debug = f_router_debug && match_sink;
23+
if (active_iteration_debug) f_router_debug = f_router_debug && match_iteration;
24+
25+
router->set_router_debug(f_router_debug);
26+
27+
#ifndef VTR_ENABLE_DEBUG_LOGGING
28+
VTR_LOGV_WARN(f_router_debug, "Limited router debug output provided since compiled without VTR_ENABLE_DEBUG_LOGGING defined\n");
29+
#endif
30+
}

vpr/src/route/route_debug.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#pragma once
2+
3+
/** @file Utils for debugging the router */
4+
5+
#include <atomic>
6+
#include "connection_router_interface.h"
7+
#include "vpr_types.h"
8+
9+
/** @brief Run-time flag to control when router debug information is printed
10+
* Note only enables debug output if compiled with VTR_ENABLE_DEBUG_LOGGING defined
11+
* f_router_debug is used to stop the router when a breakpoint is reached. When a breakpoint is reached, this flag is set to true.
12+
*
13+
* In addition f_router_debug is used to print additional debug information during routing, for instance lookahead expected costs
14+
* information.
15+
*
16+
* d2: Made atomic as an attempt to make it work with parallel routing, but don't expect reliable results. */
17+
extern std::atomic_bool f_router_debug;
18+
19+
/** Enable f_router_debug if specific sink/net debugging is set in \p router_opts */
20+
void enable_router_debug(const t_router_opts& router_opts, ParentNetId net, RRNodeId sink_rr, int router_iteration, ConnectionRouterInterface* router);

vpr/src/route/route_export.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,10 @@
1111

1212
#include "RoutingDelayCalculator.h"
1313

14-
void try_graph(int width_fac,
15-
const t_router_opts& router_opts,
16-
t_det_routing_arch* det_routing_arch,
17-
std::vector<t_segment_inf>& segment_inf,
18-
t_chan_width_dist chan_width_dist,
19-
t_direct_inf* directs,
20-
int num_directs,
21-
bool is_flat);
22-
23-
bool feasible_routing();
24-
2514
std::vector<RRNodeId> collect_congested_rr_nodes();
2615

2716
vtr::vector<RRNodeId, std::set<ClusterNetId>> collect_rr_node_nets();
2817

29-
t_clb_opins_used alloc_route_structs();
30-
3118
void free_route_structs();
3219

3320
void save_routing(vtr::vector<ParentNetId, vtr::optional<RouteTree>>& best_routing,

0 commit comments

Comments
 (0)