@@ -20,55 +20,67 @@ void get_segment_usage_stats(std::vector<t_segment_inf>& segment_inf) {
20
20
* are counted as full-length segments (e.g. length 4 even if the last 2 *
21
21
* units of wire were chopped off by the chip edge). */
22
22
23
- int max_segment_length;
24
23
RRIndexedDataId cost_index;
25
24
float utilization;
26
25
27
26
auto & device_ctx = g_vpr_ctx.device ();
28
27
const auto & rr_graph = device_ctx.rr_graph ;
29
28
auto & route_ctx = g_vpr_ctx.routing ();
30
29
31
- max_segment_length = 0 ;
32
30
int max_segment_name_length = 0 ;
33
- for (size_t seg_type = 0 ; seg_type < segment_inf.size (); seg_type++) {
34
- if (segment_inf[seg_type].longline == false ) {
35
- max_segment_length = std::max (max_segment_length,
36
- segment_inf[seg_type].length );
31
+ std::map<e_parallel_axis, std::map<int , int >> directed_occ_by_length = {
32
+ {X_AXIS, std::map<int , int >()},
33
+ {Y_AXIS, std::map<int , int >()}};
34
+
35
+ std::map<e_parallel_axis, std::map<int , int >> directed_cap_by_length = {
36
+ {X_AXIS, std::map<int , int >()},
37
+ {Y_AXIS, std::map<int , int >()}};
38
+
39
+ std::set<int , std::less<int >> segment_lengths;
40
+ for (const auto & seg_inf : segment_inf) {
41
+ int seg_length = seg_inf.longline ? LONGLINE : seg_inf.length ;
42
+
43
+ for (auto ax : {X_AXIS, Y_AXIS}) {
44
+ directed_cap_by_length[ax].insert ({seg_length, 0 });
45
+ directed_occ_by_length[ax].insert ({seg_length, 0 });
37
46
}
38
47
39
- max_segment_name_length = std::max (max_segment_name_length, static_cast <int >(segment_inf[seg_type].name .size ()));
48
+ segment_lengths.insert (seg_length);
49
+
50
+ max_segment_name_length = std::max (max_segment_name_length, static_cast <int >(seg_inf.name .size ()));
40
51
}
41
52
42
- std::map<e_parallel_axis, std::vector<int >> directed_occ_by_length = {
43
- {X_AXIS, std::vector<int >(max_segment_length + 1 , 0 )},
44
- {Y_AXIS, std::vector<int >(max_segment_length + 1 , 0 )}};
53
+ std::map<e_parallel_axis, std::vector<int >> directed_occ_by_type = {
54
+ {X_AXIS, std::vector<int >(segment_inf. size () , 0 )},
55
+ {Y_AXIS, std::vector<int >(segment_inf. size () , 0 )}};
45
56
46
- std::map<e_parallel_axis, std::vector<int >> directed_cap_by_length = {
47
- {X_AXIS, std::vector<int >(max_segment_length + 1 , 0 )},
48
- {Y_AXIS, std::vector<int >(max_segment_length + 1 , 0 )}};
57
+ std::map<e_parallel_axis, std::vector<int >> directed_cap_by_type = {
58
+ {X_AXIS, std::vector<int >(segment_inf. size () , 0 )},
59
+ {Y_AXIS, std::vector<int >(segment_inf. size () , 0 )}};
49
60
50
61
for (RRNodeId inode : device_ctx.rr_graph .nodes ()) {
51
62
auto node_type = rr_graph.node_type (inode);
52
63
if (node_type == CHANX || node_type == CHANY) {
53
64
cost_index = rr_graph.node_cost_index (inode);
54
65
size_t seg_type = device_ctx.rr_indexed_data [cost_index].seg_index ;
55
- int length = -1 ;
56
- if (!segment_inf[seg_type].longline )
57
- length = segment_inf[seg_type].length ;
58
- else
59
- length = LONGLINE;
66
+ int length = segment_inf[seg_type].longline ? LONGLINE : segment_inf[seg_type].length ;
67
+
60
68
const short & inode_capacity = rr_graph.node_capacity (inode);
61
69
int occ = route_ctx.rr_node_route_inf [inode].occ ();
62
70
auto ax = (node_type == CHANX) ? X_AXIS : Y_AXIS;
71
+
63
72
directed_occ_by_length[ax][length] += occ;
64
73
directed_cap_by_length[ax][length] += inode_capacity;
74
+
75
+ directed_occ_by_type[ax][seg_type] += occ;
76
+ directed_cap_by_type[ax][seg_type] += inode_capacity;
65
77
}
66
78
}
67
79
68
80
VTR_LOG (" \n " );
69
81
VTR_LOG (" Total Number of Wiring Segments by Direction: direction length number\n " );
70
82
VTR_LOG (" --------- ------ -------\n " );
71
- for (int length = 0 ; length <= max_segment_length; length++ ) {
83
+ for (auto length : segment_lengths ) {
72
84
for (auto ax : {X_AXIS, Y_AXIS}) {
73
85
std::string ax_name = (ax == X_AXIS) ? " X" : " Y" ;
74
86
if (directed_cap_by_length[ax][length] != 0 ) {
@@ -88,35 +100,52 @@ void get_segment_usage_stats(std::vector<t_segment_inf>& segment_inf) {
88
100
VTR_LOG (" \n " );
89
101
VTR_LOG (" %s - Directed Wiring Segment usage by length: length utilization\n " , ax_name.c_str ());
90
102
VTR_LOG (" ------ -----------\n " );
91
- for (int length = 0 ; length <= max_segment_length; length++ ) {
103
+ for (auto length : segment_lengths ) {
92
104
if (directed_cap_by_length[ax][length] != 0 ) {
93
105
std::string length_str = (length == LONGLINE) ? " longline" : std::to_string (length);
94
106
utilization = (float )directed_occ_by_length[ax][length] / (float )directed_cap_by_length[ax][length];
95
107
VTR_LOG (" %s%s %11.3g\n " ,
96
- std::string (std::max (6 - (int )length_str.length (), 0 ), ' ' ).c_str (),
108
+ std::string (std::max (7 - (int )length_str.length (), 0 ), ' ' ).c_str (),
97
109
length_str.c_str (),
98
110
utilization);
99
111
}
100
112
}
101
113
}
102
114
103
115
VTR_LOG (" \n " );
104
- VTR_LOG (" Segment usage by type (index): %sname type utilization\n " , std::string (std::max (max_segment_name_length - 4 , 0 ), ' ' ).c_str ());
105
- VTR_LOG (" %s ---- -----------\n " , std::string (std::max (4 , max_segment_name_length), ' -' ).c_str ());
116
+ VTR_LOG (" Segment occupancy by length: Length utilization\n " );
117
+ VTR_LOG (" ------ -----------\n " );
118
+ for (const auto & seg_length : segment_lengths) {
119
+ if (directed_cap_by_length[X_AXIS][seg_length] != 0 || directed_cap_by_length[Y_AXIS][seg_length] != 0 ) {
120
+ std::string seg_name = " L" + std::to_string (seg_length);
121
+
122
+ int occ = 0 ;
123
+ int cap = 0 ;
124
+ for (auto ax : {X_AXIS, Y_AXIS}) {
125
+ occ += directed_occ_by_length[ax][seg_length];
126
+ cap += directed_cap_by_length[ax][seg_length];
127
+ }
128
+ utilization = (float )occ / (float )cap;
129
+ VTR_LOG (" %s %11.3g\n " , seg_name.c_str (), utilization);
130
+ }
131
+ }
132
+
133
+ VTR_LOG (" \n " );
134
+ VTR_LOG (" Segment occupancy by type: %sname type utilization\n " , std::string (std::max (max_segment_name_length - 4 , 0 ), ' ' ).c_str ());
135
+ VTR_LOG (" %s ---- -----------\n " , std::string (std::max (4 , max_segment_name_length), ' -' ).c_str ());
106
136
107
137
for (size_t seg_type = 0 ; seg_type < segment_inf.size (); seg_type++) {
108
- int seg_length = segment_inf[seg_type].length ;
109
- if (directed_cap_by_length[X_AXIS][seg_length] != 0 || directed_cap_by_length[Y_AXIS][seg_length] != 0 ) {
138
+ if (directed_cap_by_type[X_AXIS][seg_type] != 0 || directed_cap_by_type[Y_AXIS][seg_type] != 0 ) {
110
139
std::string seg_name = segment_inf[seg_type].name ;
111
140
int seg_name_size = static_cast <int >(seg_name.size ());
112
141
int occ = 0 ;
113
142
int cap = 0 ;
114
143
for (auto ax : {X_AXIS, Y_AXIS}) {
115
- occ += directed_occ_by_length [ax][seg_length ];
116
- cap += directed_cap_by_length [ax][seg_length ];
144
+ occ += directed_occ_by_type [ax][seg_type ];
145
+ cap += directed_cap_by_type [ax][seg_type ];
117
146
}
118
147
utilization = (float )occ / (float )cap;
119
- 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);
148
+ 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);
120
149
}
121
150
}
122
151
}
0 commit comments