Skip to content

Commit ea948da

Browse files
committed
create a map of maps to store seg lengths
1 parent 6046909 commit ea948da

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

vpr/src/route/segment_stats.cpp

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,27 @@ void get_segment_usage_stats(std::vector<t_segment_inf>& segment_inf) {
3030

3131
max_segment_length = 0;
3232
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);
37-
}
33+
std::map<e_parallel_axis, std::map<int, int>> directed_occ_by_length = {
34+
{X_AXIS, std::map<int, int>()},
35+
{Y_AXIS, std::map<int, int>()}};
3836

39-
max_segment_name_length = std::max(max_segment_name_length, static_cast<int>(segment_inf[seg_type].name.size()));
40-
}
37+
std::map<e_parallel_axis, std::map<int, int>> directed_cap_by_length = {
38+
{X_AXIS, std::map<int, int>()},
39+
{Y_AXIS, std::map<int, int>()}};
4140

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)}};
41+
std::set<int> segment_lengths;
42+
for (const auto& seg_inf: segment_inf) {
43+
int seg_length = seg_inf.longline ? LONGLINE : seg_inf.length;
4544

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)}};
45+
directed_cap_by_length[X_AXIS].insert({seg_length, 0});
46+
directed_cap_by_length[Y_AXIS].insert({seg_length, 0});
47+
48+
directed_occ_by_length[X_AXIS].insert({seg_length, 0});
49+
directed_occ_by_length[Y_AXIS].insert({seg_length, 0});
50+
segment_lengths.insert(seg_length);
51+
52+
max_segment_name_length = std::max(max_segment_name_length, static_cast<int>(seg_inf.name.size()));
53+
}
4954

5055
std::map<e_parallel_axis, std::vector<int>> directed_occ_by_type = {
5156
{X_AXIS, std::vector<int>(segment_inf.size(), 0)},

0 commit comments

Comments
 (0)