Skip to content

Commit a699e67

Browse files
pass NoC link bandwidth utilization to graphics
1 parent 4bd8de3 commit a699e67

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

vpr/src/draw/draw_global.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ static t_draw_coords draw_coords;
3333
*/
3434
static std::optional<std::reference_wrapper<const BlkLocRegistry>> blk_loc_registry_ref;
3535

36+
static std::optional<std::reference_wrapper<const vtr::vector<NocLinkId, double>>> noc_link_bandwidth_usages_ref;
37+
3638
/*********************** Accessor Subroutines Definition ********************/
3739

3840
/* This accessor function returns pointer to the global variable
@@ -55,4 +57,12 @@ const BlkLocRegistry& get_graphics_blk_loc_registry_ref() {
5557
return blk_loc_registry_ref->get();
5658
}
5759

60+
void set_noc_link_bandwidth_usages_ref(const vtr::vector<NocLinkId, double>& noc_link_bandwidth_usages) {
61+
noc_link_bandwidth_usages_ref = noc_link_bandwidth_usages;
62+
}
63+
64+
const vtr::vector<NocLinkId, double>& get_noc_link_bandwidth_usages_ref() {
65+
return noc_link_bandwidth_usages_ref->get();
66+
}
67+
5868
#endif // NO_GRAPHICS

vpr/src/draw/draw_global.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ void set_graphics_blk_loc_registry_ref(const BlkLocRegistry& blk_loc_registry);
4545
*/
4646
const BlkLocRegistry& get_graphics_blk_loc_registry_ref();
4747

48+
void set_noc_link_bandwidth_usages_ref(const vtr::vector<NocLinkId, double>& noc_link_bandwidth_usages);
49+
50+
const vtr::vector<NocLinkId, double>& get_noc_link_bandwidth_usages_ref();
51+
4852
#endif // NO_GRAPHICS
4953

5054
#endif

vpr/src/draw/draw_noc.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ void draw_noc(ezgl::renderer* g) {
7575
void draw_noc_usage(vtr::vector<NocLinkId, ezgl::color>& noc_link_colors) {
7676
t_draw_state* draw_state = get_draw_state_vars();
7777
auto& noc_ctx = g_vpr_ctx.noc();
78+
const auto& noc_link_bandwidth_usages = get_noc_link_bandwidth_usages_ref();
7879

7980
// check to see if a color map was already created previously
8081
if (draw_state->noc_usage_color_map == nullptr) {
@@ -90,15 +91,15 @@ void draw_noc_usage(vtr::vector<NocLinkId, ezgl::color>& noc_link_colors) {
9091
// represents the color to draw each noc link
9192
ezgl::color current_noc_link_color;
9293

93-
for (const auto& noc_link : noc_ctx.noc_model.get_noc_links()) {
94-
NocLinkId link_id = noc_link.get_link_id();
94+
for (const auto& [link_id, bandwidth_usage] : noc_link_bandwidth_usages.pairs()) {
9595

9696
// only update the color of the link if it wasn't updated previously
9797
if (noc_link_colors[link_id] == ezgl::BLACK) {
9898
// if we are here then the link was not updated previously, so assign the color here
9999

100+
double link_bandwidth = noc_ctx.noc_model.get_single_noc_link(link_id).get_bandwidth();
100101
//get the current link bandwidth usage (ratio calculation)
101-
double link_bandwidth_usage_ratio = 0.0;//(noc_link.get_bandwidth_usage()) / noc_link.get_bandwidth();
102+
double link_bandwidth_usage_ratio = bandwidth_usage / link_bandwidth;
102103

103104
// check if the link is being overused and if it is then cap it at 1.0
104105
if (link_bandwidth_usage_ratio > 1.0) {

vpr/src/place/noc_place_utils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,10 @@ double NocCostHandler::get_link_used_bandwidth(NocLinkId link_id) const {
800800
return link_bandwidth_usages[link_id];
801801
}
802802

803+
const vtr::vector<NocLinkId, double>& NocCostHandler::get_link_bandwidth_usages() const {
804+
return link_bandwidth_usages;
805+
}
806+
803807
std::vector<NocLink> NocCostHandler::get_top_n_congested_links(int n) {
804808
// get NoC links
805809
vtr::vector<NocLinkId, NocLink> noc_links = g_vpr_ctx.noc().noc_model.get_noc_links();

vpr/src/place/noc_place_utils.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ class NocCostHandler {
286286
*/
287287
double get_link_used_bandwidth(NocLinkId link_id) const;
288288

289+
const vtr::vector<NocLinkId, double>& get_link_bandwidth_usages() const;
290+
289291
/**
290292
* @brief Determines the congestion cost a NoC link. The cost
291293
* is calculating by measuring how much the current bandwidth
@@ -510,9 +512,6 @@ class NocCostHandler {
510512

511513
///Represents the bandwidth of the data being transmitted on the link. Units in bits-per-second(bps)
512514
vtr::vector<NocLinkId, double> link_bandwidth_usages;
513-
514-
515-
friend void test_revert_noc_traffic_flow_routes();
516515
};
517516

518517
/**

vpr/src/place/place.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,10 @@ void try_place(const Netlist<>& net_list,
439439
NetCostHandler net_cost_handler = alloc_and_load_placement_structs(placer_opts, noc_opts, directs,
440440
num_directs, placer_state, noc_cost_handler);
441441

442+
if (noc_cost_handler.has_value()) {
443+
set_noc_link_bandwidth_usages_ref(noc_cost_handler->get_link_bandwidth_usages());
444+
}
445+
442446
ManualMoveGenerator manual_move_generator(placer_state);
443447

444448
vtr::ScopedStartFinishTimer timer("Placement");
@@ -769,8 +773,8 @@ void try_place(const Netlist<>& net_list,
769773
*current_move_generator, manual_move_generator,
770774
blocks_affected, timing_info.get(),
771775
placer_opts.place_algorithm, move_type_stat,
772-
timing_bb_factor,
773-
swap_stats, placer_state, net_cost_handler, noc_cost_handler);
776+
timing_bb_factor, swap_stats, placer_state,
777+
net_cost_handler, noc_cost_handler);
774778

775779

776780
//move the update used move_generator to its original variable
@@ -837,8 +841,8 @@ void try_place(const Netlist<>& net_list,
837841
*current_move_generator, manual_move_generator,
838842
blocks_affected, timing_info.get(),
839843
placer_opts.place_quench_algorithm, move_type_stat,
840-
timing_bb_factor,
841-
swap_stats, placer_state, net_cost_handler, noc_cost_handler);
844+
timing_bb_factor, swap_stats, placer_state,
845+
net_cost_handler, noc_cost_handler);
842846

843847

844848
//move the update used move_generator to its original variable

0 commit comments

Comments
 (0)