Skip to content

Commit 169b31c

Browse files
apply PR comments
1 parent eace358 commit 169b31c

14 files changed

+188
-146
lines changed

vpr/src/draw/draw.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ void init_draw_coords(float clb_width, const BlkLocRegistry& blk_loc_registry) {
580580
/* Store a reference to block location variables so that other drawing
581581
* functions can access block location information without accessing
582582
* the global placement state, which is inaccessible during placement.*/
583-
set_graphics_blk_loc_registry_ref(blk_loc_registry);
583+
draw_state->set_graphics_blk_loc_registry_ref(blk_loc_registry);
584584

585585
if (!draw_state->show_graphics && !draw_state->save_graphics
586586
&& draw_state->graphics_commands.empty())
@@ -1004,8 +1004,8 @@ static void highlight_blocks(double x, double y) {
10041004
return; /* Nothing was found on any layer*/
10051005
}
10061006

1007-
auto& cluster_ctx = g_vpr_ctx.clustering();
1008-
auto& block_locs = get_graphics_blk_loc_registry_ref().block_locs();
1007+
const auto& cluster_ctx = g_vpr_ctx.clustering();
1008+
const auto& block_locs = draw_state->get_graphics_blk_loc_registry_ref().block_locs();
10091009

10101010
VTR_ASSERT(clb_index != ClusterBlockId::INVALID());
10111011

@@ -1046,14 +1046,15 @@ static void highlight_blocks(double x, double y) {
10461046
ClusterBlockId get_cluster_block_id_from_xy_loc(double x, double y) {
10471047
t_draw_coords* draw_coords = get_draw_coords_vars();
10481048
t_draw_state* draw_state = get_draw_state_vars();
1049-
auto clb_index = ClusterBlockId::INVALID();
1050-
auto& device_ctx = g_vpr_ctx.device();
1051-
auto& cluster_ctx = g_vpr_ctx.clustering();
1052-
const auto& grid_blocks = get_graphics_blk_loc_registry_ref().grid_blocks();
1049+
const auto& device_ctx = g_vpr_ctx.device();
1050+
const auto& cluster_ctx = g_vpr_ctx.clustering();
1051+
const auto& grid_blocks = draw_state->get_graphics_blk_loc_registry_ref().grid_blocks();
10531052

10541053
/// determine block ///
10551054
ezgl::rectangle clb_bbox;
10561055

1056+
auto clb_index = ClusterBlockId::INVALID();
1057+
10571058
//iterate over grid z (layers) first. Start search of the block at the top layer to prioritize highlighting of blocks at higher levels during overlapping of layers.
10581059
for (int layer_num = device_ctx.grid.get_num_layers() - 1; layer_num >= 0; layer_num--) {
10591060
if (!draw_state->draw_layer_display[layer_num].visible) {

vpr/src/draw/draw_basic.cpp

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ const std::vector<ezgl::color> kelly_max_contrast_colors = {
101101
void drawplace(ezgl::renderer* g) {
102102
t_draw_state* draw_state = get_draw_state_vars();
103103
t_draw_coords* draw_coords = get_draw_coords_vars();
104-
auto& device_ctx = g_vpr_ctx.device();
105-
auto& cluster_ctx = g_vpr_ctx.clustering();
106-
const auto& grid_blocks = get_graphics_blk_loc_registry_ref().grid_blocks();
104+
const auto& device_ctx = g_vpr_ctx.device();
105+
const auto& cluster_ctx = g_vpr_ctx.clustering();
106+
const auto& grid_blocks = draw_state->get_graphics_blk_loc_registry_ref().grid_blocks();
107107

108108
ClusterBlockId bnum;
109109
int num_sub_tiles;
@@ -224,12 +224,9 @@ void drawplace(ezgl::renderer* g) {
224224
void drawnets(ezgl::renderer* g) {
225225
t_draw_state* draw_state = get_draw_state_vars();
226226
t_draw_coords* draw_coords = get_draw_coords_vars();
227+
const auto& cluster_ctx = g_vpr_ctx.clustering();
228+
const auto& block_locs = draw_state->get_graphics_blk_loc_registry_ref().block_locs();
227229

228-
ClusterBlockId b1, b2;
229-
auto& cluster_ctx = g_vpr_ctx.clustering();
230-
auto& block_locs = get_graphics_blk_loc_registry_ref().block_locs();
231-
232-
float transparency_factor;
233230
float NET_ALPHA = draw_state->net_alpha;
234231

235232
g->set_line_dash(ezgl::line_dash::none);
@@ -250,7 +247,7 @@ void drawnets(ezgl::renderer* g) {
250247
continue;
251248
}
252249

253-
b1 = cluster_ctx.clb_nlist.net_driver_block(net_id);
250+
ClusterBlockId b1 = cluster_ctx.clb_nlist.net_driver_block(net_id);
254251

255252
//The layer of the net driver block
256253
driver_block_layer_num = block_locs[b1].loc.layer;
@@ -262,7 +259,7 @@ void drawnets(ezgl::renderer* g) {
262259

263260
ezgl::point2d driver_center = draw_coords->get_absolute_clb_bbox(b1, cluster_ctx.clb_nlist.block_type(b1)).center();
264261
for (ClusterPinId pin_id : cluster_ctx.clb_nlist.net_sinks(net_id)) {
265-
b2 = cluster_ctx.clb_nlist.pin_block(pin_id);
262+
ClusterBlockId b2 = cluster_ctx.clb_nlist.pin_block(pin_id);
266263

267264
//the layer of the pin block (net sinks)
268265
sink_block_layer_num =block_locs[b2].loc.layer;
@@ -272,7 +269,7 @@ void drawnets(ezgl::renderer* g) {
272269
if (!element_visibility.visible) {
273270
continue; /* Don't Draw */
274271
}
275-
transparency_factor = element_visibility.alpha;
272+
float transparency_factor = element_visibility.alpha;
276273

277274
//Take the highest of the 2 transparency values that the user can select from the UI
278275
// Compare the current cross layer transparency to the overall Net transparency set by the user.
@@ -800,8 +797,8 @@ void draw_placement_macros(ezgl::renderer* g) {
800797
}
801798
t_draw_coords* draw_coords = get_draw_coords_vars();
802799

803-
auto& place_ctx = g_vpr_ctx.placement();
804-
auto& block_locs = get_graphics_blk_loc_registry_ref().block_locs();
800+
const auto& place_ctx = g_vpr_ctx.placement();
801+
const auto& block_locs = draw_state->get_graphics_blk_loc_registry_ref().block_locs();
805802

806803
for (const t_pl_macro& pl_macro : place_ctx.pl_macros) {
807804

@@ -1184,8 +1181,9 @@ void draw_crit_path_elements(const std::vector<tatum::TimingPath>& paths, const
11841181
}
11851182

11861183
int get_timing_path_node_layer_num(tatum::NodeId node) {
1187-
auto& block_locs = get_graphics_blk_loc_registry_ref().block_locs();
1188-
auto& atom_ctx = g_vpr_ctx.atom();
1184+
t_draw_state* draw_state = get_draw_state_vars();
1185+
const auto& block_locs = draw_state->get_graphics_blk_loc_registry_ref().block_locs();
1186+
const auto& atom_ctx = g_vpr_ctx.atom();
11891187

11901188
AtomPinId atom_pin = atom_ctx.lookup.tnode_atom_pin(node);
11911189
AtomBlockId atom_block = atom_ctx.nlist.pin_block(atom_pin);
@@ -1415,9 +1413,9 @@ void draw_block_pin_util() {
14151413
if (draw_state->show_blk_pin_util == DRAW_NO_BLOCK_PIN_UTIL)
14161414
return;
14171415

1418-
auto& device_ctx = g_vpr_ctx.device();
1419-
auto& cluster_ctx = g_vpr_ctx.clustering();
1420-
auto& block_locs = get_graphics_blk_loc_registry_ref().block_locs();
1416+
const auto& device_ctx = g_vpr_ctx.device();
1417+
const auto& cluster_ctx = g_vpr_ctx.clustering();
1418+
const auto& block_locs = draw_state->get_graphics_blk_loc_registry_ref().block_locs();
14211419

14221420
std::map<t_physical_tile_type_ptr, size_t> total_input_pins;
14231421
std::map<t_physical_tile_type_ptr, size_t> total_output_pins;
@@ -1475,9 +1473,8 @@ void draw_block_pin_util() {
14751473
}
14761474

14771475
void draw_reset_blk_colors() {
1478-
auto& cluster_ctx = g_vpr_ctx.clustering();
1479-
auto blks = cluster_ctx.clb_nlist.blocks();
1480-
for (auto blk : blks) {
1476+
const auto& cluster_ctx = g_vpr_ctx.clustering();
1477+
for (auto blk : cluster_ctx.clb_nlist.blocks()) {
14811478
draw_reset_blk_color(blk);
14821479
}
14831480
}

vpr/src/draw/draw_global.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@ static t_draw_state draw_state;
2626
*/
2727
static t_draw_coords draw_coords;
2828

29-
/**
30-
* @brief Stores a reference to a PlaceLocVars to be used in the graphics code.
31-
* @details This reference let us pass in a currently-being-optimized placement state,
32-
* rather than using the global placement state in placement context that is valid only once placement is done
33-
*/
34-
static std::optional<std::reference_wrapper<const BlkLocRegistry>> blk_loc_registry_ref;
35-
36-
static std::optional<std::reference_wrapper<const vtr::vector<NocLinkId, double>>> noc_link_bandwidth_usages_ref;
37-
3829
/*********************** Accessor Subroutines Definition ********************/
3930

4031
/* This accessor function returns pointer to the global variable
@@ -49,20 +40,4 @@ t_draw_state* get_draw_state_vars() {
4940
return &draw_state;
5041
}
5142

52-
void set_graphics_blk_loc_registry_ref(const BlkLocRegistry& blk_loc_registry) {
53-
blk_loc_registry_ref = std::ref(blk_loc_registry);
54-
}
55-
56-
const BlkLocRegistry& get_graphics_blk_loc_registry_ref() {
57-
return blk_loc_registry_ref->get();
58-
}
59-
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-
6843
#endif // NO_GRAPHICS

vpr/src/draw/draw_global.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,6 @@ t_draw_coords* get_draw_coords_vars();
2727

2828
t_draw_state* get_draw_state_vars();
2929

30-
/**
31-
* @brief Set the reference to placement location variable.
32-
*
33-
* During the placement stage, this reference should point to a local object
34-
* in the placement stage because the placement stage does not change the
35-
* global stage in place_ctx until the end of placement. After the placement is
36-
* done, the reference should point to the global state stored in place_ctx.
37-
*
38-
* @param blk_loc_registry The PlaceLocVars that the reference will point to.
39-
*/
40-
void set_graphics_blk_loc_registry_ref(const BlkLocRegistry& blk_loc_registry);
41-
42-
/**
43-
* @brief Returns the reference to placement block location variables.
44-
* @return A const reference to placement block location variables.
45-
*/
46-
const BlkLocRegistry& get_graphics_blk_loc_registry_ref();
47-
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-
5230
#endif // NO_GRAPHICS
5331

5432
#endif

vpr/src/draw/draw_noc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ void draw_noc(ezgl::renderer* g) {
7474
*/
7575
void draw_noc_usage(vtr::vector<NocLinkId, ezgl::color>& noc_link_colors) {
7676
t_draw_state* draw_state = get_draw_state_vars();
77-
auto& noc_ctx = g_vpr_ctx.noc();
78-
const auto& noc_link_bandwidth_usages = get_noc_link_bandwidth_usages_ref();
77+
const auto& noc_ctx = g_vpr_ctx.noc();
78+
const auto& noc_link_bandwidth_usages = draw_state->get_noc_link_bandwidth_usages_ref();
7979

8080
// check to see if a color map was already created previously
8181
if (draw_state->noc_usage_color_map == nullptr) {

vpr/src/draw/draw_searchbar.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
ezgl::rectangle draw_get_rr_chan_bbox(RRNodeId inode) {
6969
double left = 0, right = 0, top = 0, bottom = 0;
7070
t_draw_coords* draw_coords = get_draw_coords_vars();
71-
auto& device_ctx = g_vpr_ctx.device();
71+
const auto& device_ctx = g_vpr_ctx.device();
7272
const auto& rr_graph = device_ctx.rr_graph;
7373

7474
switch (rr_graph.node_type(inode)) {
@@ -105,14 +105,11 @@ ezgl::rectangle draw_get_rr_chan_bbox(RRNodeId inode) {
105105

106106
void draw_highlight_blocks_color(t_logical_block_type_ptr type,
107107
ClusterBlockId blk_id) {
108-
int k;
109-
ClusterBlockId fanblk;
110-
111108
t_draw_state* draw_state = get_draw_state_vars();
112-
auto& cluster_ctx = g_vpr_ctx.clustering();
113-
auto& block_locs = get_graphics_blk_loc_registry_ref().block_locs();
109+
const auto& cluster_ctx = g_vpr_ctx.clustering();
110+
const auto& block_locs = draw_state->get_graphics_blk_loc_registry_ref().block_locs();
114111

115-
for (k = 0; k < type->pb_type->num_pins; k++) { /* Each pin on a CLB */
112+
for (int k = 0; k < type->pb_type->num_pins; k++) { /* Each pin on a CLB */
116113
ClusterNetId net_id = cluster_ctx.clb_nlist.block_net(blk_id, k);
117114

118115
if (net_id == ClusterNetId::INVALID()) {
@@ -130,27 +127,27 @@ void draw_highlight_blocks_color(t_logical_block_type_ptr type,
130127
/* If block already highlighted, de-highlight the fanout. (the deselect case)*/
131128
draw_state->net_color[net_id] = ezgl::BLACK;
132129
for (auto pin_id : cluster_ctx.clb_nlist.net_sinks(net_id)) {
133-
fanblk = cluster_ctx.clb_nlist.pin_block(pin_id);
130+
ClusterBlockId fanblk = cluster_ctx.clb_nlist.pin_block(pin_id);
134131
draw_reset_blk_color(fanblk);
135132
}
136133
} else {
137134
/* Highlight the fanout */
138135
draw_state->net_color[net_id] = DRIVES_IT_COLOR;
139136
for (auto pin_id : cluster_ctx.clb_nlist.net_sinks(net_id)) {
140-
fanblk = cluster_ctx.clb_nlist.pin_block(pin_id);
137+
ClusterBlockId fanblk = cluster_ctx.clb_nlist.pin_block(pin_id);
141138
draw_state->set_block_color(fanblk, DRIVES_IT_COLOR);
142139
}
143140
}
144141
} else { /* This net is fanin to the block. */
145142
if (draw_state->block_color(blk_id) == SELECTED_COLOR) {
146143
/* If block already highlighted, de-highlight the fanin. (the deselect case)*/
147144
draw_state->net_color[net_id] = ezgl::BLACK;
148-
fanblk = cluster_ctx.clb_nlist.net_driver_block(net_id); /* DRIVER to net */
145+
ClusterBlockId fanblk = cluster_ctx.clb_nlist.net_driver_block(net_id); /* DRIVER to net */
149146
draw_reset_blk_color(fanblk);
150147
} else {
151148
/* Highlight the fanin */
152149
draw_state->net_color[net_id] = DRIVEN_BY_IT_COLOR;
153-
fanblk = cluster_ctx.clb_nlist.net_driver_block(net_id); /* DRIVER to net */
150+
ClusterBlockId fanblk = cluster_ctx.clb_nlist.net_driver_block(net_id); /* DRIVER to net */
154151
draw_state->set_block_color(fanblk, DRIVEN_BY_IT_COLOR);
155152
}
156153
}
@@ -211,7 +208,7 @@ void highlight_nets(char* message, RRNodeId hit_node, bool is_flat) {
211208
*/
212209
void draw_highlight_fan_in_fan_out(const std::set<RRNodeId>& nodes) {
213210
t_draw_state* draw_state = get_draw_state_vars();
214-
auto& device_ctx = g_vpr_ctx.device();
211+
const auto& device_ctx = g_vpr_ctx.device();
215212
const auto& rr_graph = device_ctx.rr_graph;
216213

217214
for (auto node : nodes) {
@@ -267,8 +264,8 @@ void deselect_all() {
267264
// as well as clearing the highlighed sub-block
268265

269266
t_draw_state* draw_state = get_draw_state_vars();
270-
auto& cluster_ctx = g_vpr_ctx.clustering();
271-
auto& device_ctx = g_vpr_ctx.device();
267+
const auto& cluster_ctx = g_vpr_ctx.clustering();
268+
const auto& device_ctx = g_vpr_ctx.device();
272269

273270
/* Create some colour highlighting */
274271
for (auto blk_id : cluster_ctx.clb_nlist.blocks()) {

vpr/src/draw/draw_types.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ float t_draw_coords::get_tile_height() {
8787
}
8888

8989
ezgl::rectangle t_draw_coords::get_pb_bbox(ClusterBlockId clb_index, const t_pb_graph_node& pb_gnode) {
90-
auto& block_locs = get_graphics_blk_loc_registry_ref().block_locs();
91-
auto& cluster_ctx = g_vpr_ctx.clustering();
90+
t_draw_state* draw_state = get_draw_state_vars();
91+
const auto& block_locs = draw_state->get_graphics_blk_loc_registry_ref().block_locs();
92+
const auto& cluster_ctx = g_vpr_ctx.clustering();
9293

9394
return get_pb_bbox(block_locs[clb_index].loc.layer,
9495
block_locs[clb_index].loc.x,
@@ -99,7 +100,7 @@ ezgl::rectangle t_draw_coords::get_pb_bbox(ClusterBlockId clb_index, const t_pb_
99100
}
100101

101102
ezgl::rectangle t_draw_coords::get_pb_bbox(int grid_layer, int grid_x, int grid_y, int sub_block_index, const t_logical_block_type_ptr logical_block_type, const t_pb_graph_node& pb_gnode) {
102-
auto& device_ctx = g_vpr_ctx.device();
103+
const auto& device_ctx = g_vpr_ctx.device();
103104
t_draw_pb_type_info& blk_type_info = this->blk_info.at(logical_block_type->index);
104105

105106
ezgl::rectangle result = blk_type_info.get_pb_bbox(pb_gnode);
@@ -118,7 +119,7 @@ ezgl::rectangle t_draw_coords::get_pb_bbox(int grid_layer, int grid_x, int grid_
118119
}
119120

120121
ezgl::rectangle t_draw_coords::get_pb_bbox(int grid_layer, int grid_x, int grid_y, int sub_block_index, const t_logical_block_type_ptr logical_block_type) {
121-
auto& device_ctx = g_vpr_ctx.device();
122+
const auto& device_ctx = g_vpr_ctx.device();
122123
t_draw_pb_type_info& blk_type_info = this->blk_info.at(logical_block_type->index);
123124

124125
auto& pb_gnode = *logical_block_type->pb_graph_head;
@@ -141,7 +142,7 @@ ezgl::rectangle t_draw_coords::get_absolute_pb_bbox(const ClusterBlockId clb_ind
141142
ezgl::rectangle result = this->get_pb_bbox(clb_index, *pb_gnode);
142143

143144
// go up the graph, adding the parent bboxes to the result,
144-
// ie. make it relative to one level higher each time.
145+
// i.e. make it relative to one level higher each time.
145146
while (pb_gnode && !pb_gnode->is_root()) {
146147
ezgl::rectangle parents_bbox = this->get_pb_bbox(clb_index, *pb_gnode->parent_pb_graph_node);
147148
result += parents_bbox.bottom_left();
@@ -152,7 +153,8 @@ ezgl::rectangle t_draw_coords::get_absolute_pb_bbox(const ClusterBlockId clb_ind
152153
}
153154

154155
ezgl::rectangle t_draw_coords::get_absolute_clb_bbox(const ClusterBlockId clb_index, const t_logical_block_type_ptr block_type) {
155-
auto& block_locs = get_graphics_blk_loc_registry_ref().block_locs();
156+
t_draw_state* draw_state = get_draw_state_vars();
157+
const auto& block_locs = draw_state->get_graphics_blk_loc_registry_ref().block_locs();
156158

157159
t_pl_loc loc = block_locs[clb_index].loc;
158160
return get_pb_bbox(loc.layer, loc.x, loc.y, loc.sub_tile, block_type);

0 commit comments

Comments
 (0)