Skip to content

Commit e3ce4bc

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 36ed2b2 commit e3ce4bc

11 files changed

+29
-12
lines changed

vpr/src/base/SetupVPR.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ static void SetupRoutingArch(const t_arch& Arch,
423423
static void SetupRouterOpts(const t_options& Options, t_router_opts* RouterOpts) {
424424
RouterOpts->do_check_rr_graph = Options.check_rr_graph;
425425
RouterOpts->astar_fac = Options.astar_fac;
426+
RouterOpts->astar_offset = Options.astar_offset;
426427
RouterOpts->router_profiler_astar_fac = Options.router_profiler_astar_fac;
427428
RouterOpts->bb_factor = Options.bb_factor;
428429
RouterOpts->criticality_exp = Options.criticality_exp;

vpr/src/base/ShowSetup.cpp

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

383383
if (TIMING_DRIVEN == RouterOpts.router_algorithm) {
384384
VTR_LOG("RouterOpts.astar_fac: %f\n", RouterOpts.astar_fac);
385+
VTR_LOG("RouterOpts.astar_offset: %f\n", RouterOpts.astar_offset);
385386
VTR_LOG("RouterOpts.router_profiler_astar_fac: %f\n", RouterOpts.router_profiler_astar_fac);
386387
VTR_LOG("RouterOpts.criticality_exp: %f\n", RouterOpts.criticality_exp);
387388
VTR_LOG("RouterOpts.max_criticality: %f\n", RouterOpts.max_criticality);
@@ -735,4 +736,4 @@ static void ShowNocOpts(const t_noc_opts& NocOpts) {
735736
VTR_LOG("NocOpts.noc_sat_routing_num_workers: %d\n", NocOpts.noc_sat_routing_num_workers);
736737
VTR_LOG("NocOpts.noc_routing_algorithm: %s\n", NocOpts.noc_placement_file_name.c_str());
737738
VTR_LOG("\n");
738-
}
739+
}

vpr/src/base/read_options.cpp

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

2502+
route_timing_grp.add_argument(args.astar_offset, "--astar_offset")
2503+
.help(
2504+
"Controls the directedness of the timing-driven router's exploration."
2505+
" It is a subtractive adjustment to the lookahead heuristic."
2506+
" Values between 0 and 1e-9 are resonable; higher values may increase quality at the expense of run-time.")
2507+
.default_value("0.0")
2508+
.show_in(argparse::ShowIn::HELP_ONLY);
2509+
25022510
route_timing_grp.add_argument(args.router_profiler_astar_fac, "--router_profiler_astar_fac")
25032511
.help(
25042512
"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
@@ -220,6 +220,7 @@ struct t_options {
220220

221221
/* Timing-driven router options only */
222222
argparse::ArgValue<float> astar_fac;
223+
argparse::ArgValue<float> astar_offset;
223224
argparse::ArgValue<float> router_profiler_astar_fac;
224225
argparse::ArgValue<float> max_criticality;
225226
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
@@ -1343,6 +1343,8 @@ struct t_placer_opts {
13431343
* an essentially breadth-first search, astar_fac = 1 is near *
13441344
* the usual astar algorithm and astar_fac > 1 are more *
13451345
* aggressive. *
1346+
* astar_offset: Offset that is subtracted from the lookahead (expected *
1347+
* future costs) in the timing-driven router. *
13461348
* max_criticality: The maximum criticality factor (from 0 to 1) any sink *
13471349
* will ever have (i.e. clip criticality to this number). *
13481350
* criticality_exp: Set criticality to (path_length(sink) / longest_path) ^ *
@@ -1431,6 +1433,7 @@ struct t_router_opts {
14311433
enum e_router_algorithm router_algorithm;
14321434
enum e_base_cost_type base_cost_type;
14331435
float astar_fac;
1436+
float astar_offset;
14341437
float router_profiler_astar_fac;
14351438
float max_criticality;
14361439
float criticality_exp;

vpr/src/place/timing_place_lookup.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,8 @@ void OverrideDelayModel::compute_override_delay_model(
11901190
RouterDelayProfiler& route_profiler,
11911191
const t_router_opts& router_opts) {
11921192
t_router_opts router_opts2 = router_opts;
1193-
router_opts2.astar_fac = 0.;
1193+
router_opts2.astar_fac = 0.f;
1194+
router_opts2.astar_offset = 0.f;
11941195

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

vpr/src/route/connection_router.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "connection_router.h"
2-
#include "rr_graph.h"
32

3+
#include <algorithm>
4+
#include "rr_graph.h"
45
#include "binary_heap.h"
56
#include "four_ary_heap.h"
67
#include "bucket.h"
@@ -660,8 +661,8 @@ float ConnectionRouter<Heap>::compute_node_cost_using_rcv(const t_conn_cost_para
660661
float expected_total_delay_cost;
661662
float expected_total_cong_cost;
662663

663-
float expected_total_cong = cost_params.astar_fac * expected_cong + backwards_cong;
664-
float expected_total_delay = cost_params.astar_fac * expected_delay + backwards_delay;
664+
float expected_total_cong = expected_cong + backwards_cong;
665+
float expected_total_delay = expected_delay + backwards_delay;
665666

666667
//If budgets specified calculate cost as described by RCV paper:
667668
// R. Fung, V. Betz and W. Chow, "Slack Allocation and Routing to Improve FPGA Timing While
@@ -813,7 +814,7 @@ void ConnectionRouter<Heap>::evaluate_timing_driven_node_costs(t_heap* to,
813814
rr_node_arch_name(target_node, is_flat_).c_str(),
814815
describe_rr_node(device_ctx.rr_graph, device_ctx.grid, device_ctx.rr_indexed_data, target_node, is_flat_).c_str(),
815816
expected_cost, to->R_upstream);
816-
total_cost += to->backward_path_cost + cost_params.astar_fac * expected_cost;
817+
total_cost += to->backward_path_cost + cost_params.astar_fac * std::max(0.f, expected_cost - cost_params.astar_offset);
817818
}
818819
to->cost = total_cost;
819820
}
@@ -905,12 +906,8 @@ void ConnectionRouter<Heap>::add_route_tree_node_to_heap(
905906

906907
if (!rcv_path_manager.is_enabled()) {
907908
// tot_cost = backward_path_cost + cost_params.astar_fac * expected_cost;
908-
float tot_cost = backward_path_cost
909-
+ cost_params.astar_fac
910-
* router_lookahead_.get_expected_cost(inode,
911-
target_node,
912-
cost_params,
913-
R_upstream);
909+
float expected_cost = router_lookahead_.get_expected_cost(inode, target_node, cost_params, R_upstream);
910+
float tot_cost = backward_path_cost + cost_params.astar_fac * std::max(0.f, expected_cost - cost_params.astar_offset);
914911
VTR_LOGV_DEBUG(router_debug_, " Adding node %8d to heap from init route tree with cost %g (%s)\n",
915912
inode,
916913
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)