Skip to content

Commit 20f5803

Browse files
[AP][DP] Added Option to Scale Init T in Annealer
Since the AP flow produces an initial placement that has 4x improved estimated wirelength and 2x improved CPD, the initial temperature of the annealer is too high. From experimentation, I have found that reducing the initial temperature in half improves quality slightly and reduces runtime. Added an option to the Placer to scale up or down the initial temperature. The default flow just sets this scale to 1.0, but the AP flow sets this scale to 0.5 currently. I have also exposed this option to the command-line so this option can be swept more easily.
1 parent 31cbe66 commit 20f5803

File tree

12 files changed

+62
-4
lines changed

12 files changed

+62
-4
lines changed

doc/src/vpr/command_line_usage.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,21 @@ If any of init_t, exit_t or alpha_t is specified, the user schedule, with a fixe
810810

811811
**Default:** ``circuit``
812812

813+
.. option:: --anneal_auto_init_t_scale <float>
814+
815+
A scale on the starting temperature of the anneal for the automatic annealing
816+
schedule.
817+
818+
When in the automatic annealing schedule, the annealer will select a good
819+
initial temperature based on the quality of the initial placement. This option
820+
allows you to scale that initial temperature up or down. Increasing this number
821+
will increase the initial temperature which will have the annealer potentially
822+
explore more of the space at the expense of run time. Depending on the quality
823+
of the initial placement, this may improve or hurt the quality of the final
824+
placement.
825+
826+
**Default:** ``1.0``
827+
813828
.. option:: --init_t <float>
814829

815830
The starting temperature of the anneal for the manual annealing schedule.

vpr/src/analytical_place/detailed_placer.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ AnnealerDetailedPlacer::AnnealerDetailedPlacer(const BlkLocRegistry& curr_cluste
7575
}
7676
}
7777

78+
// The solution produced by the AP flow is significantly better than the
79+
// initial placement solution produced by the initial placer in the default
80+
// flow. Even though the annealer auto-selects its initial temperature based
81+
// on the quality of the placement, we found that the initial temperatute was
82+
// still too high and it was hurting quality. This scales down the initial
83+
// temperature auto-selected by the annealer to prevent this and improve
84+
// runtime.
85+
float anneal_auto_init_t_scale = vpr_setup.PlacerOpts.place_auto_init_t_scale * 0.5f;
86+
7887
placer_ = std::make_unique<Placer>((const Netlist<>&)clustered_netlist,
7988
curr_clustered_placement,
8089
vpr_setup.PlacerOpts,
@@ -84,6 +93,7 @@ AnnealerDetailedPlacer::AnnealerDetailedPlacer(const BlkLocRegistry& curr_cluste
8493
netlist_pin_lookup_,
8594
FlatPlacementInfo(),
8695
place_delay_model,
96+
anneal_auto_init_t_scale,
8797
g_vpr_ctx.placement().cube_bb,
8898
false /*is_flat*/,
8999
false /*quiet*/);

vpr/src/base/CheckSetup.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ void CheckSetup(const t_packer_opts& packer_opts,
6969
NUM_PL_MOVE_TYPES);
7070
}
7171

72+
if (placer_opts.place_auto_init_t_scale < 0.0) {
73+
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
74+
"Cannot have negative annealer auto initial temperature scale.\n");
75+
}
76+
7277
// Rules for doing Analytical Placement
7378
if (ap_opts.doAP) {
7479
// Make sure that the --place option was not set.

vpr/src/base/SetupVPR.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,8 @@ static void SetupPlacerOpts(const t_options& Options, t_placer_opts* PlacerOpts)
703703

704704
PlacerOpts->placer_debug_block = Options.placer_debug_block;
705705
PlacerOpts->placer_debug_net = Options.placer_debug_net;
706+
707+
PlacerOpts->place_auto_init_t_scale = Options.place_auto_init_t_scale.value();
706708
}
707709

