Skip to content

Commit efe7cc0

Browse files
authored
Merge pull request #2523 from verilog-to-routing/pres_fac_max
Set the maximum pres_fac
2 parents 486be09 + 24d69c0 commit efe7cc0

File tree

12 files changed

+80
-59
lines changed

12 files changed

+80
-59
lines changed

doc/src/vpr/command_line_usage.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,14 @@ VPR uses a negotiated congestion algorithm (based on Pathfinder) to perform rout
11631163

11641164
**Default:** ``1.3``
11651165

1166+
.. option:: --max_pres_fac <float>
1167+
1168+
Sets the maximum present overuse penalty factor that can ever result during routing. Should always be less than 1e25 or so to prevent overflow.
1169+
Smaller values may help prevent circuitous routing in difficult routing problems, but may increase
1170+
the number of routing iterations needed and hence runtime.
1171+
1172+
**Default:** ``1000.0``
1173+
11661174
.. option:: --acc_fac <float>
11671175

11681176
Specifies the accumulated overuse factor (historical congestion cost factor).

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 SetupRouterOpts(const t_options& Options, t_router_opts* RouterOpts)
423423
RouterOpts->min_incremental_reroute_fanout = Options.min_incremental_reroute_fanout;
424424
RouterOpts->incr_reroute_delay_ripup = Options.incr_reroute_delay_ripup;
425425
RouterOpts->pres_fac_mult = Options.pres_fac_mult;
426+
RouterOpts->max_pres_fac = Options.max_pres_fac;
426427
RouterOpts->route_type = Options.RouteType;
427428

428429
RouterOpts->full_stats = Options.full_stats;

vpr/src/base/ShowSetup.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
328328
VTR_LOG("RouterOpts.first_iter_pres_fac: %f\n", RouterOpts.first_iter_pres_fac);
329329
VTR_LOG("RouterOpts.initial_pres_fac: %f\n", RouterOpts.initial_pres_fac);
330330
VTR_LOG("RouterOpts.pres_fac_mult: %f\n", RouterOpts.pres_fac_mult);
331+
VTR_LOG("RouterOpts.max_pres_fac: %f\n", RouterOpts.max_pres_fac);
331332
VTR_LOG("RouterOpts.max_router_iterations: %d\n", RouterOpts.max_router_iterations);
332333
VTR_LOG("RouterOpts.min_incremental_reroute_fanout: %d\n", RouterOpts.min_incremental_reroute_fanout);
333334
VTR_LOG("RouterOpts.do_check_rr_graph: %s\n", RouterOpts.do_check_rr_graph ? "true" : "false");
@@ -473,6 +474,7 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
473474
VTR_LOG("RouterOpts.first_iter_pres_fac: %f\n", RouterOpts.first_iter_pres_fac);
474475
VTR_LOG("RouterOpts.initial_pres_fac: %f\n", RouterOpts.initial_pres_fac);
475476
VTR_LOG("RouterOpts.pres_fac_mult: %f\n", RouterOpts.pres_fac_mult);
477+
VTR_LOG("RouterOpts.max_pres_fac: %f\n", RouterOpts.max_pres_fac);
476478
VTR_LOG("RouterOpts.max_router_iterations: %d\n", RouterOpts.max_router_iterations);
477479
VTR_LOG("RouterOpts.min_incremental_reroute_fanout: %d\n", RouterOpts.min_incremental_reroute_fanout);
478480
VTR_LOG("RouterOpts.do_check_rr_graph: %s\n", RouterOpts.do_check_rr_graph ? "true" : "false");

vpr/src/base/read_options.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,6 +2333,11 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio
23332333
.default_value("1.3")
23342334
.show_in(argparse::ShowIn::HELP_ONLY);
23352335

2336+
route_grp.add_argument(args.max_pres_fac, "-max_pres_fac")
2337+
.help("Sets the maximum present overuse penalty factor")
2338+
.default_value("1000.0")
2339+
.show_in(argparse::ShowIn::HELP_ONLY);
2340+
23362341
route_grp.add_argument(args.acc_fac, "--acc_fac")
23372342
.help("Specifies the accumulated overuse factor (historical congestion cost factor)")
23382343
.default_value("1.0")

