252 int i, iblk, num_molecules, blocks_since_last_analysis, num_clb, max_nets_in_pb_type,
253 cur_nets_in_pb_type, num_blocks_hill_added, max_cluster_size, cur_cluster_size,
254 max_molecule_inputs, max_pb_depth, cur_pb_depth, num_unrelated_clustering_attempts,
255 indexofcrit, savedindexofcrit ,
256 detailed_routing_stage, *hill_climbing_inputs_avail;
258 int *num_used_instances_type, *num_instances_type;
261 boolean early_exit, is_cluster_legal;
269 t_pack_molecule *istart, *next_molecule, *prev_molecule, *cur_molecule;
275 float num_paths_scaling, distance_scaling;
284 max_cluster_size = 0;
285 max_molecule_inputs = 0;
287 max_nets_in_pb_type = 0;
291 cur_molecule = molecule_head;
293 while (cur_molecule != NULL) {
299 cur_molecule = cur_molecule->
next;
310 if (cur_cluster_size > max_cluster_size) {
311 max_cluster_size = cur_cluster_size;
313 if (cur_pb_depth > max_pb_depth) {
314 max_pb_depth = cur_pb_depth;
316 if (cur_nets_in_pb_type > max_nets_in_pb_type) {
317 max_nets_in_pb_type = cur_nets_in_pb_type;
321 if (hill_climbing_flag) {
322 hill_climbing_inputs_avail = (
int *)
my_calloc(max_cluster_size + 1,
325 hill_climbing_inputs_avail = NULL;
333 check_for_duplicate_inputs ();
336 max_molecule_inputs, max_pb_depth, num_models,
337 &cluster_placement_stats, &primitives_list, molecule_head,
340 blocks_since_last_analysis = 0;
342 num_blocks_hill_added = 0;
343 num_used_instances_type = (
int*)
my_calloc(num_types,
sizeof(
int));
344 num_instances_type = (
int*)
my_calloc(num_types,
sizeof(
int));
351 inter_cluster_net_delay, arch->
models, timing_inf);
357 #ifndef PATH_COUNTING
385 crit = PACK_PATH_WEIGHT * slacks->path_criticality[inet][ipin]
397 for (inode = 0; inode <
num_tnodes; inode++) {
406 * (float)
tnode[inode].prepacked_data->normalized_total_critical_paths;
428 max_molecule_inputs);
433 max_molecule_inputs);
437 while (istart != NULL) {
438 is_cluster_legal =
FALSE;
439 savedindexofcrit = indexofcrit;
445 &clb[num_clb], num_clb, istart, aspect, num_used_instances_type,
446 num_instances_type, num_models, max_cluster_size,
447 max_nets_in_pb_type, detailed_routing_stage);
448 vpr_printf(TIO_MESSAGE_INFO,
"Complex block %d: %s, type: %s\n",
449 num_clb, clb[num_clb].name, clb[num_clb].type->
name);
453 beta, timing_driven, connection_driven, slacks);
456 if (timing_driven && !early_exit) {
457 blocks_since_last_analysis++;
461 cur_cluster_placement_stats_ptr = &cluster_placement_stats[clb[num_clb
463 num_unrelated_clustering_attempts = 0;
465 clb[num_clb - 1].pb, allow_unrelated_clustering,
466 &num_unrelated_clustering_attempts,
467 cur_cluster_placement_stats_ptr);
468 prev_molecule = istart;
469 while (next_molecule != NULL && prev_molecule != next_molecule) {
471 cur_cluster_placement_stats_ptr, next_molecule,
472 primitives_list, clb[num_clb - 1].pb, num_models,
473 max_cluster_size, num_clb - 1, max_nets_in_pb_type, detailed_routing_stage);
474 prev_molecule = next_molecule;
476 if (next_molecule != NULL) {
478 #ifdef DEBUG_FAILED_PACKING_CANDIDATES
479 vpr_printf(TIO_MESSAGE_DIRECT,
"\tNO_ROUTE:%s type %s/n",
487 #ifdef DEBUG_FAILED_PACKING_CANDIDATES
488 vpr_printf(TIO_MESSAGE_DIRECT,
"\tFAILED_CHECK:%s type %s check %d\n",
500 clb[num_clb - 1].pb, allow_unrelated_clustering,
501 &num_unrelated_clustering_attempts,
502 cur_cluster_placement_stats_ptr);
506 #ifdef DEBUG_FAILED_PACKING_CANDIDATES
507 vpr_printf(TIO_MESSAGE_DIRECT,
"\tPASSED:%s type %s\n",
516 global_clocks, alpha, beta, timing_driven,
517 connection_driven, slacks);
518 num_unrelated_clustering_attempts = 0;
520 if (timing_driven && !early_exit) {
521 blocks_since_last_analysis++;
524 clb[num_clb - 1].pb, allow_unrelated_clustering,
525 &num_unrelated_clustering_attempts,
526 cur_cluster_placement_stats_ptr);
531 if (is_cluster_legal ==
TRUE) {
532 vpr_printf(TIO_MESSAGE_INFO,
"Passed route at end.\n");
534 vpr_printf(TIO_MESSAGE_INFO,
"Failed route at end, repack cluster trying detailed routing at each stage.\n");
537 is_cluster_legal =
TRUE;
539 if (is_cluster_legal ==
TRUE) {
542 if (num_blocks_hill_added > 0 && !early_exit) {
543 blocks_since_last_analysis += num_blocks_hill_added;
549 max_molecule_inputs);
554 max_molecule_inputs);
559 num_used_instances_type[clb[num_clb - 1].type->index]--;
561 free(clb[num_clb - 1].pb);
562 free(clb[num_clb - 1].name);
563 clb[num_clb - 1].name = NULL;
564 clb[num_clb - 1].pb = NULL;
566 indexofcrit = savedindexofcrit;
579 output_blif (clb, num_clb, global_clocks, is_clock,
583 if (hill_climbing_flag) {
584 free(hill_climbing_inputs_avail);
588 for (i = 0; i < num_clb; i++) {
596 free(num_used_instances_type);
597 free(num_instances_type);
614 free (primitives_list);
int get_max_depth_of_pb_type(t_pb_type *pb_type)
static int * critindexarray
void free_cluster_legality_checker(void)
static void check_clustering(int num_clb, t_block *clb, boolean *is_clock)
void heapsort(int *sort_index, float *sort_values, int nelem, int start_index)
int get_max_nets_in_pb_type(const t_pb_type *pb_type)
#define SCALE_DISTANCE_VAL
static t_pack_molecule * get_molecule_for_cluster(INP enum e_packer_algorithm packer_algorithm, INP t_pb *cur_pb, INP boolean allow_unrelated_clustering, INOUTP int *num_unrelated_clustering_attempts, INP t_cluster_placement_stats *cluster_placement_stats_ptr)
int get_max_primitives_in_pb_type(t_pb_type *pb_type)
static void start_new_cluster(INP t_cluster_placement_stats *cluster_placement_stats, INP t_pb_graph_node **primitives_list, INP const t_arch *arch, INOUTP t_block *new_cluster, INP int clb_index, INP t_pack_molecule *molecule, INP float aspect, INOUTP int *num_used_instances_type, INOUTP int *num_instances_type, INP int num_models, INP int max_cluster_size, INP int max_nets_in_pb_type, INP int detailed_routing_stage)
void free_cluster_placement_stats(INOUTP t_cluster_placement_stats *cluster_placement_stats_list)
static t_pack_molecule * get_seed_logical_molecule_with_most_ext_inputs(int max_molecule_inputs)
void * my_calloc(size_t nelem, size_t size)
static int * net_output_feeds_driving_block_input
void do_timing_analysis(t_slack *slacks, boolean is_prepacked, boolean do_lut_input_balancing, boolean is_final_analysis)
void print_clustering_timing_info(const char *fname)
void reset_legalizer_for_cluster(t_block *clb)
void output_blif(t_block *clb, int num_clusters, boolean global_clocks, boolean *is_clock, const char *out_fname, boolean skip_clustering)
boolean getEchoEnabled(void)
t_prepacked_tnode_data * prepacked_data
static struct s_molecule_link * unclustered_list_head
static void alloc_and_init_clustering(boolean global_clocks, float alpha, float beta, int max_cluster_size, int max_molecule_inputs, int max_pb_depth, int max_models, t_cluster_placement_stats **cluster_placement_stats, t_pb_graph_node ***primitives_list, t_pack_molecule *molecules_head, int num_molecules)
static float * block_criticality
boolean try_breadth_first_route_cluster(void)
static void check_clocks(boolean *is_clock)
t_slack * alloc_and_load_pre_packing_timing_graph(float block_delay, float inter_cluster_net_delay, t_model *models, t_timing_inf timing_inf)
static void free_pb_stats_recursive(t_pb *pb)
static void * my_malloc(int ibytes)
void output_clustering(t_block *clb, int num_clusters, boolean global_clocks, boolean *is_clock, char *out_fname, boolean skip_clustering)
static t_pack_molecule * get_most_critical_seed_molecule(int *indexofcrit)
boolean has_valid_normalized_T_arr(int inode)
static enum e_block_pack_status try_pack_molecule(INOUTP t_cluster_placement_stats *cluster_placement_stats_ptr, INP t_pack_molecule *molecule, INOUTP t_pb_graph_node **primitives_list, INOUTP t_pb *pb, INP int max_models, INP int max_cluster_size, INP int clb_index, INP int max_nets_in_pb_type, INP int detailed_routing_stage)
static void print_block_criticalities(const char *fname)
boolean isEchoFileEnabled(enum e_echo_files echo_option)
struct s_pack_molecule * next
void print_criticality(t_slack *slacks, boolean criticality_is_normalized, const char *fname)
static struct s_molecule_link * memory_pool
float ** timing_criticality
void print_slack(float **slack, boolean slack_is_normalized, const char *fname)
void print_timing_graph(const char *fname)
struct s_type_descriptor * type_descriptors
char * getEchoFileName(enum e_echo_files echo_option)
t_logical_block ** logical_block_ptrs
static void alloc_and_load_cluster_info(INP int num_clb, INOUTP t_block *clb)
void save_cluster_solution(void)
void free_timing_graph(t_slack *slacks)
struct s_logical_block * logical_block
static void update_cluster_stats(INP t_pack_molecule *molecule, INP int clb_index, INP boolean *is_clock, INP boolean global_clocks, INP float alpha, INP float beta, INP boolean timing_driven, INP boolean connection_driven, INP t_slack *slacks)