VPR-6.0
|
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 /*************** Variables and defines local to this module ****************/ 00009 00010 #define LONGLINE 0 00011 00012 00013 00014 /******************* Subroutine definitions ********************************/ 00015 00016 00017 /** Computes statistics on the fractional utilization of segments by type 00018 * (index) and by length. This routine needs a valid rr_graph, and a 00019 * completed routing. Note that segments cut off by the end of the array 00020 * are counted as full-length segments (e.g. length 4 even if the last 2 00021 * units of wire were chopped off by the chip edge). 00022 */ 00023 void 00024 get_segment_usage_stats(int num_segment, 00025 t_segment_inf * segment_inf) 00026 { 00027 int inode, length, seg_type, max_segment_length, cost_index; 00028 int *seg_occ_by_length, *seg_cap_by_length; /* [0..max_segment_length] */ 00029 int *seg_occ_by_type, *seg_cap_by_type; /* [0..num_segment-1] */ 00030 float utilization; 00031 00032 00033 max_segment_length = 0; 00034 for(seg_type = 0; seg_type < num_segment; seg_type++) 00035 { 00036 if(segment_inf[seg_type].longline == FALSE) 00037 max_segment_length = max(max_segment_length, 00038 segment_inf[seg_type].length); 00039 } 00040 00041 seg_occ_by_length = (int *)my_calloc((max_segment_length + 1), 00042 sizeof(int)); 00043 seg_cap_by_length = (int *)my_calloc((max_segment_length + 1), 00044 sizeof(int)); 00045 00046 seg_occ_by_type = (int *)my_calloc(num_segment, sizeof(int)); 00047 seg_cap_by_type = (int *)my_calloc(num_segment, sizeof(int)); 00048 00049 00050 for(inode = 0; inode < num_rr_nodes; inode++) 00051 { 00052 if(rr_node[inode].type == CHANX || rr_node[inode].type == CHANY) 00053 { 00054 cost_index = rr_node[inode].cost_index; 00055 seg_type = rr_indexed_data[cost_index].seg_index; 00056 00057 if(!segment_inf[seg_type].longline) 00058 length = segment_inf[seg_type].length; 00059 else 00060 length = LONGLINE; 00061 00062 seg_occ_by_length[length] += rr_node[inode].occ; 00063 seg_cap_by_length[length] += rr_node[inode].capacity; 00064 seg_occ_by_type[seg_type] += rr_node[inode].occ; 00065 seg_cap_by_type[seg_type] += rr_node[inode].capacity; 00066 00067 } 00068 } 00069 00070 printf("\nSegment usage by type (index):\n"); 00071 printf("Segment type Fractional utilization\n"); 00072 printf("------------ ----------------------\n"); 00073 00074 for(seg_type = 0; seg_type < num_segment; seg_type++) 00075 { 00076 if(seg_cap_by_type[seg_type] != 0) 00077 { 00078 utilization = (float)seg_occ_by_type[seg_type] / 00079 (float)seg_cap_by_type[seg_type]; 00080 printf("%8d %5.3g\n", seg_type, 00081 utilization); 00082 } 00083 } 00084 00085 00086 printf("\nSegment usage by length:\n"); 00087 printf("Segment length Fractional utilization\n"); 00088 printf("-------------- ----------------------\n"); 00089 00090 00091 for(length = 1; length <= max_segment_length; length++) 00092 { 00093 if(seg_cap_by_length[length] != 0) 00094 { 00095 utilization = (float)seg_occ_by_length[length] / 00096 (float)seg_cap_by_length[length]; 00097 printf("%9d %5.3g\n", length, 00098 utilization); 00099 } 00100 } 00101 00102 if(seg_cap_by_length[LONGLINE] != 0) 00103 { 00104 utilization = (float)seg_occ_by_length[LONGLINE] / 00105 (float)seg_cap_by_length[LONGLINE]; 00106 printf(" longline %5.3g\n", utilization); 00107 } 00108 00109 00110 free(seg_occ_by_length); 00111 free(seg_cap_by_length); 00112 free(seg_occ_by_type); 00113 free(seg_cap_by_type); 00114 }