@@ -22,8 +22,6 @@ void get_segment_usage_stats(std::vector<t_segment_inf>& segment_inf) {
2222
2323 int length, max_segment_length;
2424 RRIndexedDataId cost_index;
25- int *seg_occ_by_length, *seg_cap_by_length; /* [0..max_segment_length] */
26- int *seg_occ_by_type, *seg_cap_by_type; /* [0..num_segment-1] */
2725 float utilization;
2826
2927 auto & device_ctx = g_vpr_ctx.device ();
@@ -41,8 +39,8 @@ void get_segment_usage_stats(std::vector<t_segment_inf>& segment_inf) {
4139 max_segment_name_length = std::max (max_segment_name_length, static_cast <int >(segment_inf[seg_type].name .size ()));
4240 }
4341
44- seg_occ_by_length = new int [max_segment_length + 1 ] ;
45- seg_cap_by_length = new int [max_segment_length + 1 ] ;
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 ) ;
4644
4745 std::map<e_parallel_axis, std::vector<int >> directed_occ_by_length = {
4846 {X_AXIS, std::vector<int >(max_segment_length+1 , 0 )},
@@ -55,18 +53,9 @@ void get_segment_usage_stats(std::vector<t_segment_inf>& segment_inf) {
5553 };
5654
5755
58- for (int i = 0 ; i < max_segment_length + 1 ; i++) {
59- seg_occ_by_length[i] = 0 ;
60- seg_cap_by_length[i] = 0 ;
61- }
62-
63- seg_occ_by_type = new int [segment_inf.size ()];
64- seg_cap_by_type = new int [segment_inf.size ()];
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 );
6558
66- for (size_t i = 0 ; i < segment_inf.size (); i++) {
67- seg_occ_by_type[i] = 0 ;
68- seg_cap_by_type[i] = 0 ;
69- }
7059
7160 for (const RRNodeId& rr_id : device_ctx.rr_graph .nodes ()) {
7261 size_t inode = (size_t )rr_id;
@@ -96,38 +85,30 @@ void get_segment_usage_stats(std::vector<t_segment_inf>& segment_inf) {
9685 VTR_LOG (" \n " );
9786 VTR_LOG (" Total Number of Wiring Segments by Direction: direction length number\n " );
9887 VTR_LOG (" --------- ------ -------\n " );
99- for (length = 1 ; length <= max_segment_length; length++) {
88+ for (length = 0 ; length <= max_segment_length; length++) {
10089 for (auto ax : {X_AXIS, Y_AXIS}) {
10190 std::string ax_name = (ax==X_AXIS) ? " X" : " Y" ;
10291 if (directed_cap_by_length[ax][length] != 0 ) {
103- VTR_LOG (" %s %4d %6d\n " , ax_name.c_str (),
104- length,
92+ std::string length_str = (length == LONGLINE) ? " longline" : std::to_string (length);
93+ VTR_LOG (" %s %s %6d\n " , ax_name.c_str (),
94+ length_str.c_str (),
10595 directed_cap_by_length[ax][length]);
10696 }
10797 }
10898
10999 }
110100
111-
112- VTR_LOG (" \n " );
113- VTR_LOG (" X - Directed Wiring Segment usage by length: length utilization\n " );
114- VTR_LOG (" ------ -----------\n " );
115-
116- for (length = 1 ; length <= max_segment_length; length++) {
117- if (directed_cap_by_length[X_AXIS][length] != 0 ) {
118- utilization = (float )directed_occ_by_length[X_AXIS][length] / (float )directed_cap_by_length[X_AXIS][length];
119- VTR_LOG (" %6d %11.3g\n " , length, utilization);
120- }
121- }
122-
123- VTR_LOG (" \n " );
124- VTR_LOG (" Y - Directed Wiring Segment usage by length: length utilization\n " );
125- VTR_LOG (" ------ -----------\n " );
126-
127- for (length = 1 ; length <= max_segment_length; length++) {
128- if (directed_cap_by_length[Y_AXIS][length] != 0 ) {
129- utilization = (float )directed_occ_by_length[Y_AXIS][length] / (float )directed_cap_by_length[Y_AXIS][length];
130- VTR_LOG (" %6d %11.3g\n " , length, utilization);
101+ for (auto ax : {X_AXIS, Y_AXIS}) {
102+ std::string ax_name = (ax==X_AXIS) ? " X" : " Y" ;
103+ VTR_LOG (" \n " );
104+ VTR_LOG (" %s - Directed Wiring Segment usage by length: length utilization\n " , ax_name.c_str ());
105+ VTR_LOG (" ------ -----------\n " );
106+ for (length = 0 ; length <= max_segment_length; length++) {
107+ if (directed_cap_by_length[ax][length] != 0 ) {
108+ std::string length_str = (length == LONGLINE) ? " longline" : std::to_string (length);
109+ utilization = (float )directed_occ_by_length[ax][length] / (float )directed_cap_by_length[ax][length];
110+ VTR_LOG (" %s %11.3g\n " , length, utilization);
111+ }
131112 }
132113 }
133114
@@ -160,9 +141,4 @@ void get_segment_usage_stats(std::vector<t_segment_inf>& segment_inf) {
160141 utilization = (float )seg_occ_by_length[LONGLINE] / (float )seg_cap_by_length[LONGLINE];
161142 VTR_LOG (" longline %5.3g\n " , utilization);
162143 }
163-
164- delete[] (seg_occ_by_length);
165- delete[] (seg_cap_by_length);
166- delete[] (seg_occ_by_type);
167- delete[] (seg_cap_by_type);
168144}
0 commit comments