VPR-7.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
prepack.h File Reference
#include "arch_types.h"
#include "util.h"
+ Include dependency graph for prepack.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

t_pack_patternsalloc_and_load_pack_patterns (OUTP int *num_packing_patterns)
 
void free_list_of_pack_patterns (INP t_pack_patterns *list_of_pack_patterns, INP int num_packing_patterns)
 
t_pack_moleculealloc_and_load_pack_molecules (INP t_pack_patterns *list_of_pack_patterns, INP int num_packing_patterns, OUTP int *num_pack_molecule)
 

Function Documentation

t_pack_molecule* alloc_and_load_pack_molecules ( INP t_pack_patterns list_of_pack_patterns,
INP int  num_packing_patterns,
OUTP int *  num_pack_molecule 
)

Pre-pack atoms in netlist to molecules

  1. Single atoms are by definition a molecule.
  2. Forced pack molecules are groupings of atoms that matches a t_pack_pattern definition.
  3. Chained molecules are molecules that follow a carry-chain style pattern: ie. a single linear chain that can be split across multiple complex blocks

Definition at line 756 of file prepack.c.

758  {
759  int i, j, best_pattern;
760  t_pack_molecule *list_of_molecules_head;
761  t_pack_molecule *cur_molecule;
762  boolean *is_used;
763 
764  is_used = (boolean*)my_calloc(num_packing_patterns, sizeof(boolean));
765 
766  cur_molecule = list_of_molecules_head = NULL;
767 
768  /* Find forced pack patterns */
769  /* Simplifying assumptions: Each atom can map to at most one molecule, use first-fit mapping based on priority of pattern */
770  /* TODO: Need to investigate better mapping strategies than first-fit */
771  for (i = 0; i < num_packing_patterns; i++) {
772  best_pattern = 0;
773  for(j = 1; j < num_packing_patterns; j++) {
774  if(is_used[best_pattern]) {
775  best_pattern = j;
776  } else if (is_used[j] == FALSE && compare_pack_pattern(&list_of_pack_patterns[j], &list_of_pack_patterns[best_pattern]) == 1) {
777  best_pattern = j;
778  }
779  }
780  assert(is_used[best_pattern] == FALSE);
781  is_used[best_pattern] = TRUE;
782  for (j = 0; j < num_logical_blocks; j++) {
783  cur_molecule = try_create_molecule(list_of_pack_patterns, best_pattern, j);
784  if (cur_molecule != NULL) {
785  cur_molecule->next = list_of_molecules_head;
786  /* In the event of multiple molecules with the same logical block pattern, bias to use the molecule with less costly physical resources first */
787  /* TODO: Need to normalize magical number 100 */
788  cur_molecule->base_gain = cur_molecule->num_blocks
789  - (cur_molecule->pack_pattern->base_cost / 100);
790  list_of_molecules_head = cur_molecule;
791  if(logical_block[j].packed_molecules == NULL || logical_block[j].packed_molecules->data_vptr != cur_molecule) {
792  /* molecule did not cover current atom (possibly because molecule created is part of a long chain that extends past multiple logic blocks), try again */
793  j--;
794  }
795  }
796  }
797  }
798  free(is_used);
799 
800  /* List all logical blocks as a molecule for blocks that do not belong to any molecules.
801  This allows the packer to be consistent as it now packs molecules only instead of atoms and molecules
802 
803  If a block belongs to a molecule, then carrying the single atoms around can make the packing problem
804  more difficult because now it needs to consider splitting molecules.
805  */
806  for (i = 0; i < num_logical_blocks; i++) {
808  if (logical_block[i].packed_molecules == NULL) {
809  cur_molecule = (t_pack_molecule*) my_calloc(1,
810  sizeof(t_pack_molecule));
811  cur_molecule->valid = TRUE;
812  cur_molecule->type = MOLECULE_SINGLE_ATOM;
813  cur_molecule->num_blocks = 1;
814  cur_molecule->root = 0;
815  cur_molecule->num_ext_inputs = logical_block[i].used_input_pins;
816  cur_molecule->chain_pattern = NULL;
817  cur_molecule->pack_pattern = NULL;
818  cur_molecule->logical_block_ptrs = (t_logical_block**) my_malloc(
819  1 * sizeof(t_logical_block*));
820  cur_molecule->logical_block_ptrs[0] = &logical_block[i];
821  cur_molecule->next = list_of_molecules_head;
822  cur_molecule->base_gain = 1;
823  list_of_molecules_head = cur_molecule;
824 
826  sizeof(struct s_linked_vptr));
827  logical_block[i].packed_molecules->data_vptr = (void*) cur_molecule;
828  }
829  }
830 
833  list_of_pack_patterns, num_packing_patterns,
834  list_of_molecules_head);
835  }
836 
837  return list_of_molecules_head;
838 }
void * my_calloc(size_t nelem, size_t size)
Definition: util.c:132
struct s_linked_vptr * packed_molecules
Definition: vpr_types.h:228
boolean getEchoEnabled(void)
Definition: ReadOptions.c:67
t_pack_patterns * pack_pattern
Definition: vpr_types.h:246
static void print_pack_molecules(INP const char *fname, INP t_pack_patterns *list_of_pack_patterns, INP int num_pack_patterns, INP t_pack_molecule *list_of_molecules)
Definition: prepack.c:1009
Definition: util.h:12
static void * my_malloc(int ibytes)
Definition: graphics.c:499
static int compare_pack_pattern(const t_pack_patterns *pattern_a, const t_pack_patterns *pattern_b)
Definition: prepack.c:1124
boolean isEchoFileEnabled(enum e_echo_files echo_option)
Definition: ReadOptions.c:115
struct s_pack_molecule * next
Definition: vpr_types.h:257
void * data_vptr
Definition: util.h:35
int num_logical_blocks
Definition: globals.c:17
enum e_pack_pattern_molecule_type type
Definition: vpr_types.h:245
static t_pack_molecule * try_create_molecule(INP t_pack_patterns *list_of_pack_patterns, INP int pack_pattern_index, INP int block_index)
Definition: prepack.c:867
char * getEchoFileName(enum e_echo_files echo_option)
Definition: ReadOptions.c:122
t_logical_block ** logical_block_ptrs
Definition: vpr_types.h:248
static t_pb_graph_node * get_expected_lowest_cost_primitive_for_logical_block(INP int ilogical_block)
Definition: prepack.c:1063
boolean valid
Definition: vpr_types.h:249
struct s_logical_block * logical_block
Definition: globals.c:20
Definition: util.h:12
t_pb_graph_node * expected_lowest_cost_primitive
Definition: vpr_types.h:230
float base_cost
Definition: cad_types.h:34
t_model_chain_pattern * chain_pattern
Definition: vpr_types.h:247

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

