@@ -20,7 +20,7 @@ void get_segment_usage_stats(std::vector<t_segment_inf>& segment_inf) {
2020 * are counted as full-length segments (e.g. length 4 even if the last 2 *
2121 * units of wire were chopped off by the chip edge). */
2222
23- int length, max_segment_length;
23+ int max_segment_length;
2424 RRIndexedDataId cost_index;
2525 float utilization;
2626
@@ -39,9 +39,6 @@ void get_segment_usage_stats(std::vector<t_segment_inf>& segment_inf) {
3939 max_segment_name_length = std::max (max_segment_name_length, static_cast <int >(segment_inf[seg_type].name .size ()));
4040 }
4141
42- std::vector<int > seg_occ_by_length (max_segment_length+1 , 0 );
43- std::vector<int > seg_cap_by_length (max_segment_length+1 , 0 );
44-
4542 std::map<e_parallel_axis, std::vector<int >> directed_occ_by_length = {
4643 {X_AXIS, std::vector<int >(max_segment_length+1 , 0 )},
4744 {Y_AXIS, std::vector<int >(max_segment_length+1 , 0 )}
@@ -52,28 +49,19 @@ void get_segment_usage_stats(std::vector<t_segment_inf>& segment_inf) {
5249 {Y_AXIS, std::vector<int >(max_segment_length+1 , 0 )}
5350 };
5451
55-
56- std::vector<int > seg_occ_by_type (max_segment_length+1 , 0 );
57- std::vector<int > seg_cap_by_type (max_segment_length+1 , 0 );
58-
59-
6052 for (const RRNodeId& rr_id : device_ctx.rr_graph .nodes ()) {
6153 size_t inode = (size_t )rr_id;
6254 auto node_type = rr_graph.node_type (rr_id);
6355 if (node_type == CHANX || node_type == CHANY) {
6456 cost_index = rr_graph.node_cost_index (rr_id);
6557 size_t seg_type = device_ctx.rr_indexed_data [cost_index].seg_index ;
66-
58+ int length = - 1 ;
6759 if (!segment_inf[seg_type].longline )
6860 length = segment_inf[seg_type].length ;
6961 else
7062 length = LONGLINE;
7163 const short & inode_capacity = rr_graph.node_capacity (rr_id);
7264 int occ = route_ctx.rr_node_route_inf [inode].occ ();
73- seg_occ_by_length[length] += occ;
74- seg_cap_by_length[length] += inode_capacity;
75- seg_occ_by_type[seg_type] += occ;
76- seg_cap_by_type[seg_type] += inode_capacity;
7765 VTR_ASSERT (node_type == CHANX|| node_type == CHANY);
7866 auto ax = (node_type == CHANX) ? X_AXIS : Y_AXIS;
7967 VTR_ASSERT (occ <= 1 && inode_capacity <= 1 );
@@ -85,12 +73,15 @@ void get_segment_usage_stats(std::vector<t_segment_inf>& segment_inf) {
8573 VTR_LOG (" \n " );
8674 VTR_LOG (" Total Number of Wiring Segments by Direction: direction length number\n " );
8775 VTR_LOG (" --------- ------ -------\n " );
88- for (length = 0 ; length <= max_segment_length; length++) {
76+ for (int length = 0 ; length <= max_segment_length; length++) {
8977 for (auto ax : {X_AXIS, Y_AXIS}) {
9078 std::string ax_name = (ax==X_AXIS) ? " X" : " Y" ;
9179 if (directed_cap_by_length[ax][length] != 0 ) {
9280 std::string length_str = (length == LONGLINE) ? " longline" : std::to_string (length);
93- VTR_LOG (" %s %s %6d\n " , ax_name.c_str (),
81+ VTR_LOG (" %s%s %s%s %6d\n " ,
82+ std::string (std::max (9 - (int )ax_name.length (), 0 ), ' ' ).c_str (),
83+ ax_name.c_str (),
84+ std::string (std::max (6 - (int )length_str.length (), 0 ), ' ' ).c_str (),
9485 length_str.c_str (),
9586 directed_cap_by_length[ax][length]);
9687 }
@@ -103,11 +94,14 @@ void get_segment_usage_stats(std::vector<t_segment_inf>& segment_inf) {
10394 VTR_LOG (" \n " );
10495 VTR_LOG (" %s - Directed Wiring Segment usage by length: length utilization\n " , ax_name.c_str ());
10596 VTR_LOG (" ------ -----------\n " );
106- for (length = 0 ; length <= max_segment_length; length++) {
97+ for (int length = 0 ; length <= max_segment_length; length++) {
10798 if (directed_cap_by_length[ax][length] != 0 ) {
10899 std::string length_str = (length == LONGLINE) ? " longline" : std::to_string (length);
109100 utilization = (float )directed_occ_by_length[ax][length] / (float )directed_cap_by_length[ax][length];
110- VTR_LOG (" %s %11.3g\n " , length_str.c_str (), utilization);
101+ VTR_LOG (" %s%s %11.3g\n " ,
102+ std::string (std::max (6 - (int )length_str.length (), 0 ), ' ' ).c_str (),
103+ length_str.c_str (),
104+ utilization);
111105 }
112106 }
113107 }
@@ -117,28 +111,18 @@ void get_segment_usage_stats(std::vector<t_segment_inf>& segment_inf) {
117111 VTR_LOG (" %s ---- -----------\n " , std::string (std::max (4 , max_segment_name_length), ' -' ).c_str ());
118112
119113 for (size_t seg_type = 0 ; seg_type < segment_inf.size (); seg_type++) {
120- if (seg_cap_by_type[seg_type] != 0 ) {
114+ int seg_length = segment_inf[seg_type].length ;
115+ if (directed_cap_by_length[X_AXIS][seg_length] != 0 || directed_cap_by_length[Y_AXIS][seg_length] != 0 ) {
121116 std::string seg_name = segment_inf[seg_type].name ;
122117 int seg_name_size = static_cast <int >(seg_name.size ());
123- utilization = (float )seg_occ_by_type[seg_type] / (float )seg_cap_by_type[seg_type];
118+ int occ = 0 ;
119+ int cap = 0 ;
120+ for (auto ax : {X_AXIS, Y_AXIS}) {
121+ occ += directed_occ_by_length[ax][seg_length];
122+ cap = directed_cap_by_length[ax][seg_length];
123+ }
124+ utilization = (float )occ / (float )cap;
124125 VTR_LOG (" %s%s %4d %11.3g\n " , std::string (std::max (4 - seg_name_size, (max_segment_name_length - seg_name_size)), ' ' ).c_str (), seg_name.c_str (), seg_type, utilization);
125126 }
126127 }
127-
128- VTR_LOG (" \n " );
129- VTR_LOG (" Segment usage by length: length utilization\n " );
130- VTR_LOG (" ------ -----------\n " );
131-
132- for (length = 1 ; length <= max_segment_length; length++) {
133- if (seg_cap_by_length[length] != 0 ) {
134- utilization = (float )seg_occ_by_length[length] / (float )seg_cap_by_length[length];
135- VTR_LOG (" %6d %11.3g\n " , length, utilization);
136- }
137- }
138- VTR_LOG (" \n " );
139-
140- if (seg_cap_by_length[LONGLINE] != 0 ) {
141- utilization = (float )seg_occ_by_length[LONGLINE] / (float )seg_cap_by_length[LONGLINE];
142- VTR_LOG (" longline %5.3g\n " , utilization);
143- }
144128}
0 commit comments