Skip to content

Commit f2a0cf9

Browse files
committed
iterate over seg lengths instead of getting index
1 parent ea948da commit f2a0cf9

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

vpr/src/route/segment_stats.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ void get_segment_usage_stats(std::vector<t_segment_inf>& segment_inf) {
4242
for (const auto& seg_inf: segment_inf) {
4343
int seg_length = seg_inf.longline ? LONGLINE : seg_inf.length;
4444

45-
directed_cap_by_length[X_AXIS].insert({seg_length, 0});
46-
directed_cap_by_length[Y_AXIS].insert({seg_length, 0});
45+
for (auto ax : {X_AXIS, Y_AXIS}) {
46+
directed_cap_by_length[ax].insert({seg_length, 0});
47+
directed_occ_by_length[ax].insert({seg_length, 0});
48+
}
49+
4750

48-
directed_occ_by_length[X_AXIS].insert({seg_length, 0});
49-
directed_occ_by_length[Y_AXIS].insert({seg_length, 0});
5051
segment_lengths.insert(seg_length);
5152

5253
max_segment_name_length = std::max(max_segment_name_length, static_cast<int>(seg_inf.name.size()));
@@ -65,14 +66,12 @@ void get_segment_usage_stats(std::vector<t_segment_inf>& segment_inf) {
6566
if (node_type == CHANX || node_type == CHANY) {
6667
cost_index = rr_graph.node_cost_index(inode);
6768
size_t seg_type = device_ctx.rr_indexed_data[cost_index].seg_index;
68-
int length = -1;
69-
if (!segment_inf[seg_type].longline)
70-
length = segment_inf[seg_type].length;
71-
else
72-
length = LONGLINE;
69+
int length = segment_inf[seg_type].longline ? LONGLINE : segment_inf[seg_type].length;
70+
7371
const short& inode_capacity = rr_graph.node_capacity(inode);
7472
int occ = route_ctx.rr_node_route_inf[inode].occ();
7573
auto ax = (node_type == CHANX) ? X_AXIS : Y_AXIS;
74+
7675
directed_occ_by_length[ax][length] += occ;
7776
directed_cap_by_length[ax][length] += inode_capacity;
7877

@@ -119,14 +118,7 @@ void get_segment_usage_stats(std::vector<t_segment_inf>& segment_inf) {
119118
VTR_LOG("\n");
120119
VTR_LOG("Segment occupancy by length: Length utilization\n");
121120
VTR_LOG(" ------ -----------\n");
122-
std::set<int> seen_lengths;
123-
for (size_t seg_type = 0; seg_type < segment_inf.size(); seg_type++) {
124-
int seg_length = segment_inf[seg_type].length;
125-
if (seen_lengths.count(seg_length) == 0) {
126-
seen_lengths.insert(seg_length);
127-
} else {
128-
continue;
129-
}
121+
for (const auto& seg_length : segment_lengths) {
130122
if (directed_cap_by_length[X_AXIS][seg_length] != 0 || directed_cap_by_length[Y_AXIS][seg_length] != 0) {
131123
std::string seg_name = "L" + std::to_string(seg_length);
132124

0 commit comments

Comments
 (0)