Skip to content

Commit 72f830a

Browse files
replace accesses to placement context in graphics with accesses to its reference holder
1 parent 7018bc3 commit 72f830a

File tree

7 files changed

+30
-28
lines changed

7 files changed

+30
-28
lines changed

vpr/src/draw/draw.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ static void highlight_blocks(double x, double y) {
10041004
}
10051005

10061006
auto& cluster_ctx = g_vpr_ctx.clustering();
1007-
auto& block_locs = g_vpr_ctx.placement().block_locs();
1007+
auto& block_locs = get_graphics_place_loc_vars_ref().block_locs();
10081008

10091009
VTR_ASSERT(clb_index != EMPTY_BLOCK_ID);
10101010

@@ -1048,7 +1048,7 @@ ClusterBlockId get_cluster_block_id_from_xy_loc(double x, double y) {
10481048
ClusterBlockId clb_index = EMPTY_BLOCK_ID;
10491049
auto& device_ctx = g_vpr_ctx.device();
10501050
auto& cluster_ctx = g_vpr_ctx.clustering();
1051-
auto& place_ctx = g_vpr_ctx.placement();
1051+
const auto& grid_blocks = get_graphics_place_loc_vars_ref().grid_blocks();
10521052

10531053
/// determine block ///
10541054
ezgl::rectangle clb_bbox;
@@ -1071,7 +1071,7 @@ ClusterBlockId get_cluster_block_id_from_xy_loc(double x, double y) {
10711071
// iterate over sub_blocks
10721072
const auto& type = device_ctx.grid.get_physical_type({i, j, layer_num});
10731073
for (int k = 0; k < type->capacity; ++k) {
1074-
clb_index = place_ctx.get_grid_blocks().block_at_location({i, j, k, layer_num});
1074+
clb_index = grid_blocks.block_at_location({i, j, k, layer_num});
10751075
if (clb_index != EMPTY_BLOCK_ID) {
10761076
clb_bbox = draw_coords->get_absolute_clb_bbox(clb_index,
10771077
cluster_ctx.clb_nlist.block_type(clb_index));

vpr/src/draw/draw_basic.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void drawplace(ezgl::renderer* g) {
103103
t_draw_coords* draw_coords = get_draw_coords_vars();
104104
auto& device_ctx = g_vpr_ctx.device();
105105
auto& cluster_ctx = g_vpr_ctx.clustering();
106-
auto& place_ctx = g_vpr_ctx.placement();
106+
const auto& grid_blocks = get_graphics_place_loc_vars_ref().grid_blocks();
107107

108108
ClusterBlockId bnum;
109109
int num_sub_tiles;
@@ -136,7 +136,7 @@ void drawplace(ezgl::renderer* g) {
136136

137137
for (int k = 0; k < num_sub_tiles; ++k) {
138138
/* Look at the tile at start of large block */
139-
bnum = place_ctx.get_grid_blocks().block_at_location({i, j, k, layer_num});
139+
bnum = grid_blocks.block_at_location({i, j, k, layer_num});
140140
/* Fill background for the clb. Do not fill if "show_blk_internal"
141141
* is toggled.
142142
*/
@@ -159,7 +159,7 @@ void drawplace(ezgl::renderer* g) {
159159
block_color);
160160
}
161161
// No color specified at this location; use the block color.
162-
if (current_loc_is_highlighted == false) {
162+
if (!current_loc_is_highlighted) {
163163
if (bnum != EMPTY_BLOCK_ID) {
164164
block_color = draw_state->block_color(bnum);
165165
} else {
@@ -230,7 +230,7 @@ void drawnets(ezgl::renderer* g) {
230230

231231
ClusterBlockId b1, b2;
232232
auto& cluster_ctx = g_vpr_ctx.clustering();
233-
auto& block_locs = g_vpr_ctx.placement().block_locs();
233+
auto& block_locs = get_graphics_place_loc_vars_ref().block_locs();
234234

235235
float transparency_factor;
236236
float NET_ALPHA = draw_state->net_alpha;
@@ -804,7 +804,7 @@ void draw_placement_macros(ezgl::renderer* g) {
804804
t_draw_coords* draw_coords = get_draw_coords_vars();
805805

806806
auto& place_ctx = g_vpr_ctx.placement();
807-
auto& block_locs = place_ctx.block_locs();
807+
auto& block_locs = get_graphics_place_loc_vars_ref().block_locs();
808808

809809
for (const t_pl_macro& pl_macro : place_ctx.pl_macros) {
810810

@@ -1187,7 +1187,7 @@ void draw_crit_path_elements(const std::vector<tatum::TimingPath>& paths, const
11871187
}
11881188

11891189
int get_timing_path_node_layer_num(tatum::NodeId node) {
1190-
auto& block_locs = g_vpr_ctx.placement().block_locs();
1190+
auto& block_locs = get_graphics_place_loc_vars_ref().block_locs();
11911191
auto& atom_ctx = g_vpr_ctx.atom();
11921192

11931193
AtomPinId atom_pin = atom_ctx.lookup.tnode_atom_pin(node);
@@ -1420,7 +1420,7 @@ void draw_block_pin_util() {
14201420

14211421
auto& device_ctx = g_vpr_ctx.device();
14221422
auto& cluster_ctx = g_vpr_ctx.clustering();
1423-
auto& block_locs = g_vpr_ctx.placement().block_locs();
1423+
auto& block_locs = get_graphics_place_loc_vars_ref().block_locs();
14241424

14251425
std::map<t_physical_tile_type_ptr, size_t> total_input_pins;
14261426
std::map<t_physical_tile_type_ptr, size_t> total_output_pins;

vpr/src/draw/draw_searchbar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void draw_highlight_blocks_color(t_logical_block_type_ptr type,
110110

111111
t_draw_state* draw_state = get_draw_state_vars();
112112
auto& cluster_ctx = g_vpr_ctx.clustering();
113-
auto& block_locs = g_vpr_ctx.placement().block_locs();
113+
auto& block_locs = get_graphics_place_loc_vars_ref().block_locs();
114114

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

vpr/src/draw/draw_types.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ezgl::color t_draw_state::block_color(ClusterBlockId blk) const {
1515
if (use_default_block_color_[blk]) {
1616

1717
auto& cluster_ctx = g_vpr_ctx.clustering();
18-
auto& block_locs = g_vpr_ctx.placement().block_locs();
18+
auto& block_locs = get_graphics_place_loc_vars_ref().block_locs();
1919

2020
t_physical_tile_type_ptr tile_type = nullptr;
2121
if (block_locs.empty()) { //No placement, pick best match
@@ -88,7 +88,7 @@ float t_draw_coords::get_tile_height() {
8888
}
8989

9090
ezgl::rectangle t_draw_coords::get_pb_bbox(ClusterBlockId clb_index, const t_pb_graph_node& pb_gnode) {
91-
auto& block_locs = g_vpr_ctx.placement().block_locs();
91+
auto& block_locs = get_graphics_place_loc_vars_ref().block_locs();
9292
auto& cluster_ctx = g_vpr_ctx.clustering();
9393

9494
return get_pb_bbox(block_locs[clb_index].loc.layer,
@@ -153,7 +153,7 @@ ezgl::rectangle t_draw_coords::get_absolute_pb_bbox(const ClusterBlockId clb_ind
153153
}
154154

155155
ezgl::rectangle t_draw_coords::get_absolute_clb_bbox(const ClusterBlockId clb_index, const t_logical_block_type_ptr block_type) {
156-
auto& block_locs = g_vpr_ctx.placement().block_locs();
156+
auto& block_locs = get_graphics_place_loc_vars_ref().block_locs();
157157

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

vpr/src/draw/intra_logic_block.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void draw_internal_draw_subblk(ezgl::renderer* g) {
152152
}
153153
auto& device_ctx = g_vpr_ctx.device();
154154
auto& cluster_ctx = g_vpr_ctx.clustering();
155-
auto& place_ctx = g_vpr_ctx.placement();
155+
const auto& grid_blocks = get_graphics_place_loc_vars_ref().grid_blocks();
156156

157157
int total_layer_num = device_ctx.grid.get_num_layers();
158158

@@ -175,14 +175,16 @@ void draw_internal_draw_subblk(ezgl::renderer* g) {
175175
int num_sub_tiles = type->capacity;
176176
for (int k = 0; k < num_sub_tiles; ++k) {
177177
/* Don't draw if block is empty. */
178-
if (place_ctx.get_grid_blocks().block_at_location({i, j, k, layer_num}) == EMPTY_BLOCK_ID || place_ctx.get_grid_blocks().block_at_location({i, j, k, layer_num}) == INVALID_BLOCK_ID)
178+
if (grid_blocks.block_at_location({i, j, k, layer_num}) == EMPTY_BLOCK_ID || grid_blocks.block_at_location({i, j, k, layer_num}) == INVALID_BLOCK_ID) {
179179
continue;
180+
}
180181

181182
/* Get block ID */
182-
ClusterBlockId bnum = place_ctx.get_grid_blocks().block_at_location({i, j, k, layer_num});
183+
ClusterBlockId bnum = grid_blocks.block_at_location({i, j, k, layer_num});
183184
/* Safety check, that physical blocks exists in the CLB */
184-
if (cluster_ctx.clb_nlist.block_pb(bnum) == nullptr)
185+
if (cluster_ctx.clb_nlist.block_pb(bnum) == nullptr) {
185186
continue;
187+
}
186188
draw_internal_pb(bnum, cluster_ctx.clb_nlist.block_pb(bnum), ezgl::rectangle({0, 0}, 0, 0), cluster_ctx.clb_nlist.block_type(bnum), g);
187189
}
188190
}
@@ -271,7 +273,7 @@ draw_internal_calc_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node
271273
float sub_tile_x, sub_tile_y;
272274
float child_width, child_height;
273275
auto& device_ctx = g_vpr_ctx.device();
274-
auto& place_ctx = g_vpr_ctx.placement();
276+
const auto& grid_blocks = get_graphics_place_loc_vars_ref().grid_blocks();
275277

276278
// get the bbox for this pb type
277279
ezgl::rectangle& pb_bbox = get_draw_coords_vars()->blk_info.at(type_descrip_index).get_pb_bbox_ref(*pb_graph_node);
@@ -289,7 +291,7 @@ draw_internal_calc_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node
289291
int capacity = device_ctx.physical_tile_types[type_descrip_index].capacity;
290292
// TODO: this is a hack - should be fixed for the layer_num
291293
const auto& type = device_ctx.grid.get_physical_type({1, 0, 0});
292-
if (capacity > 1 && device_ctx.grid.width() > 0 && device_ctx.grid.height() > 0 && place_ctx.get_grid_blocks().get_usage({1, 0, 0}) != 0
294+
if (capacity > 1 && device_ctx.grid.width() > 0 && device_ctx.grid.height() > 0 && grid_blocks.get_usage({1, 0, 0}) != 0
293295
&& type_descrip_index == type->index) {
294296
// that should test for io blocks, and setting capacity_divisor > 1
295297
// will squish every thing down
@@ -339,7 +341,7 @@ static void draw_internal_pb(const ClusterBlockId clb_index, t_pb* pb, const ezg
339341
t_draw_coords* draw_coords = get_draw_coords_vars();
340342
t_draw_state* draw_state = get_draw_state_vars();
341343

342-
auto& block_locs = g_vpr_ctx.placement().block_locs();
344+
auto& block_locs = get_graphics_place_loc_vars_ref().block_locs();
343345

344346
t_selected_sub_block_info& sel_sub_info = get_selected_sub_block_info();
345347

@@ -557,7 +559,7 @@ void draw_logical_connections(ezgl::renderer* g) {
557559
t_draw_state* draw_state = get_draw_state_vars();
558560

559561
auto& atom_ctx = g_vpr_ctx.atom();
560-
auto& block_locs = g_vpr_ctx.placement().block_locs();
562+
auto& block_locs = get_graphics_place_loc_vars_ref().block_locs();
561563

562564
g->set_line_dash(ezgl::line_dash::none);
563565

vpr/src/draw/manual_moves.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ void calculate_cost_callback(GtkWidget* /*widget*/, GtkWidget* grid) {
148148

149149
bool is_manual_move_legal(ClusterBlockId block_id, t_pl_loc to) {
150150
auto& cluster_ctx = g_vpr_ctx.clustering();
151-
auto& place_ctx = g_vpr_ctx.placement();
152151
auto& device_ctx = g_vpr_ctx.device();
152+
const auto& grid_blocks = get_graphics_place_loc_vars_ref().grid_blocks();
153153

154154
//if the block is not found
155155
if ((!cluster_ctx.clb_nlist.valid_block_id(ClusterBlockId(block_id)))) {
@@ -173,16 +173,16 @@ bool is_manual_move_legal(ClusterBlockId block_id, t_pl_loc to) {
173173
}
174174

175175
//If the destination block is user constrained, abort this swap
176-
auto b_to = place_ctx.get_grid_blocks().block_at_location(to);
176+
ClusterBlockId b_to = grid_blocks.block_at_location(to);
177177
if (b_to != INVALID_BLOCK_ID && b_to != EMPTY_BLOCK_ID) {
178-
if (place_ctx.block_locs()[b_to].is_fixed) {
178+
if (get_graphics_place_loc_vars_ref().block_locs()[b_to].is_fixed) {
179179
invalid_breakpoint_entry_window("Block is fixed");
180180
return false;
181181
}
182182
}
183183

184184
//If the block requested is already in that location.
185-
t_pl_loc current_block_loc = place_ctx.block_locs()[block_id].loc;
185+
t_pl_loc current_block_loc = get_graphics_place_loc_vars_ref().block_locs()[block_id].loc;
186186
if (to.x == current_block_loc.x && to.y == current_block_loc.y && to.sub_tile == current_block_loc.sub_tile) {
187187
invalid_breakpoint_entry_window("The block is currently in this location");
188188
return false;

vpr/src/draw/search_bar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ void auto_zoom_rr_node(RRNodeId rr_node_id) {
283283
void highlight_cluster_block(ClusterBlockId clb_index) {
284284
char msg[vtr::bufsize];
285285
auto& cluster_ctx = g_vpr_ctx.clustering();
286-
auto& place_ctx = g_vpr_ctx.placement();
286+
const auto& block_locs = get_graphics_place_loc_vars_ref().block_locs();
287287

288288
/// determine block ///
289289
ezgl::rectangle clb_bbox;
@@ -302,7 +302,7 @@ void highlight_cluster_block(ClusterBlockId clb_index) {
302302
draw_highlight_blocks_color(cluster_ctx.clb_nlist.block_type(clb_index), clb_index);
303303
sprintf(msg, "Block #%zu (%s) at (%d, %d) selected.",
304304
size_t(clb_index), cluster_ctx.clb_nlist.block_name(clb_index).c_str(),
305-
place_ctx.block_locs()[clb_index].loc.x, place_ctx.block_locs()[clb_index].loc.y);
305+
block_locs[clb_index].loc.x, block_locs[clb_index].loc.y);
306306
}
307307

308308
application.update_message(msg);

0 commit comments

Comments
 (0)