Skip to content

Commit 43636d8

Browse files
remove NoC-wide link bandwidth member variable and getter
1 parent ab91d2a commit 43636d8

File tree

4 files changed

+29
-75
lines changed

4 files changed

+29
-75
lines changed

vpr/src/draw/draw_noc.cpp

Lines changed: 16 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ void draw_noc(ezgl::renderer* g) {
6767
draw_noc_links(g, noc_router_logical_type, noc_link_colors, noc_connection_marker_bbox, list_of_noc_link_shift_directions);
6868

6969
draw_noc_connection_marker(g, router_list, noc_connection_marker_bbox);
70-
71-
return;
7270
}
7371

7472
/*
@@ -78,55 +76,42 @@ void draw_noc_usage(vtr::vector<NocLinkId, ezgl::color>& noc_link_colors) {
7876
t_draw_state* draw_state = get_draw_state_vars();
7977
auto& noc_ctx = g_vpr_ctx.noc();
8078

81-
// get the maximum badnwidth per link
82-
double max_noc_link_bandwidth = noc_ctx.noc_model.get_noc_link_bandwidth();
83-
8479
// check to see if a color map was already created previously
8580
if (draw_state->noc_usage_color_map == nullptr) {
86-
// we havent created a color map yet for the noc link usage, so create it here
81+
// we haven't created a color map yet for the noc link usage, so create it here
8782
// the color map creates a color spectrum that gradually changes from a dark to light color. Where a dark color represents low noc link usage (low bandwidth) and a light color represents high noc link usage (high bandwidth)
8883
// The color map needs a min and max value to generate the color range.
8984
// The noc usage is calculated by taking the ratio of the links current bandwidth over the maximum allowable bandwidth
90-
// for the NoC, the min value is 0, since you cannot go lower than 0 badnwidth.
85+
// for the NoC, the min value is 0, since you cannot go lower than 0 bandwidth.
9186
// The max value is going to be 1 and represents the case where the link is used to full capacity on the noc link (as provided by the user)
9287
draw_state->noc_usage_color_map = std::make_shared<vtr::PlasmaColorMap>(0.0, 1.0);
9388
}
9489

95-
// get the list of links in the NoC
96-
const vtr::vector<NocLinkId, NocLink>& noc_link_list = noc_ctx.noc_model.get_noc_links();
97-
98-
// store each links bandwidth usage
99-
double link_bandwidth_usage;
100-
10190
// represents the color to draw each noc link
10291
ezgl::color current_noc_link_color;
10392

104-
// now we need to determine the colors for each link
105-
for (int link = 0; link < (int)noc_link_list.size(); link++) {
106-
// get the current link id
107-
NocLinkId link_id(link);
93+
for (const auto& noc_link : noc_ctx.noc_model.get_noc_links()) {
94+
NocLinkId link_id = noc_link.get_link_id();
10895

109-
// only update the color of the link if it wasnt updated previously
96+
// only update the color of the link if it wasn't updated previously
11097
if (noc_link_colors[link_id] == ezgl::BLACK) {
11198
// if we are here then the link was not updated previously, so assign the color here
11299

113100
//get the current link bandwidth usage (ratio calculation)
114-
link_bandwidth_usage = (noc_link_list[link_id].get_bandwidth_usage()) / max_noc_link_bandwidth;
101+
double link_bandwidth_usage_ratio = (noc_link.get_bandwidth_usage()) / noc_link.get_bandwidth();
115102

116103
// check if the link is being overused and if it is then cap it at 1.0
117-
if (link_bandwidth_usage > 1.0) {
118-
link_bandwidth_usage = 1.0;
104+
if (link_bandwidth_usage_ratio > 1.0) {
105+
link_bandwidth_usage_ratio = 1.0;
119106
}
120107

121-
// get the corresponding color that represents the link bandwidth usgae
122-
current_noc_link_color = to_ezgl_color(draw_state->noc_usage_color_map->color(link_bandwidth_usage));
108+
// get the corresponding color that represents the link bandwidth usage
109+
current_noc_link_color = to_ezgl_color(draw_state->noc_usage_color_map->color(link_bandwidth_usage_ratio));
123110

124111
// set the colors of the link
125112
noc_link_colors[link_id] = current_noc_link_color;
126113
}
127114
}
128-
129-
return;
130115
}
131116

132117
/*
@@ -158,7 +143,7 @@ ezgl::rectangle get_noc_connection_marker_bbox(const t_logical_block_type_ptr no
158143
* We do the following to calculate the position of the marker:
159144
* 1. Get the area of the larger router tile
160145
* 2. Calculate the area of the marker (based on a predefined percentage of the area of the larger noc tile)
161-
* 3. The marker is a square, so we can can calculate the lengths
146+
* 3. The marker is a square, so we can calculate the lengths
162147
* of the sides of the marker
163148
* 4. Divide the side length by 2 and subtract this from the x & y coordinates of the center of the larger noc router tile. This is the bottom left corner of the rectangle.
164149
* 5. Then add the side length to the x & y coordinate of the center of the larger noc router tile. THis is the top right corner of the rectangle.
@@ -188,15 +173,11 @@ void draw_noc_connection_marker(ezgl::renderer* g, const vtr::vector<NocRouterId
188173
t_draw_coords* draw_coords = get_draw_coords_vars();
189174
t_draw_state* draw_state = get_draw_state_vars();
190175

191-
int router_grid_position_x = 0;
192-
int router_grid_position_y = 0;
193-
int router_grid_position_layer = 0;
194-
195176
ezgl::rectangle updated_connection_marker_bbox;
196177

197178
// go through the routers and create the connection marker
198-
for (auto router = router_list.begin(); router != router_list.end(); router++) {
199-
router_grid_position_layer = router->get_router_layer_position();
179+
for (const auto & router : router_list) {
180+
int router_grid_position_layer = router.get_router_layer_position();
200181

201182
t_draw_layer_display marker_box_visibility = draw_state->draw_layer_display[router_grid_position_layer];
202183
if (!marker_box_visibility.visible) {
@@ -206,17 +187,15 @@ void draw_noc_connection_marker(ezgl::renderer* g, const vtr::vector<NocRouterId
206187
//set the color of the marker with the layer transparency
207188
g->set_color(ezgl::BLACK, marker_box_visibility.alpha);
208189

209-
router_grid_position_x = router->get_router_grid_position_x();
210-
router_grid_position_y = router->get_router_grid_position_y();
190+
int router_grid_position_x = router.get_router_grid_position_x();
191+
int router_grid_position_y = router.get_router_grid_position_y();
211192

212193
// get the coordinates to draw the marker given the current routers tile position
213194
updated_connection_marker_bbox = connection_marker_bbox + ezgl::point2d(draw_coords->tile_x[router_grid_position_x], draw_coords->tile_y[router_grid_position_y]);
214195

215196
// draw the marker
216197
g->fill_rectangle(updated_connection_marker_bbox);
217198
}
218-
219-
return;
220199
}
221200

222201
/*
@@ -307,8 +286,6 @@ void draw_noc_links(ezgl::renderer* g, t_logical_block_type_ptr noc_router_logic
307286
//draw a line between the center of the two routers this link connects
308287
g->draw_line(link_coords.start, link_coords.end);
309288
}
310-
311-
return;
312289
}
313290

314291
void determine_direction_to_shift_noc_links(vtr::vector<NocLinkId, NocLinkShift>& list_of_noc_link_shift_directions) {
@@ -343,8 +320,6 @@ void determine_direction_to_shift_noc_links(vtr::vector<NocLinkId, NocLinkShift>
343320
list_of_noc_link_shift_directions[parallel_link] = NocLinkShift::BOTTOM_SHIFT;
344321
}
345322
}
346-
347-
return;
348323
}
349324

350325
NocLinkType determine_noc_link_type(ezgl::point2d link_start_point, ezgl::point2d link_end_point) {
@@ -488,13 +463,11 @@ void shift_noc_link(noc_link_draw_coords& link_coords, NocLinkShift link_shift_d
488463
link_coords.start.y += noc_connection_marker_quarter_height;
489464
link_coords.end.y += noc_connection_marker_quarter_height;
490465
}
491-
// dont change anything if we arent shifting at all
466+
// don't change anything if we aren't shifting at all
492467
break;
493468
default:
494469
break;
495470
}
496-
497-
return;
498471
}
499472

500473
#endif

vpr/src/noc/noc_storage.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ int NocStorage::get_number_of_noc_links(void) const {
3131
return link_storage.size();
3232
}
3333

34-
double NocStorage::get_noc_link_bandwidth(void) const {
35-
return noc_link_bandwidth;
36-
}
37-
3834
double NocStorage::get_noc_link_latency(void) const {
3935
return noc_link_latency;
4036
}
@@ -136,11 +132,10 @@ void NocStorage::add_link(NocRouterId source, NocRouterId sink, double bandwidth
136132
}
137133

138134
void NocStorage::set_noc_link_bandwidth(double link_bandwidth) {
139-
noc_link_bandwidth = link_bandwidth;
140135

141136
// Iterate over all links and set their bandwidth
142137
for (auto& link : link_storage) {
143-
link.set_bandwidth(noc_link_bandwidth);
138+
link.set_bandwidth(link_bandwidth);
144139
}
145140
}
146141

@@ -301,8 +296,6 @@ void NocStorage::echo_noc(char* file_name) const {
301296
fprintf(fp, "NoC Constraints:\n");
302297
fprintf(fp, "--------------------------------------------------------------\n");
303298
fprintf(fp, "\n");
304-
fprintf(fp, "Maximum NoC Link Bandwidth: %f\n", noc_link_bandwidth);
305-
fprintf(fp, "\n");
306299
fprintf(fp, "NoC Link Latency: %f\n", noc_link_latency);
307300
fprintf(fp, "\n");
308301
fprintf(fp, "NoC Router Latency: %f\n", noc_router_latency);
@@ -318,21 +311,23 @@ void NocStorage::echo_noc(char* file_name) const {
318311
fprintf(fp, "Router %d:\n", router.get_router_user_id());
319312
// if the router tile is larger than a single grid, the position represents the bottom left corner of the tile
320313
fprintf(fp, "Equivalent Physical Tile Grid Position -> (%d,%d)\n", router.get_router_grid_position_x(), router.get_router_grid_position_y());
321-
fprintf(fp, "Router Connections ->");
314+
fprintf(fp, "Router Connections (destination router id, link bandwidth, link latency) ->");
322315

323316
auto& router_connections = this->get_noc_router_connections(this->convert_router_id(router.get_router_user_id()));
324317

325318
// go through the outgoing links of the current router and print the connecting router
326319
for (auto router_connection : router_connections) {
327-
const NocRouterId connecting_router_id = get_single_noc_link(router_connection).get_sink_router();
320+
const auto& link = get_single_noc_link(router_connection);
321+
const NocRouterId connecting_router_id = link.get_sink_router();
328322

329-
fprintf(fp, " %d", get_single_noc_router(connecting_router_id).get_router_user_id());
323+
fprintf(fp, " (%d, %g, %g)",
324+
get_single_noc_router(connecting_router_id).get_router_user_id(),
325+
link.get_bandwidth(),
326+
link.get_latency());
330327
}
331328

332329
fprintf(fp, "\n\n");
333330
}
334331

335332
fclose(fp);
336-
337-
return;
338333
}

vpr/src/noc/noc_storage.h

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,6 @@ class NocStorage {
116116
*/
117117
bool built_noc;
118118

