Skip to content

Commit 18b7ca6

Browse files
authored
Merge pull request #1576 from acomodi/robust-delay-norm-factor
rr_graph: implement more robust delay normalization calculation
2 parents e4266ef + ed6c456 commit 18b7ca6

File tree

23 files changed

+280
-265
lines changed

23 files changed

+280
-265
lines changed

libs/libvtrutil/src/vtr_math.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <map>
2+
#include <algorithm>
23

34
#include "vtr_assert.h"
45
#include "vtr_error.h"
@@ -20,6 +21,19 @@ int ipow(int base, int exp) {
2021
return result;
2122
}
2223

24+
float median(std::vector<float> vector) {
25+
VTR_ASSERT(vector.size() > 0);
26+
27+
std::sort(vector.begin(), vector.end());
28+
29+
auto size = vector.size();
30+
if (size % 2 == 0) {
31+
return (float)(vector[size / 2 - 1] + vector[size / 2]) / 2;
32+
}
33+
34+
return (float)vector[size / 2];
35+
}
36+
2337
/* Performs linear interpolation or extrapolation on the set of (x,y) values specified by the xy_map.
2438
* A requested x value is passed in, and we return the interpolated/extrapolated y value at this requested value of x.
2539
* Meant for maps where both key and element are numbers.

libs/libvtrutil/src/vtr_math.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define VTR_MATH_H
33

44
#include <map>
5+
#include <vector>
56
#include <cmath>
67

78
#include "vtr_assert.h"
@@ -10,6 +11,9 @@ namespace vtr {
1011
/*********************** Math operations *************************************/
1112
int ipow(int base, int exp);
1213

14+
//Returns the median of an input vector.
15+
float median(std::vector<float> vector);
16+
1317
template<typename X, typename Y>
1418
Y linear_interpolate_or_extrapolate(const std::map<X, Y>* xy_map, X requested_x);
1519

