From 20d29a00ac24f867e1d57e4b54bcb337da02c7e7 Mon Sep 17 00:00:00 2001 From: amin1377 Date: Fri, 29 Sep 2023 17:13:50 -0400 Subject: [PATCH 01/10] print both segment usage by length and type --- vpr/src/route/segment_stats.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/vpr/src/route/segment_stats.cpp b/vpr/src/route/segment_stats.cpp index d19271477be..225681eabc3 100644 --- a/vpr/src/route/segment_stats.cpp +++ b/vpr/src/route/segment_stats.cpp @@ -47,6 +47,14 @@ void get_segment_usage_stats(std::vector& segment_inf) { {X_AXIS, std::vector(max_segment_length + 1, 0)}, {Y_AXIS, std::vector(max_segment_length + 1, 0)}}; + std::map> directed_occ_by_type = { + {X_AXIS, std::vector(segment_inf.size(), 0)}, + {Y_AXIS, std::vector(segment_inf.size(), 0)}}; + + std::map> directed_cap_by_type = { + {X_AXIS, std::vector(segment_inf.size(), 0)}, + {Y_AXIS, std::vector(segment_inf.size(), 0)}}; + for (RRNodeId inode : device_ctx.rr_graph.nodes()) { auto node_type = rr_graph.node_type(inode); if (node_type == CHANX || node_type == CHANY) { @@ -62,6 +70,9 @@ void get_segment_usage_stats(std::vector& segment_inf) { auto ax = (node_type == CHANX) ? X_AXIS : Y_AXIS; directed_occ_by_length[ax][length] += occ; directed_cap_by_length[ax][length] += inode_capacity; + + directed_occ_by_type[ax][seg_type] += occ; + directed_cap_by_type[ax][seg_type] += inode_capacity; } } @@ -101,7 +112,7 @@ void get_segment_usage_stats(std::vector& segment_inf) { } VTR_LOG("\n"); - VTR_LOG("Segment usage by type (index): %sname type utilization\n", std::string(std::max(max_segment_name_length - 4, 0), ' ').c_str()); + VTR_LOG("Segment occupancy by length: %sname type utilization\n", std::string(std::max(max_segment_name_length - 4, 0), ' ').c_str()); VTR_LOG(" %s ---- -----------\n", std::string(std::max(4, max_segment_name_length), '-').c_str()); for (size_t seg_type = 0; seg_type < segment_inf.size(); seg_type++) { @@ -119,4 +130,23 @@ void get_segment_usage_stats(std::vector& segment_inf) { 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); } } + + VTR_LOG("\n"); + VTR_LOG("Segment occupancy by type (index): %sname type utilization\n", std::string(std::max(max_segment_name_length - 4, 0), ' ').c_str()); + VTR_LOG(" %s ---- -----------\n", std::string(std::max(4, max_segment_name_length), '-').c_str()); + + for (size_t seg_type = 0; seg_type < segment_inf.size(); seg_type++) { + if (directed_cap_by_type[X_AXIS][seg_type] != 0 || directed_cap_by_type[Y_AXIS][seg_type] != 0) { + std::string seg_name = segment_inf[seg_type].name; + int seg_name_size = static_cast(seg_name.size()); + int occ = 0; + int cap = 0; + for (auto ax : {X_AXIS, Y_AXIS}) { + occ += directed_occ_by_type[ax][seg_type]; + cap += directed_cap_by_type[ax][seg_type]; + } + utilization = (float)occ / (float)cap; + 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); + } + } } From 602ed342e0f0dc95029265cd5a5037c773c29e50 Mon Sep 17 00:00:00 2001 From: amin1377 Date: Fri, 29 Sep 2023 17:20:24 -0400 Subject: [PATCH 02/10] don't print type for length statistics --- vpr/src/route/segment_stats.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/vpr/src/route/segment_stats.cpp b/vpr/src/route/segment_stats.cpp index 225681eabc3..161df41afee 100644 --- a/vpr/src/route/segment_stats.cpp +++ b/vpr/src/route/segment_stats.cpp @@ -112,11 +112,16 @@ void get_segment_usage_stats(std::vector& segment_inf) { } VTR_LOG("\n"); - VTR_LOG("Segment occupancy by length: %sname type utilization\n", std::string(std::max(max_segment_name_length - 4, 0), ' ').c_str()); - VTR_LOG(" %s ---- -----------\n", std::string(std::max(4, max_segment_name_length), '-').c_str()); - + VTR_LOG("Segment occupancy by length: %sname utilization\n", std::string(std::max(max_segment_name_length - 4, 0), ' ').c_str()); + VTR_LOG(" %s -----------\n", std::string(std::max(4, max_segment_name_length), '-').c_str()); + std::set seen_lengths; for (size_t seg_type = 0; seg_type < segment_inf.size(); seg_type++) { int seg_length = segment_inf[seg_type].length; + if (seen_lengths.count(seg_length) == 0) { + seen_lengths.insert(seg_length); + } else { + continue; + } if (directed_cap_by_length[X_AXIS][seg_length] != 0 || directed_cap_by_length[Y_AXIS][seg_length] != 0) { std::string seg_name = segment_inf[seg_type].name; int seg_name_size = static_cast(seg_name.size()); @@ -127,7 +132,7 @@ void get_segment_usage_stats(std::vector& segment_inf) { cap += directed_cap_by_length[ax][seg_length]; } utilization = (float)occ / (float)cap; - 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); + VTR_LOG(" %s%s %11.3g\n", std::string(std::max(4 - seg_name_size, (max_segment_name_length - seg_name_size)), ' ').c_str(), seg_name.c_str(), utilization); } } From 6b3fe0ced3efbe0692ac56c5a18628661c6606a8 Mon Sep 17 00:00:00 2001 From: amin1377 Date: Wed, 4 Oct 2023 12:33:28 -0400 Subject: [PATCH 03/10] print length as a seg number - fix indentation --- vpr/src/route/segment_stats.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vpr/src/route/segment_stats.cpp b/vpr/src/route/segment_stats.cpp index 161df41afee..526133cd885 100644 --- a/vpr/src/route/segment_stats.cpp +++ b/vpr/src/route/segment_stats.cpp @@ -104,7 +104,7 @@ void get_segment_usage_stats(std::vector& segment_inf) { std::string length_str = (length == LONGLINE) ? "longline" : std::to_string(length); utilization = (float)directed_occ_by_length[ax][length] / (float)directed_cap_by_length[ax][length]; VTR_LOG(" %s%s %11.3g\n", - std::string(std::max(6 - (int)length_str.length(), 0), ' ').c_str(), + std::string(std::max(7 - (int)length_str.length(), 0), ' ').c_str(), length_str.c_str(), utilization); } @@ -123,8 +123,9 @@ void get_segment_usage_stats(std::vector& segment_inf) { continue; } if (directed_cap_by_length[X_AXIS][seg_length] != 0 || directed_cap_by_length[Y_AXIS][seg_length] != 0) { - std::string seg_name = segment_inf[seg_type].name; + std::string seg_name = "L" + std::to_string(seg_length); int seg_name_size = static_cast(seg_name.size()); + int occ = 0; int cap = 0; for (auto ax : {X_AXIS, Y_AXIS}) { @@ -137,7 +138,7 @@ void get_segment_usage_stats(std::vector& segment_inf) { } VTR_LOG("\n"); - VTR_LOG("Segment occupancy by type (index): %sname type utilization\n", std::string(std::max(max_segment_name_length - 4, 0), ' ').c_str()); + VTR_LOG("Segment occupancy by type: %sname type utilization\n", std::string(std::max(max_segment_name_length - 4, 0), ' ').c_str()); VTR_LOG(" %s ---- -----------\n", std::string(std::max(4, max_segment_name_length), '-').c_str()); for (size_t seg_type = 0; seg_type < segment_inf.size(); seg_type++) { From 1ad1e9099eb3c170e0360a5f76a397d5ac65a47a Mon Sep 17 00:00:00 2001 From: amin1377 Date: Wed, 4 Oct 2023 14:58:03 -0400 Subject: [PATCH 04/10] fix a bug in segment usage message --- vpr/src/route/segment_stats.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vpr/src/route/segment_stats.cpp b/vpr/src/route/segment_stats.cpp index 526133cd885..78a899c7c6f 100644 --- a/vpr/src/route/segment_stats.cpp +++ b/vpr/src/route/segment_stats.cpp @@ -112,8 +112,8 @@ void get_segment_usage_stats(std::vector& segment_inf) { } VTR_LOG("\n"); - VTR_LOG("Segment occupancy by length: %sname utilization\n", std::string(std::max(max_segment_name_length - 4, 0), ' ').c_str()); - VTR_LOG(" %s -----------\n", std::string(std::max(4, max_segment_name_length), '-').c_str()); + VTR_LOG("Segment occupancy by length: name utilization\n"); + VTR_LOG(" ---- -----------\n"); std::set seen_lengths; for (size_t seg_type = 0; seg_type < segment_inf.size(); seg_type++) { int seg_length = segment_inf[seg_type].length; @@ -124,7 +124,6 @@ void get_segment_usage_stats(std::vector& segment_inf) { } if (directed_cap_by_length[X_AXIS][seg_length] != 0 || directed_cap_by_length[Y_AXIS][seg_length] != 0) { std::string seg_name = "L" + std::to_string(seg_length); - int seg_name_size = static_cast(seg_name.size()); int occ = 0; int cap = 0; @@ -133,13 +132,14 @@ void get_segment_usage_stats(std::vector& segment_inf) { cap += directed_cap_by_length[ax][seg_length]; } utilization = (float)occ / (float)cap; - VTR_LOG(" %s%s %11.3g\n", std::string(std::max(4 - seg_name_size, (max_segment_name_length - seg_name_size)), ' ').c_str(), seg_name.c_str(), utilization); + VTR_LOG(" ---- -----------\n"); + VTR_LOG(" %s %11.3g\n", seg_name.c_str(), utilization); } } VTR_LOG("\n"); VTR_LOG("Segment occupancy by type: %sname type utilization\n", std::string(std::max(max_segment_name_length - 4, 0), ' ').c_str()); - VTR_LOG(" %s ---- -----------\n", std::string(std::max(4, max_segment_name_length), '-').c_str()); + VTR_LOG(" %s ---- -----------\n", std::string(std::max(4, max_segment_name_length), '-').c_str()); for (size_t seg_type = 0; seg_type < segment_inf.size(); seg_type++) { if (directed_cap_by_type[X_AXIS][seg_type] != 0 || directed_cap_by_type[Y_AXIS][seg_type] != 0) { @@ -152,7 +152,7 @@ void get_segment_usage_stats(std::vector& segment_inf) { cap += directed_cap_by_type[ax][seg_type]; } utilization = (float)occ / (float)cap; - 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); + 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); } } } From 60469099dfd111ce10d3b8f4e7f224b80a429d5f Mon Sep 17 00:00:00 2001 From: amin1377 Date: Wed, 4 Oct 2023 15:05:07 -0400 Subject: [PATCH 05/10] remove redundant separator --- vpr/src/route/segment_stats.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/vpr/src/route/segment_stats.cpp b/vpr/src/route/segment_stats.cpp index 78a899c7c6f..295c6ca85dd 100644 --- a/vpr/src/route/segment_stats.cpp +++ b/vpr/src/route/segment_stats.cpp @@ -112,8 +112,8 @@ void get_segment_usage_stats(std::vector& segment_inf) { } VTR_LOG("\n"); - VTR_LOG("Segment occupancy by length: name utilization\n"); - VTR_LOG(" ---- -----------\n"); + VTR_LOG("Segment occupancy by length: Length utilization\n"); + VTR_LOG(" ------ -----------\n"); std::set seen_lengths; for (size_t seg_type = 0; seg_type < segment_inf.size(); seg_type++) { int seg_length = segment_inf[seg_type].length; @@ -132,8 +132,7 @@ void get_segment_usage_stats(std::vector& segment_inf) { cap += directed_cap_by_length[ax][seg_length]; } utilization = (float)occ / (float)cap; - VTR_LOG(" ---- -----------\n"); - VTR_LOG(" %s %11.3g\n", seg_name.c_str(), utilization); + VTR_LOG(" %s %11.3g\n", seg_name.c_str(), utilization); } } From ea948da487103eb9451eb33518ce5153dfc49bfa Mon Sep 17 00:00:00 2001 From: amin1377 Date: Thu, 5 Oct 2023 17:06:06 -0400 Subject: [PATCH 06/10] create a map of maps to store seg lengths --- vpr/src/route/segment_stats.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/vpr/src/route/segment_stats.cpp b/vpr/src/route/segment_stats.cpp index 295c6ca85dd..854737932d4 100644 --- a/vpr/src/route/segment_stats.cpp +++ b/vpr/src/route/segment_stats.cpp @@ -30,22 +30,27 @@ void get_segment_usage_stats(std::vector& segment_inf) { max_segment_length = 0; int max_segment_name_length = 0; - for (size_t seg_type = 0; seg_type < segment_inf.size(); seg_type++) { - if (segment_inf[seg_type].longline == false) { - max_segment_length = std::max(max_segment_length, - segment_inf[seg_type].length); - } + std::map> directed_occ_by_length = { + {X_AXIS, std::map()}, + {Y_AXIS, std::map()}}; - max_segment_name_length = std::max(max_segment_name_length, static_cast(segment_inf[seg_type].name.size())); - } + std::map> directed_cap_by_length = { + {X_AXIS, std::map()}, + {Y_AXIS, std::map()}}; - std::map> directed_occ_by_length = { - {X_AXIS, std::vector(max_segment_length + 1, 0)}, - {Y_AXIS, std::vector(max_segment_length + 1, 0)}}; + std::set segment_lengths; + for (const auto& seg_inf: segment_inf) { + int seg_length = seg_inf.longline ? LONGLINE : seg_inf.length; - std::map> directed_cap_by_length = { - {X_AXIS, std::vector(max_segment_length + 1, 0)}, - {Y_AXIS, std::vector(max_segment_length + 1, 0)}}; + directed_cap_by_length[X_AXIS].insert({seg_length, 0}); + directed_cap_by_length[Y_AXIS].insert({seg_length, 0}); + + directed_occ_by_length[X_AXIS].insert({seg_length, 0}); + directed_occ_by_length[Y_AXIS].insert({seg_length, 0}); + segment_lengths.insert(seg_length); + + max_segment_name_length = std::max(max_segment_name_length, static_cast(seg_inf.name.size())); + } std::map> directed_occ_by_type = { {X_AXIS, std::vector(segment_inf.size(), 0)}, From f2a0cf9bd5a76173f3407854d55bd316921ca560 Mon Sep 17 00:00:00 2001 From: amin1377 Date: Thu, 5 Oct 2023 17:15:56 -0400 Subject: [PATCH 07/10] iterate over seg lengths instead of getting index --- vpr/src/route/segment_stats.cpp | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/vpr/src/route/segment_stats.cpp b/vpr/src/route/segment_stats.cpp index 854737932d4..308a639292e 100644 --- a/vpr/src/route/segment_stats.cpp +++ b/vpr/src/route/segment_stats.cpp @@ -42,11 +42,12 @@ void get_segment_usage_stats(std::vector& segment_inf) { for (const auto& seg_inf: segment_inf) { int seg_length = seg_inf.longline ? LONGLINE : seg_inf.length; - directed_cap_by_length[X_AXIS].insert({seg_length, 0}); - directed_cap_by_length[Y_AXIS].insert({seg_length, 0}); + for (auto ax : {X_AXIS, Y_AXIS}) { + directed_cap_by_length[ax].insert({seg_length, 0}); + directed_occ_by_length[ax].insert({seg_length, 0}); + } + - directed_occ_by_length[X_AXIS].insert({seg_length, 0}); - directed_occ_by_length[Y_AXIS].insert({seg_length, 0}); segment_lengths.insert(seg_length); max_segment_name_length = std::max(max_segment_name_length, static_cast(seg_inf.name.size())); @@ -65,14 +66,12 @@ void get_segment_usage_stats(std::vector& segment_inf) { if (node_type == CHANX || node_type == CHANY) { cost_index = rr_graph.node_cost_index(inode); size_t seg_type = device_ctx.rr_indexed_data[cost_index].seg_index; - int length = -1; - if (!segment_inf[seg_type].longline) - length = segment_inf[seg_type].length; - else - length = LONGLINE; + int length = segment_inf[seg_type].longline ? LONGLINE : segment_inf[seg_type].length; + const short& inode_capacity = rr_graph.node_capacity(inode); int occ = route_ctx.rr_node_route_inf[inode].occ(); auto ax = (node_type == CHANX) ? X_AXIS : Y_AXIS; + directed_occ_by_length[ax][length] += occ; directed_cap_by_length[ax][length] += inode_capacity; @@ -119,14 +118,7 @@ void get_segment_usage_stats(std::vector& segment_inf) { VTR_LOG("\n"); VTR_LOG("Segment occupancy by length: Length utilization\n"); VTR_LOG(" ------ -----------\n"); - std::set seen_lengths; - for (size_t seg_type = 0; seg_type < segment_inf.size(); seg_type++) { - int seg_length = segment_inf[seg_type].length; - if (seen_lengths.count(seg_length) == 0) { - seen_lengths.insert(seg_length); - } else { - continue; - } + for (const auto& seg_length : segment_lengths) { if (directed_cap_by_length[X_AXIS][seg_length] != 0 || directed_cap_by_length[Y_AXIS][seg_length] != 0) { std::string seg_name = "L" + std::to_string(seg_length); From 837d2f926e3cebc093d5662616eca3179cbe2749 Mon Sep 17 00:00:00 2001 From: amin1377 Date: Thu, 5 Oct 2023 17:32:23 -0400 Subject: [PATCH 08/10] use segment length set and sort it in an ascending order --- vpr/src/route/segment_stats.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vpr/src/route/segment_stats.cpp b/vpr/src/route/segment_stats.cpp index 308a639292e..f1489a5aa13 100644 --- a/vpr/src/route/segment_stats.cpp +++ b/vpr/src/route/segment_stats.cpp @@ -38,7 +38,7 @@ void get_segment_usage_stats(std::vector& segment_inf) { {X_AXIS, std::map()}, {Y_AXIS, std::map()}}; - std::set segment_lengths; + std::set> segment_lengths; for (const auto& seg_inf: segment_inf) { int seg_length = seg_inf.longline ? LONGLINE : seg_inf.length; @@ -83,7 +83,7 @@ void get_segment_usage_stats(std::vector& segment_inf) { VTR_LOG("\n"); VTR_LOG("Total Number of Wiring Segments by Direction: direction length number\n"); VTR_LOG(" --------- ------ -------\n"); - for (int length = 0; length <= max_segment_length; length++) { + for (auto length : segment_lengths) { for (auto ax : {X_AXIS, Y_AXIS}) { std::string ax_name = (ax == X_AXIS) ? "X" : "Y"; if (directed_cap_by_length[ax][length] != 0) { @@ -103,7 +103,7 @@ void get_segment_usage_stats(std::vector& segment_inf) { VTR_LOG("\n"); VTR_LOG("%s - Directed Wiring Segment usage by length: length utilization\n", ax_name.c_str()); VTR_LOG(" ------ -----------\n"); - for (int length = 0; length <= max_segment_length; length++) { + for (auto length : segment_lengths) { if (directed_cap_by_length[ax][length] != 0) { std::string length_str = (length == LONGLINE) ? "longline" : std::to_string(length); utilization = (float)directed_occ_by_length[ax][length] / (float)directed_cap_by_length[ax][length]; From f931302870bb9ed30ff60770d0f4158f3feee01d Mon Sep 17 00:00:00 2001 From: amin1377 Date: Fri, 6 Oct 2023 09:11:14 -0400 Subject: [PATCH 09/10] make format --- vpr/src/route/segment_stats.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vpr/src/route/segment_stats.cpp b/vpr/src/route/segment_stats.cpp index f1489a5aa13..6d813d76169 100644 --- a/vpr/src/route/segment_stats.cpp +++ b/vpr/src/route/segment_stats.cpp @@ -39,7 +39,7 @@ void get_segment_usage_stats(std::vector& segment_inf) { {Y_AXIS, std::map()}}; std::set> segment_lengths; - for (const auto& seg_inf: segment_inf) { + for (const auto& seg_inf : segment_inf) { int seg_length = seg_inf.longline ? LONGLINE : seg_inf.length; for (auto ax : {X_AXIS, Y_AXIS}) { @@ -47,7 +47,6 @@ void get_segment_usage_stats(std::vector& segment_inf) { directed_occ_by_length[ax].insert({seg_length, 0}); } - segment_lengths.insert(seg_length); max_segment_name_length = std::max(max_segment_name_length, static_cast(seg_inf.name.size())); From 9b247d05c7e0b10681c806dce815fd2404b8e2b5 Mon Sep 17 00:00:00 2001 From: amin1377 Date: Fri, 6 Oct 2023 09:12:09 -0400 Subject: [PATCH 10/10] remove max_segment_length since it is not used --- vpr/src/route/segment_stats.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/vpr/src/route/segment_stats.cpp b/vpr/src/route/segment_stats.cpp index 6d813d76169..f05e0874cdb 100644 --- a/vpr/src/route/segment_stats.cpp +++ b/vpr/src/route/segment_stats.cpp @@ -20,7 +20,6 @@ void get_segment_usage_stats(std::vector& segment_inf) { * are counted as full-length segments (e.g. length 4 even if the last 2 * * units of wire were chopped off by the chip edge). */ - int max_segment_length; RRIndexedDataId cost_index; float utilization; @@ -28,7 +27,6 @@ void get_segment_usage_stats(std::vector& segment_inf) { const auto& rr_graph = device_ctx.rr_graph; auto& route_ctx = g_vpr_ctx.routing(); - max_segment_length = 0; int max_segment_name_length = 0; std::map> directed_occ_by_length = { {X_AXIS, std::map()},