119-
/**
120-
* @brief Represents the maximum allowed bandwidth for the links in the NoC (in bps)
121-
*/
122-
double noc_link_bandwidth;
123-
124119
/**
125120
* @brief Represents the delay expected when going through a link (in
126121
* seconds)
@@ -237,14 +232,6 @@ class NocStorage {
237232
*/
238233
int get_number_of_noc_links() const;
239234

240-
/**
241-
* @brief Get the maximum allowable bandwidth for a link
242-
* within the NoC.
243-
*
244-
* @return a numeric value that represents the link bandwidth in bps
245-
*/
246-
double get_noc_link_bandwidth() const;
247-
248235
/**
249236
* @brief Get the latency of traversing through a link in
250237
* the NoC.
@@ -460,7 +447,6 @@ class NocStorage {
460447
* used. In the detailed model, instead of associating a single latency or
461448
* bandwidth value with all NoC routers or links, each NoC router or link
462449
* has its specific value.
463-
*
464450
*/
465451
void finished_building_noc();
466452

@@ -469,7 +455,6 @@ class NocStorage {
469455
* This includes deleting all routers and links. Also all internal
470456
* IDs are removed (the is conversion table is cleared). It is
471457
* recommended to run this function before building the NoC.
472-
*
473458
*/
474459
void clear_noc();
475460

@@ -530,10 +515,10 @@ class NocStorage {
530515
* @param grid_position_x The horizontal position on the FPGA of the physical
531516
* tile that this router represents.
532517
*
533-
* @param grid_position_y The vertical position on the FPGA of the phyical
518+
* @param grid_position_y The vertical position on the FPGA of the physical
534519
* tile that this router represents.
535520
*
536-
* @param layer_position The layer number of the phyical
521+
* @param layer_position The layer number of the physical
537522
* tile that this router represents.
538523
*
539524
* @return int Represents a unique key that can be used to identify a

vpr/test/test_noc_place_utils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,15 +522,16 @@ TEST_CASE("test_find_affected_noc_routers_and_update_noc_costs, test_commit_noc_
522522
noc_opts.noc_latency_weighting = dist_3(double_engine);
523523
noc_opts.noc_congestion_weighting = dist_3(double_engine);
524524

525+
constexpr double link_bandwidth = 1.0;
526+
525527
// setting the NoC parameters
526528
noc_ctx.noc_model.set_noc_link_latency(1);
527529
noc_ctx.noc_model.set_noc_router_latency(1);
528-
noc_ctx.noc_model.set_noc_link_bandwidth(1);
530+
noc_ctx.noc_model.set_noc_link_bandwidth(link_bandwidth);
529531

530532
// needs to be the same as above
531533
const double router_latency = noc_ctx.noc_model.get_noc_router_latency();
532534
const double link_latency = noc_ctx.noc_model.get_noc_link_latency();
533-
const double link_bandwidth = noc_ctx.noc_model.get_noc_link_bandwidth();
534535

535536
// keeps track of which hard router each cluster block is placed
536537
vtr::vector<ClusterBlockId, NocRouterId> router_where_cluster_is_placed;

0 commit comments

Comments
 (0)