t_pack_patterns* alloc_and_load_pack_patterns ( OUTP int *  num_packing_patterns)

Find all packing patterns in architecture [0..num_packing_patterns-1]

Limitations: Currently assumes that forced pack nets must be single-fanout as this covers all the reasonable architectures we wanted. More complicated structures should probably be handled either downstream (general packing) or upstream (in tech mapping) If this limitation is too constraining, code is designed so that this limitation can be removed

Definition at line 75 of file prepack.c.

75  {
76  int i, j, ncount, k;
77  int L_num_blocks;
78  struct s_hash **nhash;
79  t_pack_patterns *list_of_packing_patterns;
80  t_pb_graph_edge *expansion_edge;
81 
82  /* alloc and initialize array of packing patterns based on architecture complex blocks */
83  nhash = alloc_hash_table();
84  ncount = 0;
85  for (i = 0; i < num_types; i++) {
87  type_descriptors[i].pb_graph_head, nhash, &ncount);
88  }
89 
90  list_of_packing_patterns = alloc_and_init_pattern_list_from_hash(ncount,
91  nhash);
92 
93  /* load packing patterns by traversing the edges to find edges belonging to pattern */
94  for (i = 0; i < ncount; i++) {
95  for (j = 0; j < num_types; j++) {
96  expansion_edge = find_expansion_edge_of_pattern(i,
97  type_descriptors[j].pb_graph_head);
98  if (expansion_edge == NULL) {
99  continue;
100  }
101  L_num_blocks = 0;
102  list_of_packing_patterns[i].base_cost = 0;
104  list_of_packing_patterns, i, NULL, NULL, &L_num_blocks);
105  list_of_packing_patterns[i].num_blocks = L_num_blocks;
106 
107  /* Default settings: A section of a netlist must match all blocks in a pack pattern before it can be made a molecule except for carry-chains. For carry-chains, since carry-chains are typically
108  quite flexible in terms of size, it is optional whether or not an atom in a netlist matches any particular block inside the chain */
109  list_of_packing_patterns[i].is_block_optional = (boolean*) my_malloc(L_num_blocks * sizeof(boolean));
110  for(k = 0; k < L_num_blocks; k++) {
111  list_of_packing_patterns[i].is_block_optional[k] = FALSE;
112  if(list_of_packing_patterns[i].is_chain && list_of_packing_patterns[i].root_block->block_id != k) {
113  list_of_packing_patterns[i].is_block_optional[k] = TRUE;
114  }
115  }
116  break;
117  }
118  }
119 
120  free_hash_table(nhash);
121 
122  *num_packing_patterns = ncount;
123 
124  return list_of_packing_patterns;
125 }
struct s_hash ** alloc_hash_table(void)
Definition: hash.c:7
boolean * is_block_optional
Definition: cad_types.h:36
Definition: util.h:12
void free_hash_table(struct s_hash **hash_table)
Definition: hash.c:18
static void * my_malloc(int ibytes)
Definition: graphics.c:499
static void discover_pattern_names_in_pb_graph_node(INOUTP t_pb_graph_node *pb_graph_node, INOUTP struct s_hash **nhash, INOUTP int *ncount)
Definition: prepack.c:147
static t_pack_patterns * alloc_and_init_pattern_list_from_hash(INP int ncount, INOUTP struct s_hash **nhash)
Definition: prepack.c:298
int num_types
Definition: globals.c:37
struct s_type_descriptor * type_descriptors
Definition: globals.c:38
static void backward_expand_pack_pattern_from_edge(INP t_pb_graph_edge *expansion_edge, INOUTP t_pack_patterns *list_of_packing_patterns, INP int curr_pattern_index, INP t_pb_graph_pin *destination_pin, INP t_pack_pattern_block *destination_block, INP int *L_num_blocks)
Definition: prepack.c:572
static t_pb_graph_edge * find_expansion_edge_of_pattern(INP int pattern_index, INP t_pb_graph_node *pb_graph_node)
Definition: prepack.c:341
Definition: hash.h:3
Definition: util.h:12
float base_cost
Definition: cad_types.h:34

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void free_list_of_pack_patterns ( INP t_pack_patterns list_of_pack_patterns,
INP int  num_packing_patterns 
)

