Skip to content

Commit 84cd684

Browse files
author
Naveen Venkat
committed
Fix headless GUI heatmap dumps
Signed-off-by: Naveen Venkat <archgen.guest@nyayanidhi.in>
1 parent 75d6372 commit 84cd684

4 files changed

Lines changed: 83 additions & 6 deletions

File tree

src/gui/include/gui/gui.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ class Gui
10451045

10461046
void registerHeatMap(HeatMapDataSource* heatmap);
10471047
void unregisterHeatMap(HeatMapDataSource* heatmap);
1048-
const std::set<HeatMapDataSource*>& getHeatMaps() { return heat_maps_; }
1048+
const std::set<HeatMapDataSource*>& getHeatMaps();
10491049
HeatMapDataSource* getHeatMap(const std::string& name);
10501050

10511051
// returns the Gui singleton
@@ -1082,6 +1082,7 @@ class Gui
10821082

10831083
private:
10841084
Gui();
1085+
void syncHeatMapChips();
10851086

10861087
void registerDescriptor(const std::type_info& type,
10871088
const Descriptor* descriptor);

src/gui/src/gui.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#endif
3131
#include <cmath>
3232
#include <optional>
33+
#include <set>
3334
#include <stdexcept>
3435
#include <string>
3536
#include <vector>
@@ -1171,8 +1172,32 @@ void Gui::unregisterHeatMap(HeatMapDataSource* heatmap)
11711172
heat_maps_.erase(heatmap);
11721173
}
11731174

1175+
void Gui::syncHeatMapChips()
1176+
{
1177+
if (hasUI() || db_ == nullptr) {
1178+
return;
1179+
}
1180+
1181+
// Console and headless sessions do not receive MainWindow::setBlock().
1182+
auto* chip = db_->getChip();
1183+
for (auto* heat_map : heat_maps_) {
1184+
if (heat_map->getChip() != chip) {
1185+
heat_map->setChip(chip);
1186+
heat_map->destroyMap();
1187+
}
1188+
}
1189+
}
1190+
1191+
const std::set<HeatMapDataSource*>& Gui::getHeatMaps()
1192+
{
1193+
syncHeatMapChips();
1194+
return heat_maps_;
1195+
}
1196+
11741197
HeatMapDataSource* Gui::getHeatMap(const std::string& name)
11751198
{
1199+
syncHeatMapChips();
1200+
11761201
HeatMapDataSource* source = nullptr;
11771202

11781203
for (auto* heat_map : heat_maps_) {

src/gui/test/CMakeLists.txt

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1-
or_integration_tests(
2-
"gui"
3-
TESTS
4-
supported
5-
)
1+
set(GUI_TESTS supported)
2+
set(GUI_PASSFAIL_TESTS)
63

4+
if (Qt5_FOUND AND BUILD_GUI)
5+
list(APPEND GUI_PASSFAIL_TESTS dump_heatmap_headless)
6+
endif()
7+
8+
if (GUI_PASSFAIL_TESTS)
9+
or_integration_tests(
10+
"gui"
11+
TESTS
12+
${GUI_TESTS}
13+
PASSFAIL_TESTS
14+
${GUI_PASSFAIL_TESTS}
15+
)
16+
else()
17+
or_integration_tests(
18+
"gui"
19+
TESTS
20+
${GUI_TESTS}
21+
)
22+
endif()
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
set script_dir [file dirname [info script]]
2+
set openroad_test_dir [file normalize [file join $script_dir .. .. .. test]]
3+
4+
source [file join $openroad_test_dir helpers.tcl]
5+
6+
if { ![gui::supported] } {
7+
puts "fail"
8+
exit 1
9+
}
10+
11+
suppress_message ODB 128
12+
suppress_message ODB 130
13+
suppress_message ODB 131
14+
suppress_message ODB 132
15+
suppress_message ODB 133
16+
suppress_message ODB 227
17+
18+
read_lef [file join $openroad_test_dir Nangate45 Nangate45.lef]
19+
read_def [file join $openroad_test_dir gcd_nangate45.def]
20+
21+
set heatmap_file [make_result_file dump_heatmap_headless.csv]
22+
gui::dump_heatmap Placement $heatmap_file
23+
24+
set heatmap [open $heatmap_file r]
25+
set contents [read $heatmap]
26+
close $heatmap
27+
28+
if {
29+
[string first "value (%)" $contents] >= 0
30+
&& [regexp -line {^[0-9.-]+,[0-9.-]+,[0-9.-]+,[0-9.-]+,} $contents]
31+
} {
32+
puts "pass"
33+
} else {
34+
puts "fail"
35+
}

0 commit comments

Comments
 (0)