vpr/src/base/read_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ struct t_options {
187187
argparse::ArgValue<float> first_iter_pres_fac;
188188
argparse::ArgValue<float> initial_pres_fac;
189189
argparse::ArgValue<float> pres_fac_mult;
190+
argparse::ArgValue<float> max_pres_fac;
190191
argparse::ArgValue<float> acc_fac;
191192
argparse::ArgValue<int> bb_factor;
192193
argparse::ArgValue<e_base_cost_type> base_cost_type;

vpr/src/base/vpr_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,6 +1405,7 @@ struct t_router_opts {
14051405
float first_iter_pres_fac;
14061406
float initial_pres_fac;
14071407
float pres_fac_mult;
1408+
float max_pres_fac;
14081409
float acc_fac;
14091410
float bend_cost;
14101411
int max_router_iterations;

vpr/src/place/place.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,8 +1709,8 @@ static e_move_result try_swap(const t_annealing_state* state,
17091709
if (manual_move_enabled) {
17101710
#ifndef NO_GRAPHICS
17111711
create_move_outcome = manual_move_display_and_propose(manual_move_generator, blocks_affected, proposed_action.move_type, rlim, placer_opts, criticalities);
1712-
#else //NO_GRAPHICS
1713-
// Cast to void to explicitly avoid warning.
1712+
#else //NO_GRAPHICS
1713+
//Cast to void to explicitly avoid warning.
17141714
(void)manual_move_generator;
17151715
#endif //NO_GRAPHICS
17161716
} else if (router_block_move) {

vpr/src/route/route.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ bool route(const Netlist<>& net_list,
155155
VTR_ASSERT(router_lookahead != nullptr);
156156

157157
/* Routing parameters */
158-
float pres_fac = update_draw_pres_fac(router_opts.first_iter_pres_fac); /* Typically 0 -> ignore cong. */
158+
float pres_fac = router_opts.first_iter_pres_fac;
159+
update_draw_pres_fac(pres_fac); /* Typically 0 -> ignore cong. */
159160
int bb_fac = router_opts.bb_factor;
160161

161162
/* When routing conflicts are detected the bounding boxes are scaled
@@ -357,7 +358,8 @@ bool route(const Netlist<>& net_list,
357358
//Decrease pres_fac so that critical connections will take more direct routes
358359
//Note that we use first_iter_pres_fac here (typically zero), and switch to
359360
//use initial_pres_fac on the next iteration.
360-
pres_fac = update_draw_pres_fac(router_opts.first_iter_pres_fac);
361+
pres_fac = router_opts.first_iter_pres_fac;
362+
update_draw_pres_fac(pres_fac);
361363

362364
//Reduce timing tolerances to re-route more delay-suboptimal signals
363365
connections_inf.set_connection_criticality_tolerance(0.7);
@@ -374,7 +376,8 @@ bool route(const Netlist<>& net_list,
374376
//after the first routing convergence. Since that is often zero,
375377
//we want to set pres_fac to a reasonable (i.e. typically non-zero)
376378
//value afterwards -- so it grows when multiplied by pres_fac_mult
377-
pres_fac = update_draw_pres_fac(router_opts.initial_pres_fac);
379+
pres_fac = router_opts.initial_pres_fac;
380+
update_draw_pres_fac(pres_fac);
378381
}
379382

380383
//Have we converged the maximum number of times, did not make any changes, or does it seem
@@ -437,12 +440,13 @@ bool route(const Netlist<>& net_list,
437440

438441
//Update pres_fac
439442
if (itry == 1) {
440-
pres_fac = update_draw_pres_fac(router_opts.initial_pres_fac);
443+
pres_fac = router_opts.initial_pres_fac;
444+
update_draw_pres_fac(pres_fac);
441445
} else {
442446
pres_fac *= router_opts.pres_fac_mult;
443-
444-
/* Avoid overflow for high iteration counts, even if acc_cost is big */
445-
pres_fac = update_draw_pres_fac(std::min(pres_fac, static_cast<float>(HUGE_POSITIVE_FLOAT / 1e5)));
447+
pres_fac = std::min(pres_fac, router_opts.max_pres_fac);
448+
/* Set the maximum pres_fac to the value passed by the command line argument */
449+
update_draw_pres_fac(pres_fac);
446450

447451
// Increase short path criticality if it's having a hard time resolving hold violations due to congestion
448452
if (budgeting_inf.if_set()) {

vpr/src/route/route_utils.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,15 +507,16 @@ void try_graph(int width_fac,
507507
is_flat);
508508
}
509509

510-
float update_draw_pres_fac(float new_pres_fac) {
511510
#ifndef NO_GRAPHICS
512-
511+
void update_draw_pres_fac(const float new_pres_fac) {
512+
#else
513+
void update_draw_pres_fac(const float /*new_pres_fac*/) {
514+
#endif
515+
#ifndef NO_GRAPHICS
513516
// Only updates the drawing pres_fac if graphics is enabled
514517
get_draw_state_vars()->pres_fac = new_pres_fac;
515518

516519
#endif // NO_GRAPHICS
517-
518-
return new_pres_fac;
519520
}
520521

521522
#ifndef NO_GRAPHICS

vpr/src/route/route_utils.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,8 @@ void try_graph(int width_fac,
136136
int num_directs,
137137
bool is_flat);
138138

139-
/* This routine should take the new value of the present congestion factor
140-
* and propagate it to all the relevant data fields in the vpr flow.
141-
* Currently, it only updates the pres_fac used by the drawing functions */
142-
float update_draw_pres_fac(float new_pres_fac);
139+
/* This routine updates the pres_fac used by the drawing functions */
140+
void update_draw_pres_fac(const float new_pres_fac);
143141

144142
#ifndef NO_GRAPHICS
145143
/** Updates router iteration information and checks for router iteration and net id breakpoints

0 commit comments

Comments
 (0)