708710
static void SetupAnalysisOpts(const t_options& Options, t_analysis_opts& analysis_opts) {

vpr/src/base/read_options.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,6 +2200,21 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio
22002200
.default_value("circuit")
22012201
.show_in(argparse::ShowIn::HELP_ONLY);
22022202

2203+
place_grp.add_argument(args.place_auto_init_t_scale, "--anneal_auto_init_t_scale")
2204+
.help(
2205+
"A scale on the starting temperature of the anneal for the automatic annealing "
2206+
"schedule.\n"
2207+
"\n"
2208+
"When in the automatic annealing schedule, the annealer will select a good "
2209+
"initial temperature based on the quality of the initial placement. This option "
2210+
"allows you to scale that initial temperature up or down. Increasing this number "
2211+
"will increase the initial temperature which will have the annealer potentially "
2212+
"explore more of the space at the expense of run time. Depending on the quality "
2213+
"of the initial placement, this may improve or hurt the quality of the final "
2214+
"placement.")
2215+
.default_value("1.0")
2216+
.show_in(argparse::ShowIn::HELP_ONLY);
2217+
22032218
place_grp.add_argument(args.PlaceInitT, "--init_t")
22042219
.help("Initial temperature for manual annealing schedule")
22052220
.default_value("100.0")

vpr/src/base/read_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ struct t_options {
129129
argparse::ArgValue<int> Seed;
130130
argparse::ArgValue<bool> ShowPlaceTiming;
131131
argparse::ArgValue<float> PlaceInnerNum;
132+
argparse::ArgValue<float> place_auto_init_t_scale;
132133
argparse::ArgValue<float> PlaceInitT;
133134
argparse::ArgValue<float> PlaceExitT;
134135
argparse::ArgValue<float> PlaceAlphaT;

vpr/src/base/vpr_types.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,8 +1004,9 @@ enum class e_move_type;
10041004
* @param place_constraint_subtile
10051005
* True if subtiles should be specified when printing floorplan
10061006
* constraints. False if not.
1007-
*
1008-
*
1007+
* @param place_auto_init_t_scale
1008+
* When the annealer is using the automatic schedule, this option
1009+
* scales the initial temperature selected.
10091010
*/
10101011
struct t_placer_opts {
10111012
t_place_algorithm place_algorithm;
@@ -1077,6 +1078,8 @@ struct t_placer_opts {
10771078
std::string allowed_tiles_for_delay_model;
10781079

10791080
e_place_delta_delay_algorithm place_delta_delay_matrix_calculation_method;
1081+
1082+
float place_auto_init_t_scale;
10801083
};
10811084

10821085
/******************************************************************

vpr/src/place/annealer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ PlacementAnnealer::PlacementAnnealer(const t_placer_opts& placer_opts,
206206
PlacerSetupSlacks* setup_slacks,
207207
SetupTimingInfo* timing_info,
208208
NetPinTimingInvalidator* pin_timing_invalidator,
209+
float auto_init_t_scale,
209210
int move_lim)
210211
: placer_opts_(placer_opts)
211212
, placer_state_(placer_state)
@@ -285,7 +286,8 @@ PlacementAnnealer::PlacementAnnealer(const t_placer_opts& placer_opts,
285286
move_type_stats_.rejected_moves.resize({device_ctx.logical_block_types.size(), (int)e_move_type::NUMBER_OF_AUTO_MOVES}, 0);
286287

287288
// Update the starting temperature for placement annealing to a more appropriate value
288-
annealing_state_.t = estimate_starting_temperature_();
289+
VTR_ASSERT_SAFE_MSG(auto_init_t_scale >= 0, "Initial temperature scale cannot be negative.");
290+
annealing_state_.t = estimate_starting_temperature_() * auto_init_t_scale;
289291
}
290292

291293
float PlacementAnnealer::estimate_starting_temperature_() {

vpr/src/place/annealer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ class PlacementAnnealer {
185185
PlacerSetupSlacks* setup_slacks,
186186
SetupTimingInfo* timing_info,
187187
NetPinTimingInvalidator* pin_timing_invalidator,
188+
float auto_init_t_scale,
188189
int move_lim);
189190

190191
/**

vpr/src/place/place.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ void try_place(const Netlist<>& net_list,
112112
ClusteredPinAtomPinsLookup netlist_pin_lookup(cluster_ctx.clb_nlist, atom_ctx.netlist(), pb_gpin_lookup);
113113

114114
Placer placer(net_list, {}, placer_opts, analysis_opts, noc_opts, pb_gpin_lookup, netlist_pin_lookup,
115-
flat_placement_info, place_delay_model, mutable_placement.cube_bb, is_flat, /*quiet=*/false);
115+
flat_placement_info, place_delay_model, placer_opts.place_auto_init_t_scale,
116+
mutable_placement.cube_bb, is_flat, /*quiet=*/false);
116117

117118
placer.place();
118119

0 commit comments

Comments
 (0)