Skip to content

Commit 1df6df1

Browse files
[Route] Added astar_offset Parameter
Using an astar_offset can help better tune the ordering heuristic for the search used to find the shortest path in the routing graph. It is also necessary to ensure that the heuristic is an underestimate (without setting the astar_fac to 0.0).
1 parent 62fa97e commit 1df6df1

11 files changed

+31
-9
lines changed

vpr/src/base/SetupVPR.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ static void SetupRoutingArch(const t_arch& Arch,
414414
static void SetupRouterOpts(const t_options& Options, t_router_opts* RouterOpts) {
415415
RouterOpts->do_check_rr_graph = Options.check_rr_graph;
416416
RouterOpts->astar_fac = Options.astar_fac;
417+
RouterOpts->astar_offset = Options.astar_offset;
417418
RouterOpts->router_profiler_astar_fac = Options.router_profiler_astar_fac;
418419
RouterOpts->bb_factor = Options.bb_factor;
419420
RouterOpts->criticality_exp = Options.criticality_exp;

vpr/src/base/ShowSetup.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
339339

340340
if (TIMING_DRIVEN == RouterOpts.router_algorithm) {
341341
VTR_LOG("RouterOpts.astar_fac: %f\n", RouterOpts.astar_fac);
342+
VTR_LOG("RouterOpts.astar_offset: %f\n", RouterOpts.astar_offset);
342343
VTR_LOG("RouterOpts.router_profiler_astar_fac: %f\n", RouterOpts.router_profiler_astar_fac);
343344
VTR_LOG("RouterOpts.criticality_exp: %f\n", RouterOpts.criticality_exp);
344345
VTR_LOG("RouterOpts.max_criticality: %f\n", RouterOpts.max_criticality);
@@ -484,6 +485,7 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
484485
VTR_LOG("RouterOpts.exit_after_first_routing_iteration: %s\n", RouterOpts.exit_after_first_routing_iteration ? "true" : "false");
485486
if (TIMING_DRIVEN == RouterOpts.router_algorithm) {
486487
VTR_LOG("RouterOpts.astar_fac: %f\n", RouterOpts.astar_fac);
488+
VTR_LOG("RouterOpts.astar_offset: %f\n", RouterOpts.astar_offset);
487489
VTR_LOG("RouterOpts.router_profiler_astar_fac: %f\n", RouterOpts.router_profiler_astar_fac);
488490
VTR_LOG("RouterOpts.criticality_exp: %f\n", RouterOpts.criticality_exp);
489491
VTR_LOG("RouterOpts.max_criticality: %f\n", RouterOpts.max_criticality);
@@ -804,4 +806,4 @@ static void ShowNocOpts(const t_noc_opts& NocOpts) {
804806
VTR_LOG("NocOpts.noc_swap_percentage: %d%%\n", NocOpts.noc_swap_percentage);
805807
VTR_LOG("NocOpts.noc_routing_algorithm: %s\n", NocOpts.noc_placement_file_name.c_str());
806808
VTR_LOG("\n");
807-
}
809+
}

vpr/src/base/read_options.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2475,6 +2475,14 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio
24752475
.default_value("1.2")
24762476
.show_in(argparse::ShowIn::HELP_ONLY);
24772477

2478+
route_timing_grp.add_argument(args.astar_offset, "--astar_offset")
2479+
.help(
2480+
"Controls the directedness of the timing-driven router's exploration."
2481+
"Acts as an offset for the heuristic."
2482+
" Values between 0 and 1e-9 are resonable; higher values may increase quality at the expense of run-time.")
2483+
.default_value("0.0")
2484+
.show_in(argparse::ShowIn::HELP_ONLY);
2485+
24782486
route_timing_grp.add_argument(args.router_profiler_astar_fac, "--router_profiler_astar_fac")
24792487
.help(
24802488
"Controls the directedness of the timing-driven router's exploration"

vpr/src/base/read_options.h

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

212212
/* Timing-driven router options only */
213213
argparse::ArgValue<float> astar_fac;
214+
argparse::ArgValue<float> astar_offset;
214215
argparse::ArgValue<float> router_profiler_astar_fac;
215216
argparse::ArgValue<float> max_criticality;
216217
argparse::ArgValue<float> criticality_exp;

vpr/src/base/vpr_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,8 @@ struct t_placer_opts {
13301330
* an essentially breadth-first search, astar_fac = 1 is near *
13311331
* the usual astar algorithm and astar_fac > 1 are more *
13321332
* aggressive. *
1333+
* astar_offset: factor used to offset the expected future costs to *
1334+
* target in the timing_driven router. *
13331335
* max_criticality: The maximum criticality factor (from 0 to 1) any sink *
13341336
* will ever have (i.e. clip criticality to this number). *
13351337
* criticality_exp: Set criticality to (path_length(sink) / longest_path) ^ *
@@ -1418,6 +1420,7 @@ struct t_router_opts {
14181420
enum e_router_algorithm router_algorithm;
14191421
enum e_base_cost_type base_cost_type;
14201422
float astar_fac;
1423+
float astar_offset;
14211424
float router_profiler_astar_fac;
14221425
float max_criticality;
14231426
float criticality_exp;

vpr/src/place/timing_place_lookup.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,8 @@ void OverrideDelayModel::compute_override_delay_model(
11881188
RouterDelayProfiler& route_profiler,
11891189
const t_router_opts& router_opts) {
11901190
t_router_opts router_opts2 = router_opts;
1191-
router_opts2.astar_fac = 0.;
1191+
router_opts2.astar_fac = 0.f;
1192+
router_opts2.astar_offset = 0.f;
11921193

11931194
//Look at all the direct connections that exist, and add overrides to delay model
11941195
auto& device_ctx = g_vpr_ctx.device();

vpr/src/route/connection_router.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "connection_router.h"
2+
#include <algorithm>
23
#include "rr_graph.h"
34

45
#include "binary_heap.h"
@@ -663,8 +664,10 @@ float ConnectionRouter<Heap>::compute_node_cost_using_rcv(const t_conn_cost_para
663664
float expected_total_delay_cost;
664665
float expected_total_cong_cost;
665666

666-
float expected_total_cong = cost_params.astar_fac * expected_cong + backwards_cong;
667-
float expected_total_delay = cost_params.astar_fac * expected_delay + backwards_delay;
667+
float scaled_shifted_cong = cost_params.astar_fac * std::max(0.f, expected_cong - cost_params.astar_offset);
668+
float scaled_shifted_delay = cost_params.astar_fac * std::max(0.f, expected_delay - cost_params.astar_offset);
669+
float expected_total_cong = scaled_shifted_cong + backwards_cong;
670+
float expected_total_delay = scaled_shifted_delay + backwards_delay;
668671

669672
//If budgets specified calculate cost as described by RCV paper:
670673
// R. Fung, V. Betz and W. Chow, "Slack Allocation and Routing to Improve FPGA Timing While
@@ -816,7 +819,7 @@ void ConnectionRouter<Heap>::evaluate_timing_driven_node_costs(t_heap* to,
816819
rr_node_arch_name(target_node, is_flat_).c_str(),
817820
describe_rr_node(device_ctx.rr_graph, device_ctx.grid, device_ctx.rr_indexed_data, target_node, is_flat_).c_str(),
818821
expected_cost, to->R_upstream);
819-
total_cost += to->backward_path_cost + cost_params.astar_fac * expected_cost;
822+
total_cost += to->backward_path_cost + cost_params.astar_fac * std::max(0.f, expected_cost - cost_params.astar_offset);
820823
}
821824
to->cost = total_cost;
822825
}
@@ -911,12 +914,10 @@ void ConnectionRouter<Heap>::add_route_tree_node_to_heap(
911914

912915
if (!rcv_path_manager.is_enabled()) {
913916
// tot_cost = backward_path_cost + cost_params.astar_fac * expected_cost;
917+
float expected_cost = router_lookahead_.get_expected_cost(inode, target_node, cost_params, R_upstream);
914918
float tot_cost = backward_path_cost
915919
+ cost_params.astar_fac
916-
* router_lookahead_.get_expected_cost(inode,
917-
target_node,
918-
cost_params,
919-
R_upstream);
920+
* std::max(0.f, expected_cost - cost_params.astar_offset);
920921
VTR_LOGV_DEBUG(router_debug_, " Adding node %8d to heap from init route tree with cost %g (%s)\n",
921922
inode,
922923
tot_cost,

vpr/src/route/connection_router_interface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct t_conn_delay_budget {
2323
struct t_conn_cost_params {
2424
float criticality = 1.;
2525
float astar_fac = 1.2;
26+
float astar_offset = 0.f;
2627
float bend_cost = 1.;
2728
float pres_fac = 1.;
2829
const t_conn_delay_budget* delay_budget = nullptr;

vpr/src/route/route_net.tpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ inline NetResultFlags route_net(ConnectionRouter& router,
139139
t_conn_delay_budget conn_delay_budget;
140140
t_conn_cost_params cost_params;
141141
cost_params.astar_fac = router_opts.astar_fac;
142+
cost_params.astar_offset = router_opts.astar_offset;
142143
cost_params.bend_cost = router_opts.bend_cost;
143144
cost_params.pres_fac = pres_fac;
144145
cost_params.delay_budget = ((budgeting_inf.if_set()) ? &conn_delay_budget : nullptr);

vpr/src/route/router_delay_profiling.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ bool RouterDelayProfiler::calculate_delay(RRNodeId source_node,
9595
t_conn_cost_params cost_params;
9696
cost_params.criticality = 1.;
9797
cost_params.astar_fac = router_opts.router_profiler_astar_fac;
98+
cost_params.astar_offset = router_opts.astar_offset;
9899
cost_params.bend_cost = router_opts.bend_cost;
99100

100101
route_budgets budgeting_inf(net_list_, is_flat_);
@@ -164,6 +165,7 @@ vtr::vector<RRNodeId, float> calculate_all_path_delays_from_rr_node(RRNodeId src
164165
t_conn_cost_params cost_params;
165166
cost_params.criticality = 1.;
166167
cost_params.astar_fac = router_opts.astar_fac;
168+
cost_params.astar_offset = router_opts.astar_offset;
167169
cost_params.bend_cost = router_opts.bend_cost;
168170
/* This function is called during placement. Thus, the flat routing option should be disabled. */
169171
//TODO: Placement is run with is_flat=false. However, since is_flat is passed, det_routing_arch should

vpr/test/test_connection_router.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ static float do_one_route(RRNodeId source_node,
4141
t_conn_cost_params cost_params;
4242
cost_params.criticality = router_opts.max_criticality;
4343
cost_params.astar_fac = router_opts.astar_fac;
44+
cost_params.astar_offset = router_opts.astar_offset;
4445
cost_params.bend_cost = router_opts.bend_cost;
4546

4647
const Netlist<>& net_list = is_flat ? (const Netlist<>&)g_vpr_ctx.atom().nlist : (const Netlist<>&)g_vpr_ctx.clustering().clb_nlist;

0 commit comments

Comments
 (0)