Skip to content

Commit 112d358

Browse files
Merge pull request #3273 from robluo/fix-ap-graphics-segfault
[bug fix] analytical place with graphics no longer segfault
2 parents 4e04b79 + b2e9698 commit 112d358

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

vpr/src/analytical_place/full_legalizer.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959

6060
#include "setup_grid.h"
6161
#include "stats.h"
62+
#ifndef NO_GRAPHICS
63+
#include "draw_global.h"
64+
#endif
6265

6366
std::unique_ptr<FullLegalizer> make_full_legalizer(e_ap_full_legalizer full_legalizer_type,
6467
const APNetlist& ap_netlist,
@@ -1003,6 +1006,7 @@ void FlatRecon::legalize(const PartialPlacement& p_placement) {
10031006

10041007
// Perform the initial placement on created clusters.
10051008
place_clusters(p_placement);
1009+
update_drawing_data_structures();
10061010
}
10071011

10081012
void NaiveFullLegalizer::create_clusters(const PartialPlacement& p_placement) {
@@ -1219,6 +1223,7 @@ void NaiveFullLegalizer::legalize(const PartialPlacement& p_placement) {
12191223
// made part of the placement and verify placement should check for
12201224
// it.
12211225
post_place_sync();
1226+
update_drawing_data_structures();
12221227
}
12231228

12241229
void APPack::legalize(const PartialPlacement& p_placement) {
@@ -1304,4 +1309,14 @@ void APPack::legalize(const PartialPlacement& p_placement) {
13041309

13051310
// Synchronize the pins in the clusters after placement.
13061311
post_place_sync();
1312+
update_drawing_data_structures();
13071313
}
1314+
1315+
void FullLegalizer::update_drawing_data_structures() {
1316+
#ifndef NO_GRAPHICS
1317+
// update graphic resources incase of clustering changes
1318+
if (get_draw_state_vars()) {
1319+
get_draw_state_vars()->refresh_graphic_resources_after_cluster_change();
1320+
}
1321+
#endif
1322+
}

vpr/src/analytical_place/full_legalizer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ class FullLegalizer {
5959
* device grid and fixed blocks are observed.
6060
*/
6161
virtual void legalize(const PartialPlacement& p_placement) = 0;
62+
63+
/// @brief Update drawing data structure for current placement
64+
void update_drawing_data_structures();
6265

6366
protected:
6467
/// @brief The AP Netlist to fully legalize the flat placement of.

vpr/src/draw/draw_types.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ void t_draw_state::reset_block_colors() {
4343
true);
4444
}
4545

46+
void t_draw_state::refresh_graphic_resources_after_cluster_change() {
47+
const ClusteringContext& cluster_ctx = g_vpr_ctx.clustering();
48+
const AtomContext& atom_ctx = g_vpr_ctx.atom();
49+
50+
// Resize block color vectors to match the possibly new clustered size
51+
block_color_.resize(cluster_ctx.clb_nlist.blocks().size());
52+
use_default_block_color_.resize(cluster_ctx.clb_nlist.blocks().size());
53+
reset_block_colors();
54+
55+
// Resize net color as well since they might be rebuild in analytical placement
56+
if (is_flat) {
57+
net_color.resize(atom_ctx.netlist().nets().size());
58+
} else {
59+
net_color.resize(cluster_ctx.clb_nlist.nets().size());
60+
}
61+
std::fill(net_color.begin(), net_color.end(), ezgl::BLACK);
62+
}
63+
4664
/**************************************************
4765
* begin t_draw_pb_type_info function definitions *
4866
**************************************************/

vpr/src/draw/draw_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@ struct t_draw_state {
333333
void reset_block_color(ClusterBlockId blk);
334334
void reset_block_colors();
335335

336+
///@brief Refresh graphics resources' size after update to cluster blocks size
337+
void refresh_graphic_resources_after_cluster_change();
338+
336339
std::vector<std::pair<t_pl_loc, ezgl::color>> colored_locations;
337340

338341
/// @brief Stores UI checkbox struct for passing into the callback functions

0 commit comments

Comments
 (0)