Skip to content

Commit 9343ee9

Browse files
authored
Merge pull request #2563 from verilog-to-routing/temp_cleanup_
Minor router lookahed cleanup
2 parents 817a956 + 3df3b6b commit 9343ee9

16 files changed

+195
-163
lines changed

libs/libarchfpga/src/physical_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,8 +1558,8 @@ enum e_Fc_type {
15581558
* seg_index: The index of the segment as stored in the appropriate Segs list*
15591559
* Upon loading the architecture, we use this field to keep track *
15601560
* the segment's index in the unified segment_inf vector. This is *
1561-
* usefull when building the rr_graph for different Y & X channels*
1562-
* interms of track distribution and segment type. *
1561+
* useful when building the rr_graph for different Y & X channels *
1562+
* in terms of track distribution and segment type. *
15631563
* meta: Table storing extra arbitrary metadata attributes. */
15641564
struct t_segment_inf {
15651565
std::string name;

libs/librrgraph/src/base/rr_graph_view.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ class RRGraphView {
369369
/** @brief Get outgoing edges for a node.
370370
* This API is designed to enable range-based loop to walk through the outgoing edges of a node
371371
* Example:
372-
* RRGraphView rr_graph; // A dummny rr_graph for a short example
372+
* RRGraphView rr_graph; // A dummy rr_graph for a short example
373373
* RRNodeId node; // A dummy node for a short example
374374
* for (RREdgeId edge : rr_graph.edges(node)) {
375375
* // Do something with the edge
@@ -436,7 +436,7 @@ class RRGraphView {
436436
}
437437

438438
/** @brief Return the switch information that is categorized in the rr_switch_inf with a given id
439-
* rr_switch_inf is created to minimize memory footprint of RRGraph classs
439+
* rr_switch_inf is created to minimize memory footprint of RRGraph class
440440
* While the RRG could contain millions (even much larger) of edges, there are only
441441
* a limited number of types of switches.
442442
* Hence, we use a flyweight pattern to store switch-related information that differs

vpr/src/base/read_options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2572,7 +2572,7 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio
25722572
" * classic: The classic VPR lookahead (may perform better on un-buffered routing\n"
25732573
" architectures)\n"
25742574
" * map: An advanced lookahead which accounts for diverse wire type\n"
2575-
" * compressed_map: The algorithm is similar to map lookahead with the exception of saprse sampling of the chip"
2575+
" * compressed_map: The algorithm is similar to map lookahead with the exception of sparse sampling of the chip"
25762576
" to reduce the run-time to build the router lookahead and also its memory footprint\n"
25772577
" * extended_map: A more advanced and extended lookahead which accounts for a more\n"
25782578
" exhaustive node sampling method\n"

vpr/src/base/vpr_api.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,9 @@ void vpr_create_device_grid(const t_vpr_setup& vpr_setup, const t_arch& Arch) {
462462
float target_device_utilization = vpr_setup.PackerOpts.target_device_utilization;
463463
device_ctx.grid = create_device_grid(vpr_setup.device_layout, Arch.grid_layouts, num_type_instances, target_device_utilization);
464464

465-
VTR_ASSERT_MSG(device_ctx.grid.get_num_layers() <= MAX_NUM_LAYERS, "Number of layers should be less than MAX_NUM_LAYERS. If you need more layers, please increase the value of MAX_NUM_LAYERS in vpr_types.h");
465+
VTR_ASSERT_MSG(device_ctx.grid.get_num_layers() <= MAX_NUM_LAYERS,
466+
"Number of layers should be less than MAX_NUM_LAYERS. "
467+
"If you need more layers, please increase the value of MAX_NUM_LAYERS in vpr_types.h");
466468

467469
/*
468470
*Report on the device
@@ -1455,7 +1457,7 @@ void vpr_analysis(const Netlist<>& net_list,
14551457
generate_setup_timing_stats(/*prefix=*/"", *timing_info,
14561458
*analysis_delay_calc, vpr_setup.AnalysisOpts, vpr_setup.RouterOpts.flat_routing);
14571459

1458-
//Write the post-syntesis netlist
1460+
//Write the post-synthesis netlist
14591461
if (vpr_setup.AnalysisOpts.gen_post_synthesis_netlist) {
14601462
netlist_writer(atom_ctx.nlist.netlist_name().c_str(), analysis_delay_calc,
14611463
vpr_setup.AnalysisOpts);

vpr/src/base/vpr_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,7 @@ class t_chan_seg_details {
16811681

16821682
private:
16831683
//The only unique information about a channel segment is it's start/end
1684-
//and length. All other information is shared accross segment types,
1684+
//and length. All other information is shared across segment types,
16851685
//so we use a flyweight to the t_seg_details which defines that info.
16861686
//
16871687
//To preserve the illusion of uniqueness we wrap all t_seg_details members

vpr/src/place/timing_place_lookup.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ std::unique_ptr<PlaceDelayModel> compute_place_delay_model(const t_placer_opts&
195195
router_opts.read_router_lookahead,
196196
segment_inf,
197197
is_flat);
198+
198199
RouterDelayProfiler route_profiler(net_list, router_lookahead, is_flat);
199200

200201
int longest_length = get_longest_segment_length(segment_inf);

vpr/src/route/router_delay_profiling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ vtr::vector<RRNodeId, float> calculate_all_path_delays_from_rr_node(RRNodeId src
243243
return path_delays_to;
244244
}
245245

246-
void alloc_routing_structs(t_chan_width chan_width,
246+
void alloc_routing_structs(const t_chan_width& chan_width,
247247
const t_router_opts& router_opts,
248248
t_det_routing_arch* det_routing_arch,
249249
std::vector<t_segment_inf>& segment_inf,

vpr/src/route/router_delay_profiling.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ vtr::vector<RRNodeId, float> calculate_all_path_delays_from_rr_node(RRNodeId src
5454
const t_router_opts& router_opts,
5555
bool is_flat);
5656

57-
void alloc_routing_structs(t_chan_width chan_width,
57+
void alloc_routing_structs(const t_chan_width& chan_width,
5858
const t_router_opts& router_opts,
5959
t_det_routing_arch* det_routing_arch,
6060
std::vector<t_segment_inf>& segment_inf,

vpr/src/route/router_lookahead.cpp

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@
77
#include "vpr_error.h"
88
#include "globals.h"
99

10-
static int get_expected_segs_to_target(RRNodeId inode, RRNodeId target_node, int* num_segs_ortho_dir_ptr);
10+
/**
11+
* Assuming inode is CHANX or CHANY, this function calculates the number of required wires of the same type as inode
12+
* to arrive at target_noe.
13+
* @param inode The source node from which the cost to the target node is obtained.
14+
* @param target_node The target node to which the cost is obtained.
15+
* @return std::pait<int, int> The first element is the number of required wires in the same direction as inode,
16+
* while the second element determines the number of wires in the direction orthogonal to inode.
17+
*/
18+
static std::pair<int, int> get_expected_segs_to_target(RRNodeId inode, RRNodeId target_node);
19+
1120
static int round_up(float x);
1221

1322
static std::unique_ptr<RouterLookahead> make_router_lookahead_object(const t_det_routing_arch& det_routing_arch,
@@ -31,8 +40,8 @@ static std::unique_ptr<RouterLookahead> make_router_lookahead_object(const t_det
3140

3241
std::unique_ptr<RouterLookahead> make_router_lookahead(const t_det_routing_arch& det_routing_arch,
3342
e_router_lookahead router_lookahead_type,
34-
std::string write_lookahead,
35-
std::string read_lookahead,
43+
const std::string& write_lookahead,
44+
const std::string& read_lookahead,
3645
const std::vector<t_segment_inf>& segment_inf,
3746
bool is_flat) {
3847
std::unique_ptr<RouterLookahead> router_lookahead = make_router_lookahead_object(det_routing_arch,
@@ -53,8 +62,7 @@ std::unique_ptr<RouterLookahead> make_router_lookahead(const t_det_routing_arch&
5362
}
5463

5564
float ClassicLookahead::get_expected_cost(RRNodeId current_node, RRNodeId target_node, const t_conn_cost_params& params, float R_upstream) const {
56-
float delay_cost, cong_cost;
57-
std::tie(delay_cost, cong_cost) = get_expected_delay_and_cong(current_node, target_node, params, R_upstream);
65+
auto [delay_cost, cong_cost] = get_expected_delay_and_cong(current_node, target_node, params, R_upstream);
5866

5967
return delay_cost + cong_cost;
6068
}
@@ -66,8 +74,7 @@ std::pair<float, float> ClassicLookahead::get_expected_delay_and_cong(RRNodeId n
6674
t_rr_type rr_type = rr_graph.node_type(node);
6775

6876
if (rr_type == CHANX || rr_type == CHANY) {
69-
int num_segs_ortho_dir = 0;
70-
int num_segs_same_dir = get_expected_segs_to_target(node, target_node, &num_segs_ortho_dir);
77+
auto [num_segs_same_dir, num_segs_ortho_dir] = get_expected_segs_to_target(node, target_node);
7178

7279
auto cost_index = rr_graph.node_cost_index(node);
7380
int ortho_cost_index = device_ctx.rr_indexed_data[cost_index].ortho_cost_index;
@@ -112,28 +119,27 @@ static int round_up(float x) {
112119
return std::ceil(x - 0.001);
113120
}
114121

115-
static int get_expected_segs_to_target(RRNodeId inode, RRNodeId target_node, int* num_segs_ortho_dir_ptr) {
122+
static std::pair<int, int> get_expected_segs_to_target(RRNodeId inode, RRNodeId target_node) {
116123
/* Returns the number of segments the same type as inode that will be needed *
117124
* to reach target_node (not including inode) in each direction (the same *
118125
* direction (horizontal or vertical) as inode and the orthogonal direction).*/
119-
120126
auto& device_ctx = g_vpr_ctx.device();
121127
const auto& rr_graph = device_ctx.rr_graph;
122128

123-
t_rr_type rr_type;
124-
int target_x, target_y, num_segs_same_dir, ortho_cost_index;
125-
RRIndexedDataId cost_index;
129+
int num_segs_ortho_dir;
130+
int num_segs_same_dir;
131+
126132
int no_need_to_pass_by_clb;
127-
float inv_length, ortho_inv_length, ylow, yhigh, xlow, xhigh;
133+
float ylow, yhigh, xlow, xhigh;
128134

129-
target_x = rr_graph.node_xlow(target_node);
130-
target_y = rr_graph.node_ylow(target_node);
135+
int target_x = rr_graph.node_xlow(target_node);
136+
int target_y = rr_graph.node_ylow(target_node);
131137

132-
cost_index = rr_graph.node_cost_index(inode);
133-
inv_length = device_ctx.rr_indexed_data[cost_index].inv_length;
134-
ortho_cost_index = device_ctx.rr_indexed_data[cost_index].ortho_cost_index;
135-
ortho_inv_length = device_ctx.rr_indexed_data[RRIndexedDataId(ortho_cost_index)].inv_length;
136-
rr_type = rr_graph.node_type(inode);
138+
RRIndexedDataId cost_index = rr_graph.node_cost_index(inode);
139+
float inv_length = device_ctx.rr_indexed_data[cost_index].inv_length;
140+
int ortho_cost_index = device_ctx.rr_indexed_data[cost_index].ortho_cost_index;
141+
float ortho_inv_length = device_ctx.rr_indexed_data[RRIndexedDataId(ortho_cost_index)].inv_length;
142+
t_rr_type rr_type = rr_graph.node_type(inode);
137143

138144
if (rr_type == CHANX) {
139145
ylow = rr_graph.node_ylow(inode);
@@ -143,13 +149,13 @@ static int get_expected_segs_to_target(RRNodeId inode, RRNodeId target_node, int
143149
/* Count vertical (orthogonal to inode) segs first. */
144150

145151
if (ylow > target_y) { /* Coming from a row above target? */
146-
*num_segs_ortho_dir_ptr = round_up((ylow - target_y + 1.) * ortho_inv_length);
152+
num_segs_ortho_dir = round_up((ylow - target_y + 1.) * ortho_inv_length);
147153
no_need_to_pass_by_clb = 1;
148154
} else if (ylow < target_y - 1) { /* Below the CLB bottom? */
149-
*num_segs_ortho_dir_ptr = round_up((target_y - ylow) * ortho_inv_length);
155+
num_segs_ortho_dir = round_up((target_y - ylow) * ortho_inv_length);
150156
no_need_to_pass_by_clb = 1;
151157
} else { /* In a row that passes by target CLB */
152-
*num_segs_ortho_dir_ptr = 0;
158+
num_segs_ortho_dir = 0;
153159
no_need_to_pass_by_clb = 0;
154160
}
155161

@@ -170,13 +176,13 @@ static int get_expected_segs_to_target(RRNodeId inode, RRNodeId target_node, int
170176
/* Count horizontal (orthogonal to inode) segs first. */
171177

172178
if (xlow > target_x) { /* Coming from a column right of target? */
173-
*num_segs_ortho_dir_ptr = round_up((xlow - target_x + 1.) * ortho_inv_length);
179+
num_segs_ortho_dir = round_up((xlow - target_x + 1.) * ortho_inv_length);
174180
no_need_to_pass_by_clb = 1;
175181
} else if (xlow < target_x - 1) { /* Left of and not adjacent to the CLB? */
176-
*num_segs_ortho_dir_ptr = round_up((target_x - xlow) * ortho_inv_length);
182+
num_segs_ortho_dir = round_up((target_x - xlow) * ortho_inv_length);
177183
no_need_to_pass_by_clb = 1;
178184
} else { /* In a column that passes by target CLB */
179-
*num_segs_ortho_dir_ptr = 0;
185+
num_segs_ortho_dir = 0;
180186
no_need_to_pass_by_clb = 0;
181187
}
182188

@@ -191,7 +197,7 @@ static int get_expected_segs_to_target(RRNodeId inode, RRNodeId target_node, int
191197
}
192198
}
193199

194-
return (num_segs_same_dir);
200+
return {num_segs_same_dir, num_segs_ortho_dir};
195201
}
196202

197203
void invalidate_router_lookahead_cache() {
@@ -201,8 +207,8 @@ void invalidate_router_lookahead_cache() {
201207

202208
const RouterLookahead* get_cached_router_lookahead(const t_det_routing_arch& det_routing_arch,
203209
e_router_lookahead router_lookahead_type,
204-
std::string write_lookahead,
205-
std::string read_lookahead,
210+
const std::string& write_lookahead,
211+
const std::string& read_lookahead,
206212
const std::vector<t_segment_inf>& segment_inf,
207213
bool is_flat) {
208214
auto& router_ctx = g_vpr_ctx.routing();

vpr/src/route/router_lookahead.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ class RouterLookahead {
9292
*/
9393
std::unique_ptr<RouterLookahead> make_router_lookahead(const t_det_routing_arch& det_routing_arch,
9494
e_router_lookahead router_lookahead_type,
95-
std::string write_lookahead,
96-
std::string read_lookahead,
95+
const std::string& write_lookahead,
96+
const std::string& read_lookahead,
9797
const std::vector<t_segment_inf>& segment_inf,
9898
bool is_flat);
9999

@@ -115,8 +115,8 @@ void invalidate_router_lookahead_cache();
115115
*/
116116
const RouterLookahead* get_cached_router_lookahead(const t_det_routing_arch& det_routing_arch,
117117
e_router_lookahead router_lookahead_type,
118-
std::string write_lookahead,
119-
std::string read_lookahead,
118+
const std::string& write_lookahead,
119+
const std::string& read_lookahead,
120120
const std::vector<t_segment_inf>& segment_inf,
121121
bool is_flat);
122122

vpr/src/route/router_lookahead_compressed_map.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,9 @@ std::pair<float, float> CompressedMapLookahead::get_expected_delay_and_cong(RRNo
428428
auto& device_ctx = g_vpr_ctx.device();
429429
auto& rr_graph = device_ctx.rr_graph;
430430

431-
int delta_x, delta_y;
432431
int from_layer_num = rr_graph.node_layer(from_node);
433432
int to_layer_num = rr_graph.node_layer(to_node);
434-
util::get_xy_deltas(from_node, to_node, &delta_x, &delta_y);
433+
auto [delta_x, delta_y] = util::get_xy_deltas(from_node, to_node);
435434
delta_x = abs(delta_x);
436435
delta_y = abs(delta_y);
437436

0 commit comments

Comments
 (0)