00001 #include <stdio.h>
00002 #include "util.h"
00003 #include "vpr_types.h"
00004 #include "globals.h"
00005 #include "segment_stats.h"
00006
00007
00008
00009
00010 #define LONGLINE 0
00011
00012
00013
00014
00015
00016
00017 void
00018 get_segment_usage_stats(int num_segment,
00019 t_segment_inf * segment_inf)
00020 {
00021
00022
00023
00024
00025
00026
00027
00028 int inode, length, seg_type, max_segment_length, cost_index;
00029 int *seg_occ_by_length, *seg_cap_by_length;
00030 int *seg_occ_by_type, *seg_cap_by_type;
00031 float utilization;
00032
00033
00034 max_segment_length = 0;
00035 for(seg_type = 0; seg_type < num_segment; seg_type++)
00036 {
00037 if(segment_inf[seg_type].longline == FALSE)
00038 max_segment_length = max(max_segment_length,
00039 segment_inf[seg_type].length);
00040 }
00041
00042 seg_occ_by_length = (int *)my_calloc((max_segment_length + 1),
00043 sizeof(int));
00044 seg_cap_by_length = (int *)my_calloc((max_segment_length + 1),
00045 sizeof(int));
00046
00047 seg_occ_by_type = (int *)my_calloc(num_segment, sizeof(int));
00048 seg_cap_by_type = (int *)my_calloc(num_segment, sizeof(int));
00049
00050
00051 for(inode = 0; inode < num_rr_nodes; inode++)
00052 {
00053 if(rr_node[inode].type == CHANX || rr_node[inode].type == CHANY)
00054 {
00055 cost_index = rr_node[inode].cost_index;
00056 seg_type = rr_indexed_data[cost_index].seg_index;
00057
00058 if(!segment_inf[seg_type].longline)
00059 length = segment_inf[seg_type].length;
00060 else
00061 length = LONGLINE;
00062
00063 seg_occ_by_length[length] += rr_node[inode].occ;
00064 seg_cap_by_length[length] += rr_node[inode].capacity;
00065 seg_occ_by_type[seg_type] += rr_node[inode].occ;
00066 seg_cap_by_type[seg_type] += rr_node[inode].capacity;
00067
00068 }
00069 }
00070
00071 printf("\nSegment usage by type (index):\n");
00072 printf("Segment type Fractional utilization\n");
00073 printf("------------ ----------------------\n");
00074
00075 for(seg_type = 0; seg_type < num_segment; seg_type++)
00076 {
00077 if(seg_cap_by_type[seg_type] != 0)
00078 {
00079 utilization = (float)seg_occ_by_type[seg_type] /
00080 (float)seg_cap_by_type[seg_type];
00081 printf("%8d %5.3g\n", seg_type,
00082 utilization);
00083 }
00084 }
00085
00086
00087 printf("\nSegment usage by length:\n");
00088 printf("Segment length Fractional utilization\n");
00089 printf("-------------- ----------------------\n");
00090
00091
00092 for(length = 1; length <= max_segment_length; length++)
00093 {
00094 if(seg_cap_by_length[length] != 0)
00095 {
00096 utilization = (float)seg_occ_by_length[length] /
00097 (float)seg_cap_by_length[length];
00098 printf("%9d %5.3g\n", length,
00099 utilization);
00100 }
00101 }
00102
00103 if(seg_cap_by_length[LONGLINE] != 0)
00104 {
00105 utilization = (float)seg_occ_by_length[LONGLINE] /
00106 (float)seg_cap_by_length[LONGLINE];
00107 printf(" longline %5.3g\n", utilization);
00108 }
00109
00110
00111 free(seg_occ_by_length);
00112 free(seg_cap_by_length);
00113 free(seg_occ_by_type);
00114 free(seg_cap_by_type);
00115 }