@@ -209,7 +209,8 @@ static e_move_result try_swap(const t_annealing_state* state,
209
209
t_swap_stats& swap_stats,
210
210
PlacerState& placer_state,
211
211
NetCostHandler& net_cost_handler,
212
- std::optional<NocCostHandler>& noc_cost_handler);
212
+ std::optional<NocCostHandler>& noc_cost_handler,
213
+ vtr::RngContainer& rng);
213
214
214
215
215
216
static void check_place (const t_placer_costs& costs,
@@ -250,7 +251,8 @@ static float starting_t(const t_annealing_state* state,
250
251
t_swap_stats& swap_stats,
251
252
PlacerState& placer_state,
252
253
NetCostHandler& net_cost_handler,
253
- std::optional<NocCostHandler>& noc_cost_handler);
254
+ std::optional<NocCostHandler>& noc_cost_handler,
255
+ vtr::RngContainer& rng);
254
256
255
257
static int count_connections ();
256
258
@@ -268,7 +270,7 @@ static void invalidate_affected_connections(
268
270
static float analyze_setup_slack_cost (const PlacerSetupSlacks* setup_slacks,
269
271
const PlacerState& placer_state);
270
272
271
- static e_move_result assess_swap (double delta_c, double t);
273
+ static e_move_result assess_swap (double delta_c, double t, vtr::RngContainer& rng );
272
274
273
275
static void update_placement_cost_normalization_factors (t_placer_costs* costs,
274
276
const t_placer_opts& placer_opts,
@@ -312,7 +314,8 @@ static void placement_inner_loop(const t_annealing_state* state,
312
314
t_swap_stats& swap_stats,
313
315
PlacerState& placer_state,
314
316
NetCostHandler& net_cost_handler,
315
- std::optional<NocCostHandler>& noc_cost_handler);
317
+ std::optional<NocCostHandler>& noc_cost_handler,
318
+ vtr::RngContainer& rng);
316
319
317
320
static void generate_post_place_timing_reports (const t_placer_opts& placer_opts,
318
321
const t_analysis_opts& analysis_opts,
@@ -433,6 +436,7 @@ void try_place(const Netlist<>& net_list,
433
436
const auto & p_timing_ctx = placer_state.timing ();
434
437
const auto & p_runtime_ctx = placer_state.runtime ();
435
438
439
+ vtr::RngContainer rng (placer_opts.seed );
436
440
437
441
std::optional<NocCostHandler> noc_cost_handler;
438
442
// create cost handler objects
@@ -445,7 +449,7 @@ void try_place(const Netlist<>& net_list,
445
449
}
446
450
#endif
447
451
448
- ManualMoveGenerator manual_move_generator (placer_state);
452
+ ManualMoveGenerator manual_move_generator (placer_state, rng );
449
453
450
454
vtr::ScopedStartFinishTimer timer (" Placement" );
451
455
@@ -454,10 +458,10 @@ void try_place(const Netlist<>& net_list,
454
458
}
455
459
456
460
initial_placement (placer_opts, placer_opts.constraints_file .c_str (),
457
- noc_opts, blk_loc_registry, noc_cost_handler);
461
+ noc_opts, blk_loc_registry, noc_cost_handler, rng );
458
462
459
463
// create the move generator based on the chosen strategy
460
- auto [move_generator, move_generator2] = create_move_generators (placer_state, placer_opts, move_lim, noc_opts.noc_centroid_weight );
464
+ auto [move_generator, move_generator2] = create_move_generators (placer_state, placer_opts, move_lim, noc_opts.noc_centroid_weight , rng );
461
465
462
466
if (!placer_opts.write_initial_place_file .empty ()) {
463
467
print_place (nullptr , nullptr , placer_opts.write_initial_place_file .c_str (), placer_state.block_locs ());
@@ -702,7 +706,7 @@ void try_place(const Netlist<>& net_list,
702
706
placer_setup_slacks.get (), timing_info.get (), *move_generator,
703
707
manual_move_generator, pin_timing_invalidator.get (),
704
708
blocks_affected, placer_opts, noc_opts, move_type_stat,
705
- swap_stats, placer_state, net_cost_handler, noc_cost_handler);
709
+ swap_stats, placer_state, net_cost_handler, noc_cost_handler, rng );
706
710
707
711
if (!placer_opts.move_stats_file .empty ()) {
708
712
f_move_stats_file = std::unique_ptr<FILE, decltype (&vtr::fclose)>(
@@ -776,7 +780,7 @@ void try_place(const Netlist<>& net_list,
776
780
blocks_affected, timing_info.get (),
777
781
placer_opts.place_algorithm , move_type_stat,
778
782
timing_bb_factor, swap_stats, placer_state,
779
- net_cost_handler, noc_cost_handler);
783
+ net_cost_handler, noc_cost_handler, rng );
780
784
781
785
782
786
// move the update used move_generator to its original variable
@@ -844,7 +848,7 @@ void try_place(const Netlist<>& net_list,
844
848
blocks_affected, timing_info.get (),
845
849
placer_opts.place_quench_algorithm , move_type_stat,
846
850
timing_bb_factor, swap_stats, placer_state,
847
- net_cost_handler, noc_cost_handler);
851
+ net_cost_handler, noc_cost_handler, rng );
848
852
849
853
850
854
// move the update used move_generator to its original variable
@@ -1060,7 +1064,8 @@ static void placement_inner_loop(const t_annealing_state* state,
1060
1064
t_swap_stats& swap_stats,
1061
1065
PlacerState& placer_state,
1062
1066
NetCostHandler& net_cost_handler,
1063
- std::optional<NocCostHandler>& noc_cost_handler) {
1067
+ std::optional<NocCostHandler>& noc_cost_handler,
1068
+ vtr::RngContainer& rng) {
1064
1069
// How many times have we dumped placement to a file this temperature?
1065
1070
int inner_placement_save_count = 0 ;
1066
1071
@@ -1075,7 +1080,7 @@ static void placement_inner_loop(const t_annealing_state* state,
1075
1080
blocks_affected, delay_model, criticalities, setup_slacks,
1076
1081
placer_opts, noc_opts, move_type_stat, place_algorithm,
1077
1082
timing_bb_factor, manual_move_enabled, swap_stats,
1078
- placer_state, net_cost_handler, noc_cost_handler);
1083
+ placer_state, net_cost_handler, noc_cost_handler, rng );
1079
1084
1080
1085
if (swap_result == ACCEPTED) {
1081
1086
/* Move was accepted. Update statistics that are useful for the annealing schedule. */
@@ -1177,7 +1182,8 @@ static float starting_t(const t_annealing_state* state,
1177
1182
t_swap_stats& swap_stats,
1178
1183
PlacerState& placer_state,
1179
1184
NetCostHandler& net_cost_handler,
1180
- std::optional<NocCostHandler>& noc_cost_handler) {
1185
+ std::optional<NocCostHandler>& noc_cost_handler,
1186
+ vtr::RngContainer& rng) {
1181
1187
if (annealing_sched.type == USER_SCHED) {
1182
1188
return (annealing_sched.init_t );
1183
1189
}
@@ -1211,7 +1217,7 @@ static float starting_t(const t_annealing_state* state,
1211
1217
blocks_affected, delay_model, criticalities, setup_slacks,
1212
1218
placer_opts, noc_opts, move_type_stat, placer_opts.place_algorithm ,
1213
1219
REWARD_BB_TIMING_RELATIVE_WEIGHT, manual_move_enabled, swap_stats,
1214
- placer_state, net_cost_handler, noc_cost_handler);
1220
+ placer_state, net_cost_handler, noc_cost_handler, rng );
1215
1221
1216
1222
1217
1223
if (swap_result == ACCEPTED) {
@@ -1285,7 +1291,8 @@ static e_move_result try_swap(const t_annealing_state* state,
1285
1291
t_swap_stats& swap_stats,
1286
1292
PlacerState& placer_state,
1287
1293
NetCostHandler& net_cost_handler,
1288
- std::optional<NocCostHandler>& noc_cost_handler) {
1294
+ std::optional<NocCostHandler>& noc_cost_handler,
1295
+ vtr::RngContainer& rng) {
1289
1296
/* Picks some block and moves it to another spot. If this spot is *
1290
1297
* occupied, switch the blocks. Assess the change in cost function. *
1291
1298
* rlim is the range limiter. *
@@ -1317,13 +1324,13 @@ static e_move_result try_swap(const t_annealing_state* state,
1317
1324
// Determine whether we need to force swap two router blocks
1318
1325
bool router_block_move = false ;
1319
1326
if (noc_opts.noc ) {
1320
- router_block_move = check_for_router_swap (noc_opts.noc_swap_percentage );
1327
+ router_block_move = check_for_router_swap (noc_opts.noc_swap_percentage , rng );
1321
1328
}
1322
1329
1323
1330
/* Allow some fraction of moves to not be restricted by rlim, */
1324
1331
/* in the hopes of better escaping local minima. */
1325
1332
float rlim;
1326
- if (rlim_escape_fraction > 0 . && vtr:: frand () < rlim_escape_fraction) {
1333
+ if (rlim_escape_fraction > 0 . && rng. frand () < rlim_escape_fraction) {
1327
1334
rlim = std::numeric_limits<float >::infinity ();
1328
1335
} else {
1329
1336
rlim = state->rlim ;
@@ -1343,7 +1350,7 @@ static e_move_result try_swap(const t_annealing_state* state,
1343
1350
#endif // NO_GRAPHICS
1344
1351
} else if (router_block_move) {
1345
1352
// generate a move where two random router blocks are swapped
1346
- create_move_outcome = propose_router_swap (blocks_affected, rlim, placer_state.blk_loc_registry ());
1353
+ create_move_outcome = propose_router_swap (blocks_affected, rlim, placer_state.blk_loc_registry (), rng );
1347
1354
proposed_action.move_type = e_move_type::UNIFORM;
1348
1355
} else {
1349
1356
// Generate a new move (perturbation) used to explore the space of possible placements
@@ -1457,7 +1464,7 @@ static e_move_result try_swap(const t_annealing_state* state,
1457
1464
}
1458
1465
1459
1466
/* 1 -> move accepted, 0 -> rejected. */
1460
- move_outcome = assess_swap (delta_c, state->t );
1467
+ move_outcome = assess_swap (delta_c, state->t , rng );
1461
1468
1462
1469
// Updates the manual_move_state members and displays costs to the user to decide whether to ACCEPT/REJECT manual move.
1463
1470
#ifndef NO_GRAPHICS
@@ -1740,7 +1747,7 @@ static float analyze_setup_slack_cost(const PlacerSetupSlacks* setup_slacks,
1740
1747
return 1 ;
1741
1748
}
1742
1749
1743
- static e_move_result assess_swap (double delta_c, double t) {
1750
+ static e_move_result assess_swap (double delta_c, double t, vtr::RngContainer& rng ) {
1744
1751
/* Returns: 1 -> move accepted, 0 -> rejected. */
1745
1752
VTR_LOGV_DEBUG (g_vpr_ctx.placement ().f_placer_debug , " \t Temperature is: %e delta_c is %e\n " , t, delta_c);
1746
1753
if (delta_c <= 0 ) {
@@ -1753,7 +1760,7 @@ static e_move_result assess_swap(double delta_c, double t) {
1753
1760
return REJECTED;
1754
1761
}
1755
1762
1756
- float fnum = vtr:: frand ();
1763
+ float fnum = rng. frand ();
1757
1764
float prob_fac = std::exp (-delta_c / t);
1758
1765
if (prob_fac > fnum) {
1759
1766
VTR_LOGV_DEBUG (g_vpr_ctx.placement ().f_placer_debug , " \t\t Move is accepted(hill climbing)\n " );
0 commit comments