Skip to content

Commit 7840430

Browse files
Merge pull request #3160 from AlexandreSinger/feature-ap-anneal_init_t
[AP][DP] Added Option to Scale Init T in Annealer
2 parents fd426de + f7c570a commit 7840430

File tree

12 files changed

+68
-4
lines changed

12 files changed

+68
-4
lines changed

doc/src/vpr/command_line_usage.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,22 @@ 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 by multiplying the
821+
initial temperature by the given scale. Increasing this number
822+
will increase the initial temperature which will have the annealer potentially
823+
explore more of the space at the expense of run time. Depending on the quality
824+
of the initial placement, this may improve or hurt the quality of the final
825+
placement.
826+
827+
**Default:** ``1.0``
828+
813829
.. option:: --init_t <float>
814830

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

vpr/src/analytical_place/detailed_placer.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,19 @@ 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+
// Here we still scale by whatever the user passed in to scale the initial
86+
// temperature by, but we also scale it down further. This allows AP to scale
87+
// the initial temperature down by default, while still allowing the user
88+
// some control.
89+
float anneal_auto_init_t_scale = vpr_setup.PlacerOpts.place_auto_init_t_scale * 0.5f;
90+
7891
placer_ = std::make_unique<Placer>((const Netlist<>&)clustered_netlist,
7992
curr_clustered_placement,
8093
vpr_setup.PlacerOpts,
@@ -84,6 +97,7 @@ AnnealerDetailedPlacer::AnnealerDetailedPlacer(const BlkLocRegistry& curr_cluste
8497
netlist_pin_lookup_,
8598
FlatPlacementInfo(),
8699
place_delay_model,
100+
anneal_auto_init_t_scale,
87101
g_vpr_ctx.placement().cube_bb,
88102
false /*is_flat*/,
89103
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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,6 +2200,22 @@ 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 by multiplying the "
2211+
"initial temperature by the given scale. Increasing this number "
2212+
"will increase the initial temperature which will have the annealer potentially "
2213+
"explore more of the space at the expense of run time. Depending on the quality "
2214+
"of the initial placement, this may improve or hurt the quality of the final "
2215+
"placement.")
2216+
.default_value("1.0")
2217+
.show_in(argparse::ShowIn::HELP_ONLY);
2218+
22032219
place_grp.add_argument(args.PlaceInitT, "--init_t")
22042220
.help("Initial temperature for manual annealing schedule")
22052221
.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

vpr/src/place/placer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Placer::Placer(const Netlist<>& net_list,
3535
const ClusteredPinAtomPinsLookup& netlist_pin_lookup,
3636
const FlatPlacementInfo& flat_placement_info,
3737
std::shared_ptr<PlaceDelayModel> place_delay_model,
38+
float anneal_auto_init_t_scale,
3839
bool cube_bb,
3940
bool is_flat,
4041
bool quiet)
@@ -152,6 +153,7 @@ Placer::Placer(const Netlist<>& net_list,
152153
annealer_ = std::make_unique<PlacementAnnealer>(placer_opts_, placer_state_, place_macros, costs_, net_cost_handler_, noc_cost_handler_,
153154
noc_opts_, rng_, std::move(move_generator), std::move(move_generator2), place_delay_model_.get(),
154155
placer_criticalities_.get(), placer_setup_slacks_.get(), timing_info_.get(), pin_timing_invalidator_.get(),
156+
anneal_auto_init_t_scale,
155157
move_lim);
156158
}
157159

vpr/src/place/placer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class Placer {
4949
const ClusteredPinAtomPinsLookup& netlist_pin_lookup,
5050
const FlatPlacementInfo& flat_placement_info,
5151
std::shared_ptr<PlaceDelayModel> place_delay_model,
52+
float anneal_auto_init_t_scale,
5253
bool cube_bb,
5354
bool is_flat,
5455
bool quiet);

0 commit comments

Comments
 (0)