Skip to content

Commit 153337e

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 1fd6514 commit 153337e

11 files changed

+29
-11
lines changed

vpr/src/base/SetupVPR.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ static void SetupRoutingArch(const t_arch& Arch,
410410
static void SetupRouterOpts(const t_options& Options, t_router_opts* RouterOpts) {
411411
RouterOpts->do_check_rr_graph = Options.check_rr_graph;
412412
RouterOpts->astar_fac = Options.astar_fac;
413+
RouterOpts->astar_offset = Options.astar_offset;
413414
RouterOpts->router_profiler_astar_fac = Options.router_profiler_astar_fac;
414415
RouterOpts->post_target_prune_fac = Options.post_target_prune_fac;
415416
RouterOpts->post_target_prune_offset = Options.post_target_prune_offset;

vpr/src/base/ShowSetup.cpp

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

339339
if (TIMING_DRIVEN == RouterOpts.router_algorithm) {
340340
VTR_LOG("RouterOpts.astar_fac: %f\n", RouterOpts.astar_fac);
341+
VTR_LOG("RouterOpts.astar_offset: %f\n", RouterOpts.astar_offset);
341342
VTR_LOG("RouterOpts.router_profiler_astar_fac: %f\n", RouterOpts.router_profiler_astar_fac);
342343
VTR_LOG("RouterOpts.criticality_exp: %f\n", RouterOpts.criticality_exp);
343344
VTR_LOG("RouterOpts.max_criticality: %f\n", RouterOpts.max_criticality);
@@ -482,6 +483,7 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
482483
VTR_LOG("RouterOpts.exit_after_first_routing_iteration: %s\n", RouterOpts.exit_after_first_routing_iteration ? "true" : "false");
483484
if (TIMING_DRIVEN == RouterOpts.router_algorithm) {
484485
VTR_LOG("RouterOpts.astar_fac: %f\n", RouterOpts.astar_fac);
486+
VTR_LOG("RouterOpts.astar_offset: %f\n", RouterOpts.astar_offset);
485487
VTR_LOG("RouterOpts.router_profiler_astar_fac: %f\n", RouterOpts.router_profiler_astar_fac);
486488
VTR_LOG("RouterOpts.post_target_prune_fac: %f\n", RouterOpts.post_target_prune_fac);
487489
VTR_LOG("RouterOpts.post_target_prune_offset: %f\n", RouterOpts.post_target_prune_offset);

vpr/src/base/read_options.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2477,6 +2477,14 @@ argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& arg
24772477
.default_value("1.2")
24782478
.show_in(argparse::ShowIn::HELP_ONLY);
24792479

2480+
route_timing_grp.add_argument(args.astar_offset, "--astar_offset")
2481+
.help(
2482+
"Controls the directedness of the timing-driven router's exploration."
2483+
" It is a subtractive adjustment to the lookahead heuristic."
2484+
" Values between 0 and 1e-9 are resonable; higher values may increase quality at the expense of run-time.")
2485+
.default_value("0.0")
2486+
.show_in(argparse::ShowIn::HELP_ONLY);
2487+
24802488
route_timing_grp.add_argument(args.router_profiler_astar_fac, "--router_profiler_astar_fac")
24812489
.help(
24822490
"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
@@ -205,6 +205,7 @@ struct t_options {
205205

206206
/* Timing-driven router options only */
207207
argparse::ArgValue<float> astar_fac;
208+
argparse::ArgValue<float> astar_offset;
208209
argparse::ArgValue<float> router_profiler_astar_fac;
209210
argparse::ArgValue<float> post_target_prune_fac;
210211
argparse::ArgValue<float> post_target_prune_offset;

vpr/src/base/vpr_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,8 @@ struct t_placer_opts {
13321332
* an essentially breadth-first search, astar_fac = 1 is near *
13331333
* the usual astar algorithm and astar_fac > 1 are more *
13341334
* aggressive. *
1335+
* astar_offset: Offset that is subtracted from the lookahead (expected *
1336+
* future costs) in the timing-driven router. *
13351337
* max_criticality: The maximum criticality factor (from 0 to 1) any sink *
13361338
* will ever have (i.e. clip criticality to this number). *
13371339
* criticality_exp: Set criticality to (path_length(sink) / longest_path) ^ *
@@ -1419,6 +1421,7 @@ struct t_router_opts {
14191421
enum e_router_algorithm router_algorithm;
14201422
enum e_base_cost_type base_cost_type;
14211423
float astar_fac;
1424+
float astar_offset;
14221425
float router_profiler_astar_fac;
14231426
float post_target_prune_fac;
14241427
float post_target_prune_offset;

vpr/src/place/timing_place_lookup.cpp

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

11921193
//Look at all the direct connections that exist, and add overrides to delay model
11931194
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 "bucket.h"
67
#include "rr_graph_fwd.h"
@@ -695,8 +696,8 @@ float ConnectionRouter<Heap>::compute_node_cost_using_rcv(const t_conn_cost_para
695696
float expected_total_delay_cost;
696697
float expected_total_cong_cost;
697698

698-
float expected_total_cong = cost_params.astar_fac * expected_cong + backwards_cong;
699-
float expected_total_delay = cost_params.astar_fac * expected_delay + backwards_delay;
699+
float expected_total_cong = expected_cong + backwards_cong;
700+
float expected_total_delay = expected_delay + backwards_delay;
700701

701702
//If budgets specified calculate cost as described by RCV paper:
702703
// R. Fung, V. Betz and W. Chow, "Slack Allocation and Routing to Improve FPGA Timing While
@@ -835,7 +836,7 @@ void ConnectionRouter<Heap>::evaluate_timing_driven_node_costs(t_heap* to,
835836
target_node,
836837
cost_params,
837838
to->R_upstream);
838-
total_cost += to->backward_path_cost + cost_params.astar_fac * expected_cost;
839+
total_cost += to->backward_path_cost + cost_params.astar_fac * std::max(0.f, expected_cost - cost_params.astar_offset);
839840

840841
// if (rcv_path_manager.is_enabled() && to->path_data != nullptr) {
841842
// to->path_data->backward_delay += cost_params.criticality * Tdel;
@@ -952,12 +953,8 @@ void ConnectionRouter<Heap>::add_route_tree_node_to_heap(
952953

953954
if (!rcv_path_manager.is_enabled()) {
954955
// tot_cost = backward_path_cost + cost_params.astar_fac * expected_cost;
955-
float tot_cost = backward_path_cost
956-
+ cost_params.astar_fac
957-
* router_lookahead_.get_expected_cost(inode,
958-
target_node,
959-
cost_params,
960-
R_upstream);
956+
float expected_cost = router_lookahead_.get_expected_cost(inode, target_node, cost_params, R_upstream);
957+
float tot_cost = backward_path_cost + cost_params.astar_fac * std::max(0.f, expected_cost - cost_params.astar_offset);
961958
VTR_LOGV_DEBUG(router_debug_, " Adding node %8d to heap from init route tree with cost %g (%s)\n",
962959
inode,
963960
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 post_target_prune_fac = 1.2f;
2728
float post_target_prune_offset = 0.f;
2829
float bend_cost = 1.;

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.post_target_prune_fac = router_opts.post_target_prune_fac;
143144
cost_params.post_target_prune_offset = router_opts.post_target_prune_offset;
144145
cost_params.bend_cost = router_opts.bend_cost;

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)