VPR-7.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
timing_place.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <math.h>
3 #include "util.h"
4 #include "vpr_types.h"
5 #include "globals.h"
6 #include "path_delay.h"
7 #include "path_delay2.h"
8 #include "net_delay.h"
9 #include "timing_place_lookup.h"
10 #include "timing_place.h"
11 
12 float **timing_place_crit; /*available externally */
13 
14 static t_chunk timing_place_crit_ch = {NULL, 0, NULL};
15 static t_chunk net_delay_ch = {NULL, 0, NULL};
16 
17 /*static struct s_linked_vptr *timing_place_crit_chunk_list_head;
18 static struct s_linked_vptr *net_delay_chunk_list_head;*/
19 
20 /******** prototypes ******************/
21 /*static float **alloc_crit(struct s_linked_vptr **chunk_list_head_ptr);
22 
23 static void free_crit(struct s_linked_vptr **chunk_list_head_ptr);*/
24 
25 static float **alloc_crit(t_chunk *chunk_list_ptr);
26 
27 static void free_crit(t_chunk *chunk_list_ptr);
28 
29 /**************************************/
30 
31 static float ** alloc_crit(t_chunk *chunk_list_ptr) {
32 
33  /* Allocates space for the timing_place_crit data structure *
34  * [0..num_nets-1][1..num_pins-1]. I chunk the data to save space on large *
35  * problems. */
36 
37  float **local_crit; /* [0..num_nets-1][1..num_pins-1] */
38  float *tmp_ptr;
39  int inet;
40 
41  local_crit = (float **) my_malloc(num_nets * sizeof(float *));
42 
43  for (inet = 0; inet < num_nets; inet++) {
44  tmp_ptr = (float *) my_chunk_malloc(
45  (clb_net[inet].num_sinks) * sizeof(float), chunk_list_ptr);
46  local_crit[inet] = tmp_ptr - 1; /* [1..num_sinks] */
47  }
48 
49  return (local_crit);
50 }
51 
52 /**************************************/
53 static void free_crit(t_chunk *chunk_list_ptr){
54  free_chunk_memory(chunk_list_ptr);
55 }
56 
57 /**************************************/
58 void print_sink_delays(const char *fname) {
59 
60  int num_at_level, num_edges, inode, ilevel, i;
61  FILE *fp;
62 
63  fp = my_fopen(fname, "w", 0);
64 
65  for (ilevel = num_tnode_levels - 1; ilevel >= 0; ilevel--) {
66  num_at_level = tnodes_at_level[ilevel].nelem;
67 
68  for (i = 0; i < num_at_level; i++) {
69  inode = tnodes_at_level[ilevel].list[i];
70  num_edges = tnode[inode].num_edges;
71 
72  if (num_edges == 0) { /* sink */
73  fprintf(fp, "%g\n", tnode[inode].T_arr);
74  }
75  }
76  }
77  fclose(fp);
78 }
79 
80 /**************************************/
81 void load_criticalities(t_slack * slacks, float crit_exponent) {
82  /* Performs a 1-to-1 mapping from criticality to timing_place_crit.
83  For every pin on every net (or, equivalently, for every tedge ending
84  in that pin), timing_place_crit = criticality^(criticality exponent) */
85 
86  int inet, ipin;
87 #ifdef PATH_COUNTING
88  float timing_criticality, path_criticality;
89 #endif
90 
91  for (inet = 0; inet < num_nets; inet++) {
92  if (inet == OPEN)
93  continue;
94  if (clb_net[inet].is_global)
95  continue;
96  for (ipin = 1; ipin <= clb_net[inet].num_sinks; ipin++) {
97  if (slacks->timing_criticality[inet][ipin] < HUGE_NEGATIVE_FLOAT + 1) {
98  /* We didn't analyze this connection, so give it a timing_place_crit of 0. */
99  timing_place_crit[inet][ipin] = 0.;
100  } else {
101 #ifdef PATH_COUNTING
102  /* Calculate criticality as a weighted sum of timing criticality and path
103  criticality. The placer likes a great deal of contrast between criticalities.
104  Since path criticality varies much more than timing, we "sharpen" timing
105  criticality by taking it to some power, crit_exponent (between 1 and 8 by default). */
106  path_criticality = slacks->path_criticality[inet][ipin];
107  timing_criticality = pow(slacks->timing_criticality[inet][ipin], crit_exponent);
108 
109  timing_place_crit[inet][ipin] = PLACE_PATH_WEIGHT * path_criticality
110  + (1 - PLACE_PATH_WEIGHT) * timing_criticality;
111 #else
112  /* Just take timing criticality to some power (crit_exponent). */
113  timing_place_crit[inet][ipin] = pow(slacks->timing_criticality[inet][ipin], crit_exponent);
114 #endif
115  }
116  }
117  }
118 }
119 
120 /**************************************/
122  struct s_router_opts router_opts,
123  struct s_det_routing_arch det_routing_arch, t_segment_inf * segment_inf,
124  t_timing_inf timing_inf, float ***net_delay, INP t_direct_inf *directs,
125  INP int num_directs) {
126 
127  t_slack * slacks = alloc_and_load_timing_graph(timing_inf);
128 
129  (*net_delay) = alloc_net_delay(&net_delay_ch, clb_net,
130  num_nets);
131 
132  compute_delay_lookup_tables(router_opts, det_routing_arch, segment_inf,
133  timing_inf, chan_width_dist, directs, num_directs);
134 
135  timing_place_crit = alloc_crit(&timing_place_crit_ch);
136 
137  return slacks;
138 }
139 
140 /**************************************/
142 
143  free(timing_place_crit);
144  free_crit(&timing_place_crit_ch);
145 
146  free_timing_graph(slacks);
147  free_net_delay(*net_delay, &net_delay_ch);
148 
150 }
151 
152 /**************************************/
static float ** alloc_crit(t_chunk *chunk_list_ptr)
Definition: timing_place.c:31
struct s_ivec * tnodes_at_level
Definition: path_delay2.c:12
Definition: util.h:57
FILE * my_fopen(const char *fname, const char *flag, int prompt)
Definition: util.c:54
int * list
Definition: util.h:49
float ** timing_place_crit
Definition: timing_place.c:12
static float ** net_delay
void * my_chunk_malloc(size_t size, t_chunk *chunk_info)
Definition: util.c:184
void free_lookups_and_criticalities(float ***net_delay, t_slack *slacks)
Definition: timing_place.c:141
static t_chunk timing_place_crit_ch
Definition: timing_place.c:14
void free_place_lookup_structs(void)
int num_nets
Definition: globals.c:27
int num_edges
Definition: vpr_types.h:342
static void free_crit(t_chunk *chunk_list_ptr)
Definition: timing_place.c:53
int num_tnode_levels
Definition: path_delay2.c:10
void load_criticalities(t_slack *slacks, float crit_exponent)
Definition: timing_place.c:81
static void * my_malloc(int ibytes)
Definition: graphics.c:499
boolean * is_global
t_tnode * tnode
Definition: path_delay.c:143
struct s_net * clb_net
Definition: globals.c:28
int nelem
Definition: util.h:48
#define INP
Definition: util.h:19
static t_chunk net_delay_ch
Definition: timing_place.c:15
void print_sink_delays(const char *fname)
Definition: timing_place.c:58
void free_net_delay(float **net_delay, t_chunk *chunk_list_ptr)
Definition: net_delay.c:127
void compute_delay_lookup_tables(struct s_router_opts router_opts, struct s_det_routing_arch det_routing_arch, t_segment_inf *segment_inf, t_timing_inf timing_inf, t_chan_width_dist chan_width_dist, INP t_direct_inf *directs, INP int num_directs)
float ** alloc_net_delay(t_chunk *chunk_list_ptr, struct s_net *nets, int n_nets)
Definition: net_delay.c:103
t_slack * alloc_and_load_timing_graph(t_timing_inf timing_inf)
Definition: path_delay.c:239
float ** timing_criticality
Definition: vpr_types.h:406
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)
Definition: timing_place.c:121
Definition: slre.c:50
void free_chunk_memory(t_chunk *chunk_info)
Definition: util.c:270
void free_timing_graph(t_slack *slacks)
Definition: path_delay.c:390
#define HUGE_NEGATIVE_FLOAT
Definition: vpr_types.h:80
int num_sinks
Definition: vpr_types.h:506