7 #define ABS_DIFF(X, Y) (((X) > (Y))? ((X) - (Y)):((Y) - (X)))
9 #define MAX_LEN MAX_X*2
15 #ifdef PRINT_REL_POS_DISTR
17 print_relative_pos_distr(
void)
23 #ifdef PRINT_REL_POS_DISTR
28 int inet, len, rp, src_x, src_y, dst_x, dst_y, del_x, del_y, min_del,
32 double **relapos_distr;
36 relapos_distr = (
double **)
my_malloc((
nx +
ny + 1) *
sizeof(
double *));
37 for (len = 0; len <=
nx +
ny; len++)
39 relapos[len] = (
int *)
my_calloc(len / 2 + 1,
sizeof(
int));
41 (
double *)
my_calloc((len / 2 + 1),
sizeof(double));
44 for (inet = 0; inet <
num_nets; inet++)
63 min_del = (del_x < del_y) ? del_x : del_y;
65 if (!(min_del <= (len / 2)))
67 vpr_printf(TIO_MESSAGE_ERROR,
"Error calculating relative location min_del = %d, len = %d\n",
73 relapos[len][min_del]++;
79 #ifdef PRINT_REL_POS_DISTR
81 fopen(
"/jayar/b/b5/fang/vpr_test/wirelength/relapos2.bin",
"rb+");
84 for (len = 0; len <=
nx +
ny; len++)
87 for (rp = 0; rp <= len / 2; rp++)
89 sum += relapos[len][rp];
93 #ifdef PRINT_REL_POS_DISTR
99 for (rp = 0; rp <= len / 2; rp++)
102 relapos_distr[len][rp] =
103 (double)relapos[len][rp] / (
double)sum;
106 #ifdef PRINT_REL_POS_DISTR
107 vpr_printf(TIO_MESSAGE_ERROR,
"old %d increased by %d\n", rp_rec.
num_rp[rp], relapos[len][rp]);
108 rp_rec.
num_rp[rp] += relapos[len][rp];
112 #ifdef PRINT_REL_POS_DISTR
120 total_conn[len] = sum;
123 fprintf(stdout,
"Source to sink relative positions:\n");
124 for (len = 1; len <=
nx +
ny; len++)
126 if (total_conn[len] != 0)
128 fprintf(stdout,
"Of 2-pin distance %d exists %d\n\n", len,
130 for (rp = 0; rp <= len / 2; rp++)
132 fprintf(stdout,
"\trp%d\t%d\t\t(%.5f)\n", rp,
133 relapos[len][rp], relapos_distr[len][rp]);
135 fprintf(stdout,
"----------------\n");
139 free((
void *)total_conn);
140 for (len = 0; len <=
nx +
ny; len++)
142 free((
void *)relapos[len]);
143 free((
void *)relapos_distr[len]);
145 free((
void *)relapos);
146 free((
void *)relapos_distr);
148 #ifdef PRINT_REL_POS_DISTR
149 fclose(out_bin_file);
void * my_calloc(size_t nelem, size_t size)
static void * my_malloc(int ibytes)
struct relapos_rec_s relapos_rec_t