321 int tot_iter, inner_iter, success_sum, move_lim, moves_since_cost_recompute, width_fac,
322 num_connections, inet, ipin, outer_crit_iter_count, inner_crit_iter_count,
324 float t, success_rat, rlim, cost, timing_cost, bb_cost, new_bb_cost, new_timing_cost,
325 delay_cost, new_delay_cost, place_delay_value, inverse_prev_bb_cost, inverse_prev_timing_cost,
326 oldt, **old_region_occ_x, **old_region_occ_y, **
net_delay = NULL, crit_exponent,
327 first_rlim, final_rlim, inverse_delta_rlim, critical_path_delay =
UNDEFINED,
328 **remember_net_delay_original_ptr;
329 double av_cost, av_bb_cost, av_timing_cost, av_delay_cost, sum_of_squares, std_dev;
330 int total_swap_attempts;
339 remember_net_delay_original_ptr = NULL;
352 det_routing_arch, segment_inf, timing_inf, &net_delay, directs, num_directs);
354 remember_net_delay_original_ptr =
net_delay;
357 #ifdef PRINT_LOWER_BOUND
371 vpr_printf(TIO_MESSAGE_INFO,
"Lower bound assuming delay of %g\n", place_delay_value);
403 &old_region_occ_x, &old_region_occ_y, placer_opts,
404 directs, num_directs);
422 vpr_printf(TIO_MESSAGE_INFO,
"There are %d point to point connections in this circuit.\n", num_connections);
426 for (inet = 0; inet <
num_nets; inet++)
433 place_delay_value = delay_cost / num_connections;
438 place_delay_value = 0;
459 outer_crit_iter_count = 1;
464 inverse_prev_timing_cost = 1 / timing_cost;
465 inverse_prev_bb_cost = 1 / bb_cost;
473 place_delay_value = 0;
474 outer_crit_iter_count = 0;
478 inverse_prev_timing_cost = 0;
479 inverse_prev_bb_cost = 0;
485 inner_recompute_limit = (int) (0.5
490 inner_recompute_limit = move_lim + 1;
504 inverse_delta_rlim = 1 / (first_rlim - final_rlim);
507 old_region_occ_x, old_region_occ_y,
508 annealing_sched, move_lim, rlim,
510 inverse_prev_bb_cost, inverse_prev_timing_cost, &delay_cost);
512 moves_since_cost_recompute = 0;
513 vpr_printf(TIO_MESSAGE_INFO,
"Initial placement cost: %g bb_cost: %g td_cost: %g delay_cost: %g\n",
514 cost, bb_cost, timing_cost, delay_cost);
518 vpr_printf(TIO_MESSAGE_INFO,
"%9s %9s %11s %11s %11s %11s %8s %8s %7s %7s %7s %9s %7s\n",
519 "---------",
"---------",
"-----------",
"-----------",
"-----------",
"-----------",
520 "--------",
"--------",
"-------",
"-------",
"-------",
"---------",
"-------");
521 vpr_printf(TIO_MESSAGE_INFO,
"%9s %9s %11s %11s %11s %11s %8s %8s %7s %7s %7s %9s %7s\n",
522 "T",
"Cost",
"Av BB Cost",
"Av TD Cost",
"Av Tot Del",
523 "P to P Del",
"d_max",
"Ac Rate",
"Std Dev",
"R limit",
"Exp",
524 "Tot Moves",
"Alpha");
525 vpr_printf(TIO_MESSAGE_INFO,
"%9s %9s %11s %11s %11s %11s %8s %8s %7s %7s %7s %9s %7s\n",
526 "---------",
"---------",
"-----------",
"-----------",
"-----------",
"-----------",
527 "--------",
"--------",
"-------",
"-------",
"-------",
"---------",
"-------");
530 sprintf(msg,
"Initial Placement. Cost: %g BB Cost: %g TD Cost %g Delay Cost: %g \t Channel Factor: %d",
531 cost, bb_cost, timing_cost, delay_cost, width_fac);
534 while (
exit_crit(t, cost, annealing_sched) == 0) {
554 vpr_printf(TIO_MESSAGE_INFO,
"Outer loop recompute criticalities\n");
556 place_delay_value = delay_cost / num_connections;
569 outer_crit_iter_count = 0;
571 outer_crit_iter_count++;
575 inverse_prev_bb_cost = 1 / bb_cost;
580 inner_crit_iter_count = 1;
582 for (inner_iter = 0; inner_iter < move_lim; inner_iter++) {
583 swap_result =
try_swap(t, &cost, &bb_cost, &timing_cost, rlim,
587 inverse_prev_bb_cost, inverse_prev_timing_cost, &delay_cost);
593 av_bb_cost += bb_cost;
594 av_timing_cost += timing_cost;
595 av_delay_cost += delay_cost;
596 sum_of_squares += cost * cost;
598 }
else if (swap_result ==
ABORTED) {
612 if (inner_crit_iter_count >= inner_recompute_limit
613 && inner_iter != move_lim - 1) {
615 inner_crit_iter_count = 0;
617 vpr_printf(TIO_MESSAGE_TRACE,
"Inner loop recompute criticalities\n");
625 place_delay_value = delay_cost / num_connections;
638 inner_crit_iter_count++;
641 vpr_printf(TIO_MESSAGE_TRACE,
"t = %g cost = %g bb_cost = %g timing_cost = %g move = %d dmax = %g\n",
642 t, cost, bb_cost, timing_cost, inner_iter, delay_cost);
653 moves_since_cost_recompute += move_lim;
656 if (fabs(new_bb_cost - bb_cost) > bb_cost *
ERROR_TOL) {
657 vpr_printf(TIO_MESSAGE_ERROR,
"in try_place: new_bb_cost = %g, old bb_cost = %g\n",
658 new_bb_cost, bb_cost);
661 bb_cost = new_bb_cost;
667 if (fabs(new_timing_cost - timing_cost) > timing_cost * ERROR_TOL) {
668 vpr_printf(TIO_MESSAGE_ERROR,
"in try_place: new_timing_cost = %g, old timing_cost = %g\n",
669 new_timing_cost, timing_cost);
672 if (fabs(new_delay_cost - delay_cost) > delay_cost * ERROR_TOL) {
673 vpr_printf(TIO_MESSAGE_ERROR,
"in try_place: new_delay_cost = %g, old delay_cost = %g\n",
674 new_delay_cost, delay_cost);
677 timing_cost = new_timing_cost;
683 moves_since_cost_recompute = 0;
686 tot_iter += move_lim;
687 success_rat = ((float) success_sum) / move_lim;
688 if (success_sum == 0) {
690 av_bb_cost = bb_cost;
691 av_timing_cost = timing_cost;
692 av_delay_cost = delay_cost;
694 av_cost /= success_sum;
695 av_bb_cost /= success_sum;
696 av_timing_cost /= success_sum;
697 av_delay_cost /= success_sum;
699 std_dev =
get_std_dev(success_sum, sum_of_squares, av_cost);
702 update_t(&t, std_dev, rlim, success_rat, annealing_sched);
706 vpr_printf(TIO_MESSAGE_INFO,
"%9.5f %9.5g %11.6g %11.6g %11.6g %11.6g %8.4f %8.4f %7.4f %7.4f %7.4f %9d %7.4f\n",
707 oldt, av_cost, av_bb_cost, av_timing_cost, av_delay_cost, place_delay_value,
708 critical_path_delay, success_rat, std_dev, rlim, crit_exponent, tot_iter, t / oldt);
711 sprintf(msg,
"Cost: %g BB Cost %g TD Cost %g Temperature: %g",
712 cost, bb_cost, timing_cost, t);
718 crit_exponent = (1 - (rlim - final_rlim) * inverse_delta_rlim)
725 print_clb_placement(
"first_iteration_clb_placement.echo");
746 vpr_printf(TIO_MESSAGE_INFO,
"Outer loop recompute criticalities\n");
748 place_delay_value = delay_cost / num_connections;
759 outer_crit_iter_count = 0;
761 outer_crit_iter_count++;
763 inverse_prev_bb_cost = 1 / (bb_cost);
768 inner_crit_iter_count = 1;
770 for (inner_iter = 0; inner_iter < move_lim; inner_iter++) {
771 swap_result =
try_swap(t, &cost, &bb_cost, &timing_cost, rlim,
772 old_region_occ_x, old_region_occ_y,
774 inverse_prev_bb_cost, inverse_prev_timing_cost, &delay_cost);
779 av_bb_cost += bb_cost;
780 av_delay_cost += delay_cost;
781 av_timing_cost += timing_cost;
782 sum_of_squares += cost * cost;
788 if (inner_crit_iter_count >= inner_recompute_limit
789 && inner_iter != move_lim - 1) {
791 inner_crit_iter_count = 0;
793 vpr_printf(TIO_MESSAGE_TRACE,
"Inner loop recompute criticalities\n");
797 place_delay_value = delay_cost / num_connections;
807 inner_crit_iter_count++;
810 }
else if (swap_result ==
ABORTED) {
817 vpr_printf(TIO_MESSAGE_INFO,
"t = %g, cost = %g, move = %d\n", t, cost, tot_iter);
820 tot_iter += move_lim;
821 success_rat = ((float) success_sum) / move_lim;
822 if (success_sum == 0) {
824 av_bb_cost = bb_cost;
825 av_delay_cost = delay_cost;
826 av_timing_cost = timing_cost;
828 av_cost /= success_sum;
829 av_bb_cost /= success_sum;
830 av_delay_cost /= success_sum;
831 av_timing_cost /= success_sum;
834 std_dev =
get_std_dev(success_sum, sum_of_squares, av_cost);
837 vpr_printf(TIO_MESSAGE_INFO,
"%9.5f %9.5g %11.6g %11.6g %11.6g %11.6g %8s %8.4f %7.4f %7.4f %7.4f %9d\n",
838 t, av_cost, av_bb_cost, av_timing_cost, av_delay_cost, place_delay_value,
839 " ", success_rat, std_dev, rlim, crit_exponent, tot_iter);
861 for (inet = 0; inet <
num_nets; inet++)
892 vpr_printf(TIO_MESSAGE_INFO,
"Placement estimated critical path delay: %g ns\n", critical_path_delay);
895 sprintf(msg,
"Placement. Cost: %g bb_cost: %g td_cost: %g Channel Factor: %d",
896 cost, bb_cost, timing_cost, width_fac);
897 vpr_printf(TIO_MESSAGE_INFO,
"Placement cost: %g, bb_cost: %g, td_cost: %g, delay_cost: %g\n",
898 cost, bb_cost, timing_cost, delay_cost);
905 abort_rate = num_swap_aborted / total_swap_attempts;
906 vpr_printf(TIO_MESSAGE_INFO,
"Placement total # of swap attempts: %d\n", total_swap_attempts);
907 vpr_printf(TIO_MESSAGE_INFO,
"\tSwap reject rate: %g\n", reject_rate);
908 vpr_printf(TIO_MESSAGE_INFO,
"\tSwap accept rate: %g\n", accept_rate);
909 vpr_printf(TIO_MESSAGE_INFO,
"\tSwap abort rate: %g\n", abort_rate);
913 vpr_printf(TIO_MESSAGE_INFO,
"Total moves attempted: %d.0\n", tot_iter);
917 old_region_occ_x, old_region_occ_y,
923 net_delay = remember_net_delay_original_ptr;
static float comp_bb_cost(enum cost_methods method)
#define MAX_MOVES_BEFORE_RECOMPUTE
static void free_try_swap_arrays(void)
void update_screen(int priority, char *msg, enum pic_type pic_on_screen_val, boolean crit_path_button_enabled)
static int num_swap_aborted
static void check_place(float bb_cost, float timing_cost, enum e_place_algorithm place_algorithm, float delay_cost)
boolean enable_timing_computations
static void initial_placement(enum e_pad_loc_type pad_loc_type, char *pad_loc_file)
float get_critical_path_delay(void)
enum e_pad_loc_type pad_loc_type
float ** timing_place_crit
static float ** net_delay
static float recompute_bb_cost(void)
float ** delta_clb_to_clb
void free_lookups_and_criticalities(float ***net_delay, t_slack *slacks)
static double get_std_dev(int n, double sum_x_squared, double av_x)
void print_critical_path(const char *fname)
void do_timing_analysis(t_slack *slacks, boolean is_prepacked, boolean do_lut_input_balancing, boolean is_final_analysis)
static float starting_t(float *cost_ptr, float *bb_cost_ptr, float *timing_cost_ptr, float **old_region_occ_x, float **old_region_occ_y, struct s_annealing_sched annealing_sched, int max_moves, float rlim, enum e_place_algorithm place_algorithm, float timing_tradeoff, float inverse_prev_bb_cost, float inverse_prev_timing_cost, float *delay_cost_ptr)
static enum swap_result try_swap(float t, float *cost, float *bb_cost, float *timing_cost, float rlim, float **old_region_occ_x, float **old_region_occ_y, enum e_place_algorithm place_algorithm, float timing_tradeoff, float inverse_prev_bb_cost, float inverse_prev_timing_cost, float *delay_cost)
boolean getEchoEnabled(void)
static void comp_td_costs(float *timing_cost, float *connection_delay_sum)
static int num_swap_accepted
void init_draw_coords(float width_val)
void load_criticalities(t_slack *slacks, float crit_exponent)
#define MAX_INV_TIMING_COST
void init_chan(int cfactor, t_chan_width_dist chan_width_dist)
static void free_placement_structs(float **old_region_occ_x, float **old_region_occ_y, struct s_placer_opts placer_opts)
static int num_swap_rejected
boolean isEchoFileEnabled(enum e_echo_files echo_option)
static float ** point_to_point_delay_cost
void print_sink_delays(const char *fname)
static void update_rlim(float *rlim, float success_rat)
static void alloc_and_load_placement_structs(float place_cost_exp, float ***old_region_occ_x, float ***old_region_occ_y, struct s_placer_opts placer_opts, t_direct_inf *directs, int num_directs)
static int count_connections(void)
enum e_place_algorithm place_algorithm
void print_criticality(t_slack *slacks, boolean criticality_is_normalized, const char *fname)
void load_constant_net_delay(float **net_delay, float delay_value, struct s_net *nets, int n_nets)
static int exit_crit(float t, float cost, struct s_annealing_sched annealing_sched)
t_slack * alloc_lookups_and_criticalities(t_chan_width_dist chan_width_dist, struct s_router_opts router_opts, struct s_det_routing_arch det_routing_arch, t_segment_inf *segment_inf, t_timing_inf timing_inf, float ***net_delay, INP t_direct_inf *directs, INP int num_directs)
void print_slack(float **slack, boolean slack_is_normalized, const char *fname)
void print_timing_graph(const char *fname)
int inner_loop_recompute_divider
char * getEchoFileName(enum e_echo_files echo_option)
static void update_t(float *t, float std_dev, float rlim, float success_rat, struct s_annealing_sched annealing_sched)
void load_timing_graph_net_delays(float **net_delay)