Skip to content

Commit e09a891

Browse files
committed
Merge branch 'master' of github.com:verilog-to-routing/vtr-verilog-to-routing
2 parents de628a8 + 4d86496 commit e09a891

File tree

6 files changed

+70
-5
lines changed

6 files changed

+70
-5
lines changed

vpr/src/base/SetupVPR.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ static void SetupRouterOpts(const t_options& Options, t_router_opts *RouterOpts)
363363
RouterOpts->router_debug_sink_rr = Options.router_debug_sink_rr;
364364
RouterOpts->lookahead_type = Options.router_lookahead_type;
365365
RouterOpts->max_convergence_count = Options.router_max_convergence_count;
366+
RouterOpts->reconvergence_cpd_threshold = Options.router_reconvergence_cpd_threshold;
366367
}
367368

368369
static void SetupAnnealSched(const t_options& Options,

vpr/src/base/read_options.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,14 @@ static argparse::ArgumentParser create_arg_parser(std::string prog_name, t_optio
11791179
.default_value("1")
11801180
.show_in(argparse::ShowIn::HELP_ONLY);
11811181

1182+
route_timing_grp.add_argument(args.router_reconvergence_cpd_threshold, "--router_reconvergence_cpd_threshold")
1183+
.help("Specifies the minimum potential CPD improvement for which the router will"
1184+
" continue to attempt re-convergent routing."
1185+
" For example, a value of 0.99 means the router will not give up on reconvergent"
1186+
" routing if it thinks a > 1% CPD reduction is possible.")
1187+
.default_value("0.99")
1188+
.show_in(argparse::ShowIn::HELP_ONLY);
1189+
11821190
auto& analysis_grp = parser.add_argument_group("analysis options");
11831191

11841192
analysis_grp.add_argument<bool,ParseOnOff>(args.full_stats, "--full_stats")

vpr/src/base/read_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ struct t_options {
122122
argparse::ArgValue<int> router_debug_sink_rr;
123123
argparse::ArgValue<e_router_lookahead> router_lookahead_type;
124124
argparse::ArgValue<int> router_max_convergence_count;
125+
argparse::ArgValue<float> router_reconvergence_cpd_threshold;
125126

126127
/* Analysis options */
127128
argparse::ArgValue<bool> full_stats;

vpr/src/base/vpr_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ struct t_router_opts {
961961
int router_debug_sink_rr;
962962
e_router_lookahead lookahead_type;
963963
int max_convergence_count;
964+
float reconvergence_cpd_threshold;
964965
};
965966

966967
struct t_analysis_opts {

vpr/src/route/route_timing.cpp

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ static bool is_better_quality_routing(const vtr::vector<ClusterNetId,t_traceback
253253
const WirelengthInfo& wirelength_info,
254254
std::shared_ptr<const SetupHoldTimingInfo> timing_info);
255255

256+
static bool early_reconvergence_exit_heuristic(const t_router_opts& router_opts,
257+
int itry_since_last_convergence,
258+
std::shared_ptr<const SetupHoldTimingInfo> timing_info,
259+
const RoutingMetrics& best_routing_metrics);
260+
256261
/************************ Subroutine definitions *****************************/
257262
bool try_timing_driven_route(t_router_opts router_opts,
258263
vtr::vector_map<ClusterNetId, float *> &net_delay,
@@ -357,6 +362,7 @@ bool try_timing_driven_route(t_router_opts router_opts,
357362
float prev_iter_cumm_time = 0;
358363
vtr::Timer iteration_timer;
359364
int num_net_bounding_boxes_updated = 0;
365+
int itry_since_last_convergence = -1;
360366
for (itry = 1; itry <= router_opts.max_router_iterations; ++itry) {
361367

362368
RouterStats router_iteration_stats;
@@ -381,6 +387,10 @@ bool try_timing_driven_route(t_router_opts router_opts,
381387
route_timing_info = make_constant_timing_info(0.);
382388
}
383389

390+
if (itry_since_last_convergence >= 0) {
391+
++itry_since_last_convergence;
392+
}
393+
384394
/*
385395
* Route each net
386396
*/
@@ -499,20 +509,33 @@ bool try_timing_driven_route(t_router_opts router_opts,
499509
}
500510

501511
//Decrease pres_fac so that criticl connections will take more direct routes
502-
pres_fac = router_opts.initial_pres_fac;
512+
//Note that we use first_iter_pres_fac here (typically zero), and switch to
513+
//use initial_pres_fac on the next iteration.
514+
pres_fac = router_opts.first_iter_pres_fac;
503515

504516
//Reduce timing tolerances to re-route more delay-suboptimal signals
505-
connections_inf.set_connection_criticality_tolerance(0.8);
517+
connections_inf.set_connection_criticality_tolerance(0.7);
506518
connections_inf.set_connection_delay_tolerance(1.01);
507519

508520
++legal_convergence_count;
521+
itry_since_last_convergence = 0;
509522

510523
VTR_ASSERT(routing_is_successful);
511524
}
512525

513-
//Have we converged the maximum number of times, or did not make any changes?
526+
if (itry_since_last_convergence == 1) {
527+
//We used first_iter_pres_fac when we started routing again
528+
//after the first routing convergence. Since that is often zero,
529+
//we want to set pres_fac to a reasonable (i.e. typically non-zero)
530+
//value afterwards -- so it grows when multiplied by pres_fac_mult
531+
pres_fac = router_opts.initial_pres_fac;
532+
}
533+
534+
//Have we converged the maximum number of times, did not make any changes, or does it seem
535+
//unlikely additional convergences will improve QoR?
514536
if (legal_convergence_count >= router_opts.max_convergence_count
515-
|| router_iteration_stats.connections_routed == 0) {
537+
|| router_iteration_stats.connections_routed == 0
538+
|| early_reconvergence_exit_heuristic(router_opts, itry_since_last_convergence, timing_info, best_routing_metrics)) {
516539
break; //Done routing
517540
}
518541

@@ -526,7 +549,7 @@ bool try_timing_driven_route(t_router_opts router_opts,
526549

527550
//Estimate at what iteration we will converge to a legal routing
528551
if (overuse_info.overused_nodes() > ROUTING_PREDICTOR_MIN_ABSOLUTE_OVERUSE_THRESHOLD) {
529-
//Only abort if we have a significant number of overused resources
552+
//Only consider aborting if we have a significant number of overused resources
530553

531554
if (!std::isnan(est_success_iteration) && est_success_iteration > abort_iteration_threshold) {
532555
VTR_LOG("Routing aborted, the predicted iteration for a successful route (%.1f) is too high.\n", est_success_iteration);
@@ -2516,3 +2539,26 @@ static bool is_better_quality_routing(const vtr::vector<ClusterNetId,t_traceback
25162539
//Finally, wirelength tie breaker
25172540
return wirelength_info.used_wirelength() < best_routing_metrics.used_wirelength;
25182541
}
2542+
2543+
static bool early_reconvergence_exit_heuristic(const t_router_opts& router_opts,
2544+
int itry_since_last_convergence,
2545+
std::shared_ptr<const SetupHoldTimingInfo> timing_info,
2546+
const RoutingMetrics& best_routing_metrics) {
2547+
//Give-up on reconvergent routing if the CPD improvement after the
2548+
//first iteration since convergence is small, compared to the best
2549+
//CPD seen so far
2550+
if (itry_since_last_convergence == 1) {
2551+
float cpd_ratio = timing_info->setup_worst_negative_slack() / best_routing_metrics.sWNS;
2552+
2553+
//Give up if we see less than a 1% CPD improvement,
2554+
//after reducing pres_fac. Typically larger initial
2555+
//improvements are needed to see an actual improvement
2556+
//in final legal routing quality.
2557+
if (cpd_ratio >= router_opts.reconvergence_cpd_threshold) {
2558+
VTR_LOG("Giving up routing since additional routing convergences seem unlikely to improve quality (CPD ratio: %g)\n", cpd_ratio);
2559+
return true; //Potential CPD improvement is small, don't spend run-time trying to improve it
2560+
}
2561+
}
2562+
2563+
return false; //Don't give up
2564+
}

vtr_flow/scripts/run_vtr_flow.pl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
my $odin_adder_config_path = "default";
120120
my $use_odin_xml_config = 1;
121121
my $relax_W_factor = 1.3;
122+
my $crit_path_router_iterations = undef;
122123

123124

124125
##########
@@ -206,6 +207,9 @@
206207
elsif ( $token eq "-relax_W_factor" ){
207208
$relax_W_factor = shift(@ARGV);
208209
}
210+
elsif ( $token eq "-crit_path_router_iterations" ){
211+
$crit_path_router_iterations = shift(@ARGV);
212+
}
209213
# else forward the argument
210214
else {
211215
push @forwarded_vpr_args, $token;
@@ -873,6 +877,10 @@
873877
push(@relaxed_W_extra_vpr_args, ("--route"));
874878
push(@relaxed_W_extra_vpr_args, ("--route_chan_width", "$relaxed_W"));
875879

880+
if (defined $crit_path_router_iterations) {
881+
push(@relaxed_W_extra_vpr_args, ("--max_router_iterations", "$crit_path_router_iterations"));
882+
}
883+
876884
my $relaxed_W_log_file = "vpr.crit_path.out";
877885
$q = run_vpr({
878886
arch_name => $architecture_file_name,

0 commit comments

Comments
 (0)