@@ -96,12 +96,7 @@ struct t_placer_statistics {
96
96
};
97
97
98
98
constexpr float INVALID_DELAY = std::numeric_limits<float >::quiet_NaN();
99
-
100
- constexpr double MAX_INV_TIMING_COST = 1 .e9 ;
101
- /* Stops inverse timing cost from going to infinity with very lax timing constraints,
102
- * which avoids multiplying by a gigantic prev_inverse.timing_cost when auto-normalizing.
103
- * The exact value of this cost has relatively little impact, but should not be
104
- * large enough to be on the order of timing costs for normal constraints. */
99
+ constexpr float INVALID_COST = std::numeric_limits<double >::quiet_NaN();
105
100
106
101
/* ********************* Variables local to place.c ***************************/
107
102
@@ -265,7 +260,6 @@ static void reset_move_nets(int num_nets_affected);
265
260
static e_move_result try_swap (float t,
266
261
float crit_exponent,
267
262
t_placer_costs* costs,
268
- t_placer_prev_inverse_costs* prev_inverse_costs,
269
263
float rlim,
270
264
MoveGenerator& move_generator,
271
265
SetupTimingInfo* timing_info,
@@ -293,7 +287,6 @@ static int check_macro_placement_consistency();
293
287
294
288
static float starting_t (float crit_exponent,
295
289
t_placer_costs* costs,
296
- t_placer_prev_inverse_costs* prev_inverse_costs,
297
290
t_annealing_sched annealing_sched,
298
291
int max_moves,
299
292
float rlim,
@@ -369,7 +362,6 @@ static void free_try_swap_arrays();
369
362
370
363
static void outer_loop_update_timing_info (const t_placer_opts& placer_opts,
371
364
t_placer_costs* costs,
372
- t_placer_prev_inverse_costs* prev_inverse_costs,
373
365
int num_connections,
374
366
float crit_exponent,
375
367
int * outer_crit_iter_count,
@@ -388,7 +380,6 @@ static void placement_inner_loop(float t,
388
380
int inner_recompute_limit,
389
381
t_placer_statistics* stats,
390
382
t_placer_costs* costs,
391
- t_placer_prev_inverse_costs* prev_inverse_costs,
392
383
int * moves_since_cost_recompute,
393
384
ClusteredPinTimingInvalidator* pin_timing_invalidator,
394
385
const PlaceDelayModel* delay_model,
@@ -458,8 +449,7 @@ void try_place(const t_placer_opts& placer_opts,
458
449
outer_crit_iter_count, inner_recompute_limit;
459
450
float success_rat, first_crit_exponent, first_rlim;
460
451
461
- t_placer_costs costs;
462
- t_placer_prev_inverse_costs prev_inverse_costs;
452
+ t_placer_costs costs (placer_opts.place_algorithm );
463
453
464
454
tatum::TimingPathInfo critical_path;
465
455
float sTNS = NAN;
@@ -573,7 +563,7 @@ void try_place(const t_placer_opts& placer_opts,
573
563
574
564
critical_path = timing_info->least_slack_critical_path ();
575
565
576
- // Write out the initial timing echo file
566
+ /* Write out the initial timing echo file */
577
567
if (isEchoFileEnabled (E_ECHO_INITIAL_PLACEMENT_TIMING_GRAPH)) {
578
568
tatum::write_echo (getEchoFileName (E_ECHO_INITIAL_PLACEMENT_TIMING_GRAPH),
579
569
*timing_ctx.graph , *timing_ctx.constraints , *placement_delay_calc, timing_info->analyzer ());
@@ -585,20 +575,27 @@ void try_place(const t_placer_opts& placer_opts,
585
575
586
576
outer_crit_iter_count = 1 ;
587
577
588
- prev_inverse_costs.timing_cost = 1 / costs.timing_cost ;
589
- prev_inverse_costs.bb_cost = 1 / costs.bb_cost ;
590
- costs.cost = 1 ; /* our new cost function uses normalized values of */
591
- /* bb_cost and timing_cost, the value of cost will be reset */
592
- /* to 1 at each temperature when *_TIMING_DRIVEN_PLACE is true */
593
- } else { /* BOUNDING_BOX_PLACE */
594
- costs.cost = costs.bb_cost = comp_bb_cost (NORMAL);
595
- costs.timing_cost = 0 ;
578
+ /* Initialize the normalization factors. Calling costs.update_norm_factors() *
579
+ * here would fail the golden results of strong_sdc benchmark */
580
+ costs.timing_cost_norm = 1 / costs.timing_cost ;
581
+ costs.bb_cost_norm = 1 / costs.bb_cost ;
582
+ costs.cost = 1 ;
583
+ } else {
584
+ VTR_ASSERT (placer_opts.place_algorithm == BOUNDING_BOX_PLACE);
585
+
586
+ /* Total cost is the same as wirelength cost */
587
+ costs.bb_cost = comp_bb_cost (NORMAL);
588
+ costs.cost = costs.bb_cost ;
589
+
590
+ /* Timing cost and normalization factors are not used */
591
+ costs.timing_cost = INVALID_COST;
592
+ costs.timing_cost_norm = INVALID_COST;
593
+ costs.bb_cost_norm = INVALID_COST;
594
+
595
+ /* Other initializations */
596
596
outer_crit_iter_count = 0 ;
597
597
num_connections = 0 ;
598
598
first_crit_exponent = 0 ;
599
-
600
- prev_inverse_costs.timing_cost = 0 ; /* inverses not used */
601
- prev_inverse_costs.bb_cost = 0 ;
602
599
}
603
600
604
601
// Sanity check that initial placement is legal
@@ -683,7 +680,7 @@ void try_place(const t_placer_opts& placer_opts,
683
680
first_rlim = (float )max (device_ctx.grid .width () - 1 , device_ctx.grid .height () - 1 );
684
681
685
682
float first_t = starting_t (first_crit_exponent,
686
- &costs, &prev_inverse_costs,
683
+ &costs,
687
684
annealing_sched, move_lim, first_rlim,
688
685
place_delay_model.get (),
689
686
placer_criticalities.get (),
@@ -720,12 +717,9 @@ void try_place(const t_placer_opts& placer_opts,
720
717
/* Outer loop of the simulated annealing begins */
721
718
do {
722
719
vtr::Timer temperature_timer;
723
- if (placer_opts.place_algorithm .is_timing_driven ()) {
724
- costs.cost = 1 ;
725
- }
726
720
727
721
outer_loop_update_timing_info (placer_opts,
728
- &costs, &prev_inverse_costs,
722
+ &costs,
729
723
num_connections,
730
724
state.crit_exponent ,
731
725
&outer_crit_iter_count,
@@ -737,7 +731,7 @@ void try_place(const t_placer_opts& placer_opts,
737
731
738
732
placement_inner_loop (state.t , num_temps, state.rlim , placer_opts,
739
733
state.move_lim , state.crit_exponent , inner_recompute_limit, &stats,
740
- &costs, &prev_inverse_costs,
734
+ &costs,
741
735
&moves_since_cost_recompute,
742
736
pin_timing_invalidator.get (),
743
737
place_delay_model.get (),
@@ -789,7 +783,7 @@ void try_place(const t_placer_opts& placer_opts,
789
783
vtr::ScopedFinishTimer temperature_timer (" Placement Quench" );
790
784
791
785
outer_loop_update_timing_info (placer_opts,
792
- &costs, &prev_inverse_costs,
786
+ &costs,
793
787
num_connections,
794
788
state.crit_exponent ,
795
789
&outer_crit_iter_count,
@@ -805,7 +799,7 @@ void try_place(const t_placer_opts& placer_opts,
805
799
* which reduce the cost of the placement */
806
800
placement_inner_loop (state.t , num_temps, state.rlim , placer_opts,
807
801
move_lim, state.crit_exponent , quench_recompute_limit, &stats,
808
- &costs, &prev_inverse_costs,
802
+ &costs,
809
803
&moves_since_cost_recompute,
810
804
pin_timing_invalidator.get (),
811
805
place_delay_model.get (),
@@ -928,7 +922,6 @@ void try_place(const t_placer_opts& placer_opts,
928
922
/* Function to update the setup slacks and criticalities before the inner loop of the annealing/quench */
929
923
static void outer_loop_update_timing_info (const t_placer_opts& placer_opts,
930
924
t_placer_costs* costs,
931
- t_placer_prev_inverse_costs* prev_inverse_costs,
932
925
int num_connections,
933
926
float crit_exponent,
934
927
int * outer_crit_iter_count,
@@ -964,11 +957,8 @@ static void outer_loop_update_timing_info(const t_placer_opts& placer_opts,
964
957
}
965
958
(*outer_crit_iter_count)++;
966
959
967
- /* at each temperature change we update these values to be used */
968
- /* for normalizing the tradeoff between timing and wirelength (bb) */
969
- prev_inverse_costs->bb_cost = 1 / costs->bb_cost ;
970
- /* Prevent inverse timing cost from going to infinity */
971
- prev_inverse_costs->timing_cost = min (1 / costs->timing_cost , MAX_INV_TIMING_COST);
960
+ /* Update the cost normalization factors */
961
+ costs->update_norm_factors ();
972
962
}
973
963
974
964
/* Function which contains the inner loop of the simulated annealing */
@@ -981,7 +971,6 @@ static void placement_inner_loop(float t,
981
971
int inner_recompute_limit,
982
972
t_placer_statistics* stats,
983
973
t_placer_costs* costs,
984
- t_placer_prev_inverse_costs* prev_inverse_costs,
985
974
int * moves_since_cost_recompute,
986
975
ClusteredPinTimingInvalidator* pin_timing_invalidator,
987
976
const PlaceDelayModel* delay_model,
@@ -1008,7 +997,6 @@ static void placement_inner_loop(float t,
1008
997
e_move_result swap_result = try_swap (t,
1009
998
crit_exponent,
1010
999
costs,
1011
- prev_inverse_costs,
1012
1000
rlim,
1013
1001
move_generator,
1014
1002
timing_info,
@@ -1239,7 +1227,6 @@ static bool update_annealing_state(t_annealing_state* state,
1239
1227
1240
1228
static float starting_t (float crit_exponent,
1241
1229
t_placer_costs* costs,
1242
- t_placer_prev_inverse_costs* prev_inverse_costs,
1243
1230
t_annealing_sched annealing_sched,
1244
1231
int max_moves,
1245
1232
float rlim,
@@ -1275,7 +1262,6 @@ static float starting_t(float crit_exponent,
1275
1262
e_move_result swap_result = try_swap (t,
1276
1263
crit_exponent,
1277
1264
costs,
1278
- prev_inverse_costs,
1279
1265
rlim,
1280
1266
move_generator,
1281
1267
timing_info,
@@ -1350,7 +1336,6 @@ static void reset_move_nets(int num_nets_affected) {
1350
1336
static e_move_result try_swap (float t,
1351
1337
float crit_exponent,
1352
1338
t_placer_costs* costs,
1353
- t_placer_prev_inverse_costs* prev_inverse_costs,
1354
1339
float rlim,
1355
1340
MoveGenerator& move_generator,
1356
1341
SetupTimingInfo* timing_info,
@@ -1472,8 +1457,8 @@ static e_move_result try_swap(float t,
1472
1457
/* in this case we redefine delta_c as a combination of timing and bb. *
1473
1458
*additionally, we normalize all values, therefore delta_c is in *
1474
1459
*relation to 1*/
1475
- delta_c = (1 - timing_tradeoff) * bb_delta_c * prev_inverse_costs-> bb_cost
1476
- + timing_tradeoff * timing_delta_c * prev_inverse_costs-> timing_cost ;
1460
+ delta_c = (1 - timing_tradeoff) * bb_delta_c * costs-> bb_cost_norm
1461
+ + timing_tradeoff * timing_delta_c * costs-> timing_cost_norm ;
1477
1462
1478
1463
} else {
1479
1464
VTR_ASSERT (place_algorithm == BOUNDING_BOX_PLACE);
@@ -1559,8 +1544,8 @@ static e_move_result try_swap(float t,
1559
1544
}
1560
1545
1561
1546
move_outcome_stats.delta_cost_norm = delta_c;
1562
- move_outcome_stats.delta_bb_cost_norm = bb_delta_c * prev_inverse_costs-> bb_cost ;
1563
- move_outcome_stats.delta_timing_cost_norm = timing_delta_c * prev_inverse_costs-> timing_cost ;
1547
+ move_outcome_stats.delta_bb_cost_norm = bb_delta_c * costs-> bb_cost_norm ;
1548
+ move_outcome_stats.delta_timing_cost_norm = timing_delta_c * costs-> timing_cost_norm ;
1564
1549
1565
1550
move_outcome_stats.delta_bb_cost_abs = bb_delta_c;
1566
1551
move_outcome_stats.delta_timing_cost_abs = timing_delta_c;
0 commit comments