vpr/src/base/SetupVPR.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ static void SetupRoutingArch(const t_arch& Arch,
330330
static void SetupRouterOpts(const t_options& Options, t_router_opts* RouterOpts) {
331331
RouterOpts->do_check_rr_graph = Options.check_rr_graph;
332332
RouterOpts->astar_fac = Options.astar_fac;
333+
RouterOpts->router_profiler_astar_fac = Options.router_profiler_astar_fac;
333334
RouterOpts->bb_factor = Options.bb_factor;
334335
RouterOpts->criticality_exp = Options.criticality_exp;
335336
RouterOpts->max_criticality = Options.max_criticality;

vpr/src/base/ShowSetup.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
268268

269269
if (TIMING_DRIVEN == RouterOpts.router_algorithm) {
270270
VTR_LOG("RouterOpts.astar_fac: %f\n", RouterOpts.astar_fac);
271+
VTR_LOG("RouterOpts.router_profiler_astar_fac: %f\n", RouterOpts.router_profiler_astar_fac);
271272
VTR_LOG("RouterOpts.criticality_exp: %f\n", RouterOpts.criticality_exp);
272273
VTR_LOG("RouterOpts.max_criticality: %f\n", RouterOpts.max_criticality);
273274
VTR_LOG("RouterOpts.init_wirelength_abort_threshold: %f\n", RouterOpts.init_wirelength_abort_threshold);
@@ -408,6 +409,7 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
408409
VTR_LOG("RouterOpts.exit_after_first_routing_iteration: %s\n", RouterOpts.exit_after_first_routing_iteration ? "true" : "false");
409410
if (TIMING_DRIVEN == RouterOpts.router_algorithm) {
410411
VTR_LOG("RouterOpts.astar_fac: %f\n", RouterOpts.astar_fac);
412+
VTR_LOG("RouterOpts.router_profiler_astar_fac: %f\n", RouterOpts.router_profiler_astar_fac);
411413
VTR_LOG("RouterOpts.criticality_exp: %f\n", RouterOpts.criticality_exp);
412414
VTR_LOG("RouterOpts.max_criticality: %f\n", RouterOpts.max_criticality);
413415
VTR_LOG("RouterOpts.init_wirelength_abort_threshold: %f\n", RouterOpts.init_wirelength_abort_threshold);

vpr/src/base/echo_files.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ void alloc_and_load_echo_file_info() {
115115
setEchoFileName(E_ECHO_SBLOCK_PATTERN, "sblock_pattern.txt");
116116
setEchoFileName(E_ECHO_ENDPOINT_TIMING, "endpoint_timing.echo.json");
117117
setEchoFileName(E_ECHO_LOOKAHEAD_MAP, "lookahead_map.echo");
118+
setEchoFileName(E_ECHO_RR_GRAPH_INDEXED_DATA, "rr_indexed_data.echo");
118119
}
119120

120121
void free_echo_file_info() {

vpr/src/base/echo_files.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ enum e_echo_files {
4747
E_ECHO_SBLOCK_PATTERN,
4848
E_ECHO_ENDPOINT_TIMING,
4949
E_ECHO_LOOKAHEAD_MAP,
50+
E_ECHO_RR_GRAPH_INDEXED_DATA,
5051

5152
//Timing Graphs
5253
E_ECHO_PRE_PACKING_TIMING_GRAPH,

vpr/src/base/read_options.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2000,7 +2000,16 @@ argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& arg
20002000

20012001
route_timing_grp.add_argument(args.astar_fac, "--astar_fac")
20022002
.help(
2003-
"Controls the directedness of the the timing-driven router's exploration."
2003+
"Controls the directedness of the timing-driven router's exploration."
2004+
" Values between 1 and 2 are resonable; higher values trade some quality for reduced run-time")
2005+
.default_value("1.2")
2006+
.show_in(argparse::ShowIn::HELP_ONLY);
2007+
2008+
route_timing_grp.add_argument(args.router_profiler_astar_fac, "--router_profiler_astar_fac")
2009+
.help(
2010+
"Controls the directedness of the timing-driven router's exploration"
2011+
" when doing router delay profiling."
2012+
" The router delay profiling step is currently used to calculate the place delay matrix lookup."
20042013
" Values between 1 and 2 are resonable; higher values trade some quality for reduced run-time")
20052014
.default_value("1.2")
20062015
.show_in(argparse::ShowIn::HELP_ONLY);

vpr/src/base/read_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ struct t_options {
158158

159159
/* Timing-driven router options only */
160160
argparse::ArgValue<float> astar_fac;
161+
argparse::ArgValue<float> router_profiler_astar_fac;
161162
argparse::ArgValue<float> max_criticality;
162163
argparse::ArgValue<float> criticality_exp;
163164
argparse::ArgValue<float> router_init_wirelength_abort_threshold;

vpr/src/base/vpr_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,7 @@ struct t_router_opts {
11881188
enum e_router_algorithm router_algorithm;
11891189
enum e_base_cost_type base_cost_type;
11901190
float astar_fac;
1191+
float router_profiler_astar_fac;
11911192
float max_criticality;
11921193
float criticality_exp;
11931194
float init_wirelength_abort_threshold;

vpr/src/route/router_delay_profiling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ bool RouterDelayProfiler::calculate_delay(int source_node, int sink_node, const
5454

5555
t_conn_cost_params cost_params;
5656
cost_params.criticality = 1.;
57-
cost_params.astar_fac = router_opts.astar_fac;
57+
cost_params.astar_fac = router_opts.router_profiler_astar_fac;
5858
cost_params.bend_cost = router_opts.bend_cost;
5959

6060
route_budgets budgeting_inf;

vpr/src/route/rr_graph.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ static void load_rr_switch_inf(const int num_arch_switches, const float R_minW_n
257257
static void alloc_rr_switch_inf(t_arch_switch_fanin& switch_fanin);
258258

259259
static void rr_graph_externals(const std::vector<t_segment_inf>& segment_inf,
260-
int max_chan_width,
261260
int wire_to_rr_ipin_switch,
262261
enum e_base_cost_type base_cost_type);
263262

@@ -733,8 +732,7 @@ static void build_rr_graph(const t_graph_type graph_type,
733732
//Save the channel widths for the newly constructed graph
734733
device_ctx.chan_width = nodes_per_chan;
735734

736-
rr_graph_externals(segment_inf, max_chan_width,
737-
*wire_to_rr_ipin_switch, base_cost_type);
735+
rr_graph_externals(segment_inf, *wire_to_rr_ipin_switch, base_cost_type);
738736

739737
check_rr_graph(graph_type, grid, types);
740738

@@ -900,14 +898,12 @@ static void remap_rr_node_switch_indices(const t_arch_switch_fanin& switch_fanin
900898
}
901899

902900
static void rr_graph_externals(const std::vector<t_segment_inf>& segment_inf,
903-
int max_chan_width,
904901
int wire_to_rr_ipin_switch,
905902
enum e_base_cost_type base_cost_type) {
906903
auto& device_ctx = g_vpr_ctx.device();
907904

908905
add_rr_graph_C_from_switches(device_ctx.rr_switch_inf[wire_to_rr_ipin_switch].Cin);
909-
alloc_and_load_rr_indexed_data(segment_inf, device_ctx.rr_node_indices,
910-
max_chan_width, wire_to_rr_ipin_switch, base_cost_type);
906+
alloc_and_load_rr_indexed_data(segment_inf, wire_to_rr_ipin_switch, base_cost_type);
911907
load_rr_index_segments(segment_inf.size());
912908
}
913909

0 commit comments

Comments
 (0)