Skip to content

rr_graph: implement more robust delay normalization calculation #1576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions libs/libvtrutil/src/vtr_math.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <map>
#include <algorithm>

#include "vtr_assert.h"
#include "vtr_error.h"
Expand All @@ -20,6 +21,19 @@ int ipow(int base, int exp) {
return result;
}

float median(std::vector<float> vector) {
VTR_ASSERT(vector.size() > 0);

std::sort(vector.begin(), vector.end());

auto size = vector.size();
if (size % 2 == 0) {
return (float)(vector[size / 2 - 1] + vector[size / 2]) / 2;
}

return (float)vector[size / 2];
}

/* Performs linear interpolation or extrapolation on the set of (x,y) values specified by the xy_map.
* A requested x value is passed in, and we return the interpolated/extrapolated y value at this requested value of x.
* Meant for maps where both key and element are numbers.
Expand Down
4 changes: 4 additions & 0 deletions libs/libvtrutil/src/vtr_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define VTR_MATH_H

#include <map>
#include <vector>
#include <cmath>

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

//Returns the median of an input vector.
float median(std::vector<float> vector);

template<typename X, typename Y>
Y linear_interpolate_or_extrapolate(const std::map<X, Y>* xy_map, X requested_x);

Expand Down
1 change: 1 addition & 0 deletions vpr/src/base/SetupVPR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ static void SetupRoutingArch(const t_arch& Arch,
static void SetupRouterOpts(const t_options& Options, t_router_opts* RouterOpts) {
RouterOpts->do_check_rr_graph = Options.check_rr_graph;
RouterOpts->astar_fac = Options.astar_fac;
RouterOpts->router_profiler_astar_fac = Options.router_profiler_astar_fac;
RouterOpts->bb_factor = Options.bb_factor;
RouterOpts->criticality_exp = Options.criticality_exp;
RouterOpts->max_criticality = Options.max_criticality;
Expand Down
2 changes: 2 additions & 0 deletions vpr/src/base/ShowSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {

if (TIMING_DRIVEN == RouterOpts.router_algorithm) {
VTR_LOG("RouterOpts.astar_fac: %f\n", RouterOpts.astar_fac);
VTR_LOG("RouterOpts.router_profiler_astar_fac: %f\n", RouterOpts.router_profiler_astar_fac);
VTR_LOG("RouterOpts.criticality_exp: %f\n", RouterOpts.criticality_exp);
VTR_LOG("RouterOpts.max_criticality: %f\n", RouterOpts.max_criticality);
VTR_LOG("RouterOpts.init_wirelength_abort_threshold: %f\n", RouterOpts.init_wirelength_abort_threshold);
Expand Down Expand Up @@ -412,6 +413,7 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
VTR_LOG("RouterOpts.exit_after_first_routing_iteration: %s\n", RouterOpts.exit_after_first_routing_iteration ? "true" : "false");
if (TIMING_DRIVEN == RouterOpts.router_algorithm) {
VTR_LOG("RouterOpts.astar_fac: %f\n", RouterOpts.astar_fac);
VTR_LOG("RouterOpts.router_profiler_astar_fac: %f\n", RouterOpts.router_profiler_astar_fac);
VTR_LOG("RouterOpts.criticality_exp: %f\n", RouterOpts.criticality_exp);
VTR_LOG("RouterOpts.max_criticality: %f\n", RouterOpts.max_criticality);
VTR_LOG("RouterOpts.init_wirelength_abort_threshold: %f\n", RouterOpts.init_wirelength_abort_threshold);
Expand Down
1 change: 1 addition & 0 deletions vpr/src/base/echo_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ void alloc_and_load_echo_file_info() {
setEchoFileName(E_ECHO_SBLOCK_PATTERN, "sblock_pattern.txt");
setEchoFileName(E_ECHO_ENDPOINT_TIMING, "endpoint_timing.echo.json");
setEchoFileName(E_ECHO_LOOKAHEAD_MAP, "lookahead_map.echo");
setEchoFileName(E_ECHO_RR_GRAPH_INDEXED_DATA, "rr_indexed_data.echo");
}

void free_echo_file_info() {
Expand Down
1 change: 1 addition & 0 deletions vpr/src/base/echo_files.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ enum e_echo_files {
E_ECHO_SBLOCK_PATTERN,
E_ECHO_ENDPOINT_TIMING,
E_ECHO_LOOKAHEAD_MAP,
E_ECHO_RR_GRAPH_INDEXED_DATA,

//Timing Graphs
E_ECHO_PRE_PACKING_TIMING_GRAPH,
Expand Down
11 changes: 10 additions & 1 deletion vpr/src/base/read_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2000,7 +2000,16 @@ argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& arg

route_timing_grp.add_argument(args.astar_fac, "--astar_fac")
.help(
"Controls the directedness of the the timing-driven router's exploration."
"Controls the directedness of the timing-driven router's exploration."
" Values between 1 and 2 are resonable; higher values trade some quality for reduced run-time")
.default_value("1.2")
.show_in(argparse::ShowIn::HELP_ONLY);

route_timing_grp.add_argument(args.router_profiler_astar_fac, "--router_profiler_astar_fac")
.help(
"Controls the directedness of the timing-driven router's exploration"
" when doing router delay profiling."
" The router delay profiling step is currently used to calculate the place delay matrix lookup."
" Values between 1 and 2 are resonable; higher values trade some quality for reduced run-time")
.default_value("1.2")
.show_in(argparse::ShowIn::HELP_ONLY);
Expand Down
1 change: 1 addition & 0 deletions vpr/src/base/read_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ struct t_options {

/* Timing-driven router options only */
argparse::ArgValue<float> astar_fac;
argparse::ArgValue<float> router_profiler_astar_fac;
argparse::ArgValue<float> max_criticality;
argparse::ArgValue<float> criticality_exp;
argparse::ArgValue<float> router_init_wirelength_abort_threshold;
Expand Down
1 change: 1 addition & 0 deletions vpr/src/base/vpr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,7 @@ struct t_router_opts {
enum e_router_algorithm router_algorithm;
enum e_base_cost_type base_cost_type;
float astar_fac;
float router_profiler_astar_fac;
float max_criticality;
float criticality_exp;
float init_wirelength_abort_threshold;
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/route/router_delay_profiling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool RouterDelayProfiler::calculate_delay(int source_node, int sink_node, const

t_conn_cost_params cost_params;
cost_params.criticality = 1.;
cost_params.astar_fac = router_opts.astar_fac;
cost_params.astar_fac = router_opts.router_profiler_astar_fac;
cost_params.bend_cost = router_opts.bend_cost;

route_budgets budgeting_inf;
Expand Down
8 changes: 2 additions & 6 deletions vpr/src/route/rr_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ static void load_rr_switch_inf(const int num_arch_switches, const float R_minW_n
static void alloc_rr_switch_inf(t_arch_switch_fanin& switch_fanin);

static void rr_graph_externals(const std::vector<t_segment_inf>& segment_inf,
int max_chan_width,
int wire_to_rr_ipin_switch,
enum e_base_cost_type base_cost_type);

Expand Down Expand Up @@ -740,8 +739,7 @@ static void build_rr_graph(const t_graph_type graph_type,
//Save the channel widths for the newly constructed graph
device_ctx.chan_width = nodes_per_chan;

rr_graph_externals(segment_inf, max_chan_width,
*wire_to_rr_ipin_switch, base_cost_type);
rr_graph_externals(segment_inf, *wire_to_rr_ipin_switch, base_cost_type);

check_rr_graph(graph_type, grid, types);

Expand Down Expand Up @@ -907,14 +905,12 @@ static void remap_rr_node_switch_indices(const t_arch_switch_fanin& switch_fanin
}

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

add_rr_graph_C_from_switches(device_ctx.rr_switch_inf[wire_to_rr_ipin_switch].Cin);
alloc_and_load_rr_indexed_data(segment_inf, device_ctx.rr_node_indices,
max_chan_width, wire_to_rr_ipin_switch, base_cost_type);
alloc_and_load_rr_indexed_data(segment_inf, wire_to_rr_ipin_switch, base_cost_type);
load_rr_index_segments(segment_inf.size());
}

Expand Down
Loading