SRC/place_stats.c File Reference

#include <stdio.h>
#include <math.h>
#include "util.h"
#include "vpr_types.h"
#include "globals.h"
Include dependency graph for place_stats.c:

Go to the source code of this file.

Data Structures

struct  relapos_rec_s

Defines

#define ABS_DIFF(X, Y)   (((X) > (Y))? ((X) - (Y)):((Y) - (X)))
#define MAX_X   50
#define MAX_LEN   MAX_X*2

Typedefs

typedef struct relapos_rec_s relapos_rec_t

Functions

void print_relative_pos_distr (void)

Define Documentation

#define ABS_DIFF ( X,
 )     (((X) > (Y))? ((X) - (Y)):((Y) - (X)))

Definition at line 7 of file place_stats.c.

#define MAX_LEN   MAX_X*2

Definition at line 9 of file place_stats.c.

#define MAX_X   50

Definition at line 8 of file place_stats.c.


Typedef Documentation

typedef struct relapos_rec_s relapos_rec_t

Function Documentation

void print_relative_pos_distr ( void   ) 

Definition at line 18 of file place_stats.c.

00019 {
00020 
00021 /* Prints out the probability distribution of the relative locations of *
00022  * input pins on a net -- i.e. simulates 2-point net distance probability *
00023  * distribution.                                                        */
00024 #ifdef PRINT_REL_POS_DISTR
00025     FILE *out_bin_file;
00026     relapos_rec_t rp_rec;
00027 #endif /* PRINT_REL_POS_DISTR */
00028 
00029     int inet, len, rp, src_x, src_y, dst_x, dst_y, del_x, del_y, min_del,
00030         sink_pin, sum;
00031     int *total_conn;
00032     int **relapos;
00033     double **relapos_distr;
00034 
00035     total_conn = (int *)my_malloc((nx + ny + 1) * sizeof(int));
00036     relapos = (int **)my_malloc((nx + ny + 1) * sizeof(int *));
00037     relapos_distr = (double **)my_malloc((nx + ny + 1) * sizeof(double *));
00038     for(len = 0; len <= nx + ny; len++)
00039         {
00040             relapos[len] = (int *)my_calloc(len / 2 + 1, sizeof(int));
00041             relapos_distr[len] =
00042                 (double *)my_calloc((len / 2 + 1), sizeof(double));
00043         }
00044 
00045 
00046     for(inet = 0; inet < num_nets; inet++)
00047         {
00048             if(net[inet].is_global == FALSE)
00049                 {
00050 
00051                     src_x = block[net[inet].node_block[0]].x;
00052                     src_y = block[net[inet].node_block[0]].y;
00053 
00054                     for(sink_pin = 1; sink_pin <= net[inet].num_sinks;
00055                         sink_pin++)
00056                         {
00057                             dst_x = block[net[inet].node_block[sink_pin]].x;
00058                             dst_y = block[net[inet].node_block[sink_pin]].y;
00059 
00060                             del_x = ABS_DIFF(dst_x, src_x);
00061                             del_y = ABS_DIFF(dst_y, src_y);
00062 
00063                             len = del_x + del_y;
00064 
00065                             min_del = (del_x < del_y) ? del_x : del_y;
00066 
00067                             if(!(min_del <= (len / 2)))
00068                                 {
00069                                     printf
00070                                         ("Error in calculating relative location min_del = %d, len = %d\n",
00071                                          min_del, len);
00072                                     exit(1);
00073                                 }
00074                             else
00075                                 {
00076                                     relapos[len][min_del]++;
00077                                 }
00078                         }
00079                 }
00080         }
00081 
00082 #ifdef PRINT_REL_POS_DISTR
00083     out_bin_file =
00084         fopen("/jayar/b/b5/fang/vpr_test/wirelength/relapos2.bin", "rb+");
00085 #endif /* PRINT_REL_POS_DISTR */
00086 
00087     for(len = 0; len <= nx + ny; len++)
00088         {
00089             sum = 0;
00090             for(rp = 0; rp <= len / 2; rp++)
00091                 {
00092                     sum += relapos[len][rp];
00093                 }
00094             if(sum != 0)
00095                 {
00096 #ifdef PRINT_REL_POS_DISTR
00097                     fseek(out_bin_file, sizeof(relapos_rec_t) * len,
00098                           SEEK_SET);
00099                     fread(&rp_rec, sizeof(relapos_rec_t), 1, out_bin_file);
00100 #endif /* PRINT_REL_POS_DISTR */
00101 
00102                     for(rp = 0; rp <= len / 2; rp++)
00103                         {
00104 
00105                             relapos_distr[len][rp] =
00106                                 (double)relapos[len][rp] / (double)sum;
00107 
00108                             /* updating the binary record at "len" */
00109 #ifdef PRINT_REL_POS_DISTR
00110                             fprintf(stderr, "old %d increase by %d\n",
00111                                     rp_rec.num_rp[rp], relapos[len][rp]);
00112                             rp_rec.num_rp[rp] += relapos[len][rp];
00113                             fprintf(stderr, "becomes %d\n",
00114                                     rp_rec.num_rp[rp]);
00115 #endif /* PRINT_REL_POS_DISTR */
00116                         }
00117 #ifdef PRINT_REL_POS_DISTR
00118                     /* write back the updated record at "len" */
00119                     fseek(out_bin_file, sizeof(relapos_rec_t) * len,
00120                           SEEK_SET);
00121                     fwrite(&rp_rec, sizeof(relapos_rec_t), 1, out_bin_file);
00122 #endif /* PRINT_REL_POS_DISTR */
00123 
00124                 }
00125             total_conn[len] = sum;
00126         }
00127 
00128     fprintf(stdout, "Source to sink relative positions:\n");
00129     for(len = 1; len <= nx + ny; len++)
00130         {
00131             if(total_conn[len] != 0)
00132                 {
00133                     fprintf(stdout, "Of 2-pin distance %d exists %d\n\n", len,
00134                             total_conn[len]);
00135                     for(rp = 0; rp <= len / 2; rp++)
00136                         {
00137                             fprintf(stdout, "\trp%d\t%d\t\t(%.5f)\n", rp,
00138                                     relapos[len][rp], relapos_distr[len][rp]);
00139                         }
00140                     fprintf(stdout, "----------------\n");
00141                 }
00142         }
00143 
00144     free((void *)total_conn);
00145     for(len = 0; len <= nx + ny; len++)
00146         {
00147             free((void *)relapos[len]);
00148             free((void *)relapos_distr[len]);
00149         }
00150     free((void *)relapos);
00151     free((void *)relapos_distr);
00152 
00153 #ifdef PRINT_REL_POS_DISTR
00154     fclose(out_bin_file);
00155 #endif /* PRINT_REL_POS_DISTR */
00156 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Tue Jan 5 15:26:01 2010 for VPR5.0 by  doxygen 1.6.1