@@ -209,7 +209,8 @@ static e_move_result try_swap(const t_annealing_state* state,
209209 t_swap_stats& swap_stats,
210210 PlacerState& placer_state,
211211 NetCostHandler& net_cost_handler,
212- std::optional<NocCostHandler>& noc_cost_handler);
212+ std::optional<NocCostHandler>& noc_cost_handler,
213+ vtr::RngContainer& rng);
213214
214215
215216static void check_place (const t_placer_costs& costs,
@@ -250,7 +251,8 @@ static float starting_t(const t_annealing_state* state,
250251 t_swap_stats& swap_stats,
251252 PlacerState& placer_state,
252253 NetCostHandler& net_cost_handler,
253- std::optional<NocCostHandler>& noc_cost_handler);
254+ std::optional<NocCostHandler>& noc_cost_handler,
255+ vtr::RngContainer& rng);
254256
255257static int count_connections ();
256258
@@ -268,7 +270,7 @@ static void invalidate_affected_connections(
268270static float analyze_setup_slack_cost (const PlacerSetupSlacks* setup_slacks,
269271 const PlacerState& placer_state);
270272
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 );
272274
273275static void update_placement_cost_normalization_factors (t_placer_costs* costs,
274276 const t_placer_opts& placer_opts,
@@ -312,7 +314,8 @@ static void placement_inner_loop(const t_annealing_state* state,
312314 t_swap_stats& swap_stats,
313315 PlacerState& placer_state,
314316 NetCostHandler& net_cost_handler,
315- std::optional<NocCostHandler>& noc_cost_handler);
317+ std::optional<NocCostHandler>& noc_cost_handler,
318+ vtr::RngContainer& rng);
316319
317320static void generate_post_place_timing_reports (const t_placer_opts& placer_opts,
318321 const t_analysis_opts& analysis_opts,
@@ -433,6 +436,7 @@ void try_place(const Netlist<>& net_list,
433436 const auto & p_timing_ctx = placer_state.timing ();
434437 const auto & p_runtime_ctx = placer_state.runtime ();
435438
439+ vtr::RngContainer rng (placer_opts.seed );
436440
437441 std::optional<NocCostHandler> noc_cost_handler;
438442 // create cost handler objects
@@ -445,7 +449,7 @@ void try_place(const Netlist<>& net_list,
445449 }
446450#endif
447451
448- ManualMoveGenerator manual_move_generator (placer_state);
452+ ManualMoveGenerator manual_move_generator (placer_state, rng );
449453
450454 vtr::ScopedStartFinishTimer timer (" Placement" );
451455
@@ -454,10 +458,10 @@ void try_place(const Netlist<>& net_list,
454458 }
455459
456460 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 );
458462
459463 // 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 );
461465
462466 if (!placer_opts.write_initial_place_file .empty ()) {
463467 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,
702706 placer_setup_slacks.get (), timing_info.get (), *move_generator,
703707 manual_move_generator, pin_timing_invalidator.get (),
704708 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 );
706710
707711 if (!placer_opts.move_stats_file .empty ()) {
708712 f_move_stats_file = std::unique_ptr<FILE, decltype (&vtr::fclose)>(
@@ -776,7 +780,7 @@ void try_place(const Netlist<>& net_list,
776780 blocks_affected, timing_info.get (),
777781 placer_opts.place_algorithm , move_type_stat,
778782 timing_bb_factor, swap_stats, placer_state,
779- net_cost_handler, noc_cost_handler);
783+ net_cost_handler, noc_cost_handler, rng );
780784
781785
782786 // move the update used move_generator to its original variable
@@ -844,7 +848,7 @@ void try_place(const Netlist<>& net_list,
844848 blocks_affected, timing_info.get (),
845849 placer_opts.place_quench_algorithm , move_type_stat,
846850 timing_bb_factor, swap_stats, placer_state,
847- net_cost_handler, noc_cost_handler);
851+ net_cost_handler, noc_cost_handler, rng );
848852
849853
850854 // move the update used move_generator to its original variable
@@ -1060,7 +1064,8 @@ static void placement_inner_loop(const t_annealing_state* state,
10601064 t_swap_stats& swap_stats,
10611065 PlacerState& placer_state,
10621066 NetCostHandler& net_cost_handler,
1063- std::optional<NocCostHandler>& noc_cost_handler) {
1067+ std::optional<NocCostHandler>& noc_cost_handler,
1068+ vtr::RngContainer& rng) {
10641069 // How many times have we dumped placement to a file this temperature?
10651070 int inner_placement_save_count = 0 ;
10661071
@@ -1075,7 +1080,7 @@ static void placement_inner_loop(const t_annealing_state* state,
10751080 blocks_affected, delay_model, criticalities, setup_slacks,
10761081 placer_opts, noc_opts, move_type_stat, place_algorithm,
10771082 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 );
10791084
10801085 if (swap_result == ACCEPTED) {
10811086 /* 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,
11771182 t_swap_stats& swap_stats,
11781183 PlacerState& placer_state,
11791184 NetCostHandler& net_cost_handler,
1180- std::optional<NocCostHandler>& noc_cost_handler) {
1185+ std::optional<NocCostHandler>& noc_cost_handler,
1186+ vtr::RngContainer& rng) {
11811187 if (annealing_sched.type == USER_SCHED) {
11821188 return (annealing_sched.init_t );
11831189 }
@@ -1211,7 +1217,7 @@ static float starting_t(const t_annealing_state* state,
12111217 blocks_affected, delay_model, criticalities, setup_slacks,
12121218 placer_opts, noc_opts, move_type_stat, placer_opts.place_algorithm ,
12131219 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 );
12151221
12161222
12171223 if (swap_result == ACCEPTED) {
@@ -1285,7 +1291,8 @@ static e_move_result try_swap(const t_annealing_state* state,
12851291 t_swap_stats& swap_stats,
12861292 PlacerState& placer_state,
12871293 NetCostHandler& net_cost_handler,
1288- std::optional<NocCostHandler>& noc_cost_handler) {
1294+ std::optional<NocCostHandler>& noc_cost_handler,
1295+ vtr::RngContainer& rng) {
12891296 /* Picks some block and moves it to another spot. If this spot is *
12901297 * occupied, switch the blocks. Assess the change in cost function. *
12911298 * rlim is the range limiter. *
@@ -1317,13 +1324,13 @@ static e_move_result try_swap(const t_annealing_state* state,
13171324 // Determine whether we need to force swap two router blocks
13181325 bool router_block_move = false ;
13191326 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 );
13211328 }
13221329
13231330 /* Allow some fraction of moves to not be restricted by rlim, */
13241331 /* in the hopes of better escaping local minima. */
13251332 float rlim;
1326- if (rlim_escape_fraction > 0 . && vtr:: frand () < rlim_escape_fraction) {
1333+ if (rlim_escape_fraction > 0 . && rng. frand () < rlim_escape_fraction) {
13271334 rlim = std::numeric_limits<float >::infinity ();
13281335 } else {
13291336 rlim = state->rlim ;
@@ -1343,7 +1350,7 @@ static e_move_result try_swap(const t_annealing_state* state,
13431350#endif // NO_GRAPHICS
13441351 } else if (router_block_move) {
13451352 // 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 );
13471354 proposed_action.move_type = e_move_type::UNIFORM;
13481355 } else {
13491356 // 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,
14571464 }
14581465
14591466 /* 1 -> move accepted, 0 -> rejected. */
1460- move_outcome = assess_swap (delta_c, state->t );
1467+ move_outcome = assess_swap (delta_c, state->t , rng );
14611468
14621469 // Updates the manual_move_state members and displays costs to the user to decide whether to ACCEPT/REJECT manual move.
14631470#ifndef NO_GRAPHICS
@@ -1740,7 +1747,7 @@ static float analyze_setup_slack_cost(const PlacerSetupSlacks* setup_slacks,
17401747 return 1 ;
17411748}
17421749
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 ) {
17441751 /* Returns: 1 -> move accepted, 0 -> rejected. */
17451752 VTR_LOGV_DEBUG (g_vpr_ctx.placement ().f_placer_debug , " \t Temperature is: %e delta_c is %e\n " , t, delta_c);
17461753 if (delta_c <= 0 ) {
@@ -1753,7 +1760,7 @@ static e_move_result assess_swap(double delta_c, double t) {
17531760 return REJECTED;
17541761 }
17551762
1756- float fnum = vtr:: frand ();
1763+ float fnum = rng. frand ();
17571764 float prob_fac = std::exp (-delta_c / t);
17581765 if (prob_fac > fnum) {
17591766 VTR_LOGV_DEBUG (g_vpr_ctx.placement ().f_placer_debug , " \t\t Move is accepted(hill climbing)\n " );
0 commit comments