Definition at line 319 of file prepack.c.

319  {
320  int i, j, num_pack_pattern_blocks;
321  t_pack_pattern_block **pattern_block_list;
322  if (list_of_pack_patterns != NULL) {
323  for (i = 0; i < num_packing_patterns; i++) {
324  num_pack_pattern_blocks = list_of_pack_patterns[i].num_blocks;
325  pattern_block_list = (t_pack_pattern_block **)my_calloc(num_pack_pattern_blocks, sizeof(t_pack_pattern_block *));
326  free(list_of_pack_patterns[i].name);
327  free(list_of_pack_patterns[i].is_block_optional);
328  free_pack_pattern(list_of_pack_patterns[i].root_block, pattern_block_list);
329  for (j = 0; j < num_pack_pattern_blocks; j++) {
330  free(pattern_block_list[j]);
331  }
332  free(pattern_block_list);
333  }
334  free(list_of_pack_patterns);
335  }
336 }
void * my_calloc(size_t nelem, size_t size)
Definition: util.c:132
char * name
Definition: hash.h:4
static void free_pack_pattern(INOUTP t_pack_pattern_block *pattern_block, INOUTP t_pack_pattern_block **pattern_block_list)
Definition: prepack.c:841

+ Here is the call graph for this function:

+ Here is the caller graph for this function: