VPR-7.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
place_macro.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  s_pl_macro_member
 
struct  s_pl_macro
 

Macros

#define PALCE_MACRO_H
 

Typedefs

typedef struct s_pl_macro_member t_pl_macro_member
 
typedef struct s_pl_macro t_pl_macro
 

Functions

int alloc_and_load_placement_macros (t_direct_inf *directs, int num_directs, t_pl_macro **chains)
 
void get_imacro_from_iblk (int *imacro, int iblk, t_pl_macro *macros, int num_macros)
 
void free_placement_macros_structs (void)
 

Macro Definition Documentation

#define PALCE_MACRO_H

Definition at line 136 of file place_macro.h.

Typedef Documentation

typedef struct s_pl_macro t_pl_macro

Function Documentation

int alloc_and_load_placement_macros ( t_direct_inf directs,
int  num_directs,
t_pl_macro **  chains 
)

Definition at line 281 of file place_macro.c.

281  {
282 
283  /* This function allocates and loads the macros placement macros *
284  * and returns the total number of macros in 2 steps. *
285  * 1) Allocate temporary data structure for maximum possible *
286  * size and loops through all the blocks storing the data *
287  * relevant to the carry chains. At the same time, also count *
288  * the amount of memory required for the actual variables. *
289  * 2) Allocate the actual variables with the exact amount of *
290  * memory. Then loads the data from the temporary data *
291  * structures before freeing them. *
292  * *
293  * For pl_macro_member_blk_num, allocate for the first dimension *
294  * only at first. Allocate for the second dimemsion when I know *
295  * the size. Otherwise, the array is going to be of size *
296  * num_blocks^2 (There are big benckmarks VPR that have num_blocks *
297  * in the 100k's range). *
298  * *
299  * The placement macro array is freed by the caller(s). */
300 
301  /* Declaration of local variables */
302  int imacro, imember, num_macro;
303  int *pl_macro_idirect, *pl_macro_num_members, **pl_macro_member_blk_num,
304  *pl_macro_member_blk_num_of_this_blk;
305 
306  t_pl_macro * macro = NULL;
307 
308  /* Sets up the required variables. */
309  alloc_and_load_idirect_from_blk_pin(directs, num_directs,
311 
312  /* Allocate maximum memory for temporary variables. */
313  pl_macro_num_members = (int *) my_calloc (num_blocks , sizeof(int));
314  pl_macro_idirect = (int *) my_calloc (num_blocks , sizeof(int));
315  pl_macro_member_blk_num = (int **) my_calloc (num_blocks , sizeof(int*));
316  pl_macro_member_blk_num_of_this_blk = (int *) my_calloc (num_blocks , sizeof(int));
317 
318  /* Compute required size: *
319  * Go through all the pins with possible direct connections in *
320  * f_idirect_from_blk_pin. Count the number of heads (which is the same *
321  * as the number macros) and also the length of each macro *
322  * Head - blocks with to_pin OPEN and from_pin connected *
323  * Tail - blocks with to_pin connected and from_pin OPEN */
324  num_macro = 0;
325  find_all_the_macro (&num_macro, pl_macro_member_blk_num_of_this_blk,
326  pl_macro_idirect, pl_macro_num_members, pl_macro_member_blk_num);
327 
328  /* Allocate the memories for the macro. */
329  macro = (t_pl_macro *) my_malloc (num_macro * sizeof(t_pl_macro));
330 
331  /* Allocate the memories for the chaim members. *
332  * Load the values from the temporary data structures. */
333  for (imacro = 0; imacro < num_macro; imacro++) {
334  macro[imacro].num_blocks = pl_macro_num_members[imacro];
335  macro[imacro].members = (t_pl_macro_member *) my_malloc
336  (macro[imacro].num_blocks * sizeof(t_pl_macro_member));
337 
338  /* Load the values for each member of the macro */
339  for (imember = 0; imember < macro[imacro].num_blocks; imember++) {
340  macro[imacro].members[imember].x_offset = imember * directs[pl_macro_idirect[imacro]].x_offset;
341  macro[imacro].members[imember].y_offset = imember * directs[pl_macro_idirect[imacro]].y_offset;
342  macro[imacro].members[imember].z_offset = directs[pl_macro_idirect[imacro]].z_offset;
343  macro[imacro].members[imember].blk_index = pl_macro_member_blk_num[imacro][imember];
344  }
345  }
346 
347  /* Frees up the temporary data structures. */
348  free(pl_macro_num_members);
349  free(pl_macro_idirect);
350  for(imacro=0; imacro < num_macro; imacro++) {
351  free(pl_macro_member_blk_num[imacro]);
352  }
353  free(pl_macro_member_blk_num);
354  free(pl_macro_member_blk_num_of_this_blk);
355 
356  /* Returns the pointer to the macro by reference. */
357  *macros = macro;
358  return (num_macro);
359 
360 }
static int ** f_direct_type_from_blk_pin
Definition: place_macro.c:164
void * my_calloc(size_t nelem, size_t size)
Definition: util.c:132
int num_blocks
Definition: place_macro.h:158
static int ** f_idirect_from_blk_pin
Definition: place_macro.c:157
int num_blocks
Definition: globals.c:30
static void find_all_the_macro(int *num_of_macro, int *pl_macro_member_blk_num_of_this_blk, int *pl_macro_idirect, int *pl_macro_num_members, int **pl_macro_member_blk_num)
Definition: place_macro.c:183
t_pl_macro_member * members
Definition: place_macro.h:159
static void * my_malloc(int ibytes)
Definition: graphics.c:499
void alloc_and_load_idirect_from_blk_pin(t_direct_inf *directs, int num_directs, int ***idirect_from_blk_pin, int ***direct_type_from_blk_pin)
Definition: vpr_utils.c:1073

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void free_placement_macros_structs ( void  )

Definition at line 421 of file place_macro.c.

421  {
422 
423  /* This function frees up all the static data structures used. */
424 
425  // This frees up the two arrays and set the pointers to NULL
426  int itype;
427  if ( f_idirect_from_blk_pin != NULL ) {
428  for (itype = 1; itype < num_types; itype++) {
429  free(f_idirect_from_blk_pin[itype]);
430  }
432  f_idirect_from_blk_pin = NULL;
433  }
434 
435  if ( f_direct_type_from_blk_pin != NULL ) {
436  for (itype = 1; itype < num_types; itype++) {
437  free(f_direct_type_from_blk_pin[itype]);
438  }
441  }
442 
443  // This frees up the imacro from iblk mapping array.
445 
446 }
static int ** f_direct_type_from_blk_pin
Definition: place_macro.c:164
static int ** f_idirect_from_blk_pin
Definition: place_macro.c:157
static void free_imacro_from_iblk(void)
Definition: place_macro.c:380
int num_types
Definition: globals.c:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void get_imacro_from_iblk ( int *  imacro,
int  iblk,
t_pl_macro macros,
int  num_macros 
)

Definition at line 362 of file place_macro.c.

362  {
363 
364  /* This mapping is needed for fast lookup's whether the block with index *
365  * iblk belongs to a placement macro or not. *
366  * *
367  * The array f_imacro_from_iblk is used for the mapping for speed reason *
368  * [0...num_blocks-1] */
369 
370  /* If the array is not allocated and loaded, allocate it. */
371  if (f_imacro_from_iblk == NULL) {
372  alloc_and_load_imacro_from_iblk(macros, num_macros);
373  }
374 
375  /* Return the imacro for the block. */
376  *imacro = f_imacro_from_iblk[iblk];
377 
378 }
static void alloc_and_load_imacro_from_iblk(t_pl_macro *macros, int num_macros)
Definition: place_macro.c:394
static int * f_imacro_from_iblk
Definition: place_macro.c:169

+ Here is the call graph for this function:

+ Here is the caller graph for this function: