Skip to content

Commit c6d5c2c

Browse files
committed
gpl: include new gif for routability reverts
Signed-off-by: Augusto Berndt <[email protected]>
1 parent 870e772 commit c6d5c2c

File tree

8 files changed

+75
-27
lines changed

8 files changed

+75
-27
lines changed

src/gpl/src/AbstractGraphics.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,19 @@ class AbstractGraphics
105105
}
106106

107107
// Gui functions.
108-
virtual void gifStart(std::string_view path) = 0;
109-
void gifAddFrame(const odb::Rect& region = odb::Rect(),
108+
// Gui functions.
109+
virtual int gifStart(std::string_view path) = 0;
110+
void gifAddFrame(int key,
111+
const odb::Rect& region = odb::Rect(),
110112
int width_px = 0,
111113
double dbu_per_pixel = 0,
112114
std::optional<int> delay = std::nullopt)
113115
{
114-
gifAddFrameImpl(region, width_px, dbu_per_pixel, delay);
116+
gifAddFrameImpl(key, region, width_px, dbu_per_pixel, delay);
115117
}
116118
virtual void deleteLabel(std::string_view label_name) = 0;
117-
virtual void gifEnd() = 0;
119+
virtual void gifEnd(int key) = 0;
120+
virtual void setDisplayControl(std::string_view name, bool value) = 0;
118121

119122
protected:
120123
virtual void cellPlotImpl(bool pause) = 0;
@@ -130,7 +133,8 @@ class AbstractGraphics
130133
std::string_view heatmap_control,
131134
int image_width_px)
132135
= 0;
133-
virtual void gifAddFrameImpl(const odb::Rect& region,
136+
virtual void gifAddFrameImpl(int key,
137+
const odb::Rect& region,
134138
int width_px,
135139
double dbu_per_pixel,
136140
std::optional<int> delay)

src/gpl/src/graphicsImpl.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -873,28 +873,33 @@ void GraphicsImpl::saveLabeledImageImpl(std::string_view path,
873873
gui->clearSelections();
874874
}
875875

876-
void GraphicsImpl::gifStart(std::string_view path)
876+
int GraphicsImpl::gifStart(std::string_view path)
877877
{
878-
gif_key_ = gui::Gui::get()->gifStart(std::string(path));
878+
return gui::Gui::get()->gifStart(std::string(path));
879879
}
880880

881-
void GraphicsImpl::gifAddFrameImpl(const odb::Rect& region,
881+
void GraphicsImpl::gifAddFrameImpl(int key,
882+
const odb::Rect& region,
882883
int width_px,
883884
double dbu_per_pixel,
884885
std::optional<int> delay)
885886
{
886-
gui::Gui::get()->gifAddFrame(
887-
gif_key_, region, width_px, dbu_per_pixel, delay);
887+
gui::Gui::get()->gifAddFrame(key, region, width_px, dbu_per_pixel, delay);
888888
}
889889

890890
void GraphicsImpl::deleteLabel(std::string_view label_name)
891891
{
892892
gui::Gui::get()->deleteLabel(std::string(label_name));
893893
}
894894

895-
void GraphicsImpl::gifEnd()
895+
void GraphicsImpl::gifEnd(int key)
896896
{
897-
gui::Gui::get()->gifEnd(gif_key_);
897+
gui::Gui::get()->gifEnd(key);
898+
}
899+
900+
void GraphicsImpl::setDisplayControl(std::string_view name, bool value)
901+
{
902+
gui::Gui::get()->setDisplayControlsVisible(std::string(name), value);
898903
}
899904

900905
} // namespace gpl

src/gpl/src/graphicsImpl.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@ class GraphicsImpl : public gpl::AbstractGraphics,
7474

7575
void setDebugOn(bool set_on) override { debug_on_ = set_on; }
7676

77-
void gifStart(std::string_view path) override;
77+
void setDisplayControl(std::string_view name, bool value) override;
78+
79+
int gifStart(std::string_view path) override;
7880
void deleteLabel(std::string_view label_name) override;
79-
void gifEnd() override;
81+
void gifEnd(int key) override;
8082

8183
protected:
8284
void cellPlotImpl(bool pause) override;
@@ -90,7 +92,8 @@ class GraphicsImpl : public gpl::AbstractGraphics,
9092
bool select_buffers,
9193
std::string_view heatmap_control,
9294
int image_width_px) override;
93-
void gifAddFrameImpl(const odb::Rect& region,
95+
void gifAddFrameImpl(int key,
96+
const odb::Rect& region,
9497
int width_px,
9598
double dbu_per_pixel,
9699
std::optional<int> delay) override;
@@ -176,7 +179,6 @@ class GraphicsImpl : public gpl::AbstractGraphics,
176179
gui::Chart* stepLength_chart_{nullptr};
177180
gui::Chart* routing_chart_{nullptr};
178181
bool debug_on_{false};
179-
int gif_key_{0};
180182

181183
void initHeatmap();
182184
void drawNesterov(gui::Painter& painter);

src/gpl/src/graphicsNone.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ class GraphicsNone : public AbstractGraphics
5353
bool enabled() override { return false; }
5454
void setDebugOn(bool set_on) override {}
5555

56-
void gifStart(std::string_view path) override {};
56+
int gifStart(std::string_view path) override { return 0; };
5757
void deleteLabel(std::string_view label_name) override {}
58-
void gifEnd() override {}
58+
void gifEnd(int key) override {}
59+
void setDisplayControl(std::string_view name, bool value) override {}
5960

6061
protected:
6162
void cellPlotImpl(bool pause) override {}
@@ -73,7 +74,8 @@ class GraphicsNone : public AbstractGraphics
7374
int image_width_px) override
7475
{
7576
}
76-
void gifAddFrameImpl(const odb::Rect& region,
77+
void gifAddFrameImpl(int key,
78+
const odb::Rect& region,
7779
int width_px,
7880
double dbu_per_pixel,
7981
std::optional<int> delay) override

src/gpl/src/initialPlace.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void InitialPlace::doBicgstabPlace(int threads)
6464
setPlaceInstExtId();
6565

6666
if (graphics_enabled) {
67-
graphics_->gifStart("initPlacement.gif");
67+
gif_key_ = graphics_->gifStart("initPlacement.gif");
6868
}
6969

7070
for (size_t iter = 1; iter <= ipVars_.maxIter; iter++) {
@@ -88,7 +88,7 @@ void InitialPlace::doBicgstabPlace(int threads)
8888
odb::Rect bbox = pbc_->db()->getChip()->getBlock()->getBBox()->getBox();
8989
int max_dim = std::max(bbox.dx(), bbox.dy());
9090
double dbu_per_pixel = static_cast<double>(max_dim) / 1000.0;
91-
graphics_->gifAddFrame(region, 500, dbu_per_pixel, 20);
91+
graphics_->gifAddFrame(gif_key_, region, 500, dbu_per_pixel, 20);
9292
}
9393

9494
if (std::isnan(error.x) || std::isnan(error.y)) {
@@ -115,7 +115,7 @@ void InitialPlace::doBicgstabPlace(int threads)
115115
}
116116

117117
if (graphics_enabled) {
118-
graphics_->gifEnd();
118+
graphics_->gifEnd(gif_key_);
119119
}
120120
}
121121

src/gpl/src/initialPlace.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class InitialPlace
5050
std::vector<std::shared_ptr<PlacerBase>> pbVec_;
5151
std::unique_ptr<AbstractGraphics> graphics_;
5252
utl::Logger* log_ = nullptr;
53+
int gif_key_ = 0;
5354

5455
// Solve two SparseMatrix equations here;
5556
//

src/gpl/src/nesterovPlace.cpp

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ void NesterovPlace::updateIterGraphics(
308308

309309
if (npVars_.debug_generate_images && iter == 0) {
310310
std::string gif_path = fmt::format("{}/placement.gif", reports_dir);
311-
graphics_->gifStart(gif_path);
311+
placement_gif_key_ = graphics_->gifStart(gif_path);
312312
}
313313

314314
if (npVars_.debug_generate_images && iter % 10 == 0) {
@@ -325,7 +325,8 @@ void NesterovPlace::updateIterGraphics(
325325
std::string label_name = fmt::format("frame_label_{}", iter);
326326

327327
graphics_->addFrameLabel(bbox, label, label_name);
328-
graphics_->gifAddFrame(region, width_px, dbu_per_pixel, delay);
328+
graphics_->gifAddFrame(
329+
placement_gif_key_, region, width_px, dbu_per_pixel, delay);
329330
graphics_->deleteLabel(label_name);
330331
}
331332

@@ -747,10 +748,35 @@ void NesterovPlace::runRoutability(int iter,
747748
label,
748749
/* select_buffers = */ false,
749750
"Heat Maps/Estimated Congestion (RUDY)");
751+
752+
odb::Rect region;
753+
int width_px = 500;
754+
odb::Rect bbox = pbc_->db()->getChip()->getBlock()->getBBox()->getBox();
755+
int max_dim = std::max(bbox.dx(), bbox.dy());
756+
double dbu_per_pixel = static_cast<double>(max_dim) / 1000.0;
757+
int delay = 20;
758+
std::string label_name = fmt::format("frame_label_routability_{}", iter);
759+
760+
if (routability_gif_key_ == -1) {
761+
log_->report("start routability gif at iter {}", iter);
762+
std::string gif_path
763+
= fmt::format("{}/routability.gif", routability_driven_dir);
764+
gif_path = fmt::format("{}/routability.gif", routability_driven_dir);
765+
routability_gif_key_ = graphics_->gifStart(gif_path);
766+
}
767+
768+
graphics_->addFrameLabel(bbox, label, label_name);
769+
770+
graphics_->setDisplayControl("Heat Maps/Estimated Congestion (RUDY)",
771+
true);
772+
graphics_->gifAddFrame(
773+
routability_gif_key_, region, width_px, dbu_per_pixel, delay);
774+
graphics_->setDisplayControl("Heat Maps/Estimated Congestion (RUDY)",
775+
false);
776+
777+
graphics_->deleteLabel(label_name);
750778
}
751779

752-
log_->report("call routability with average_overflow_unscaled_: {:.3f}",
753-
average_overflow_unscaled_);
754780
// recover the densityPenalty values
755781
// if further routability-driven is needed
756782
std::pair<bool, bool> result
@@ -799,6 +825,11 @@ void NesterovPlace::runRoutability(int iter,
799825
}
800826

801827
if (!is_routability_need_) {
828+
if (graphics_ && graphics_->enabled() && npVars_.debug_generate_images
829+
&& routability_gif_key_ != -1) {
830+
graphics_->gifEnd(routability_gif_key_);
831+
routability_gif_key_ = -1;
832+
}
802833
for (auto& nb : nbVec_) {
803834
end_routability_area += nb->getNesterovInstsArea();
804835
}
@@ -818,7 +849,7 @@ bool NesterovPlace::isConverged(int gpl_iter_count,
818849

819850
if (num_region_converge == nbVec_.size()) {
820851
if (graphics_ && graphics_->enabled() && npVars_.debug_generate_images) {
821-
graphics_->gifEnd();
852+
graphics_->gifEnd(placement_gif_key_);
822853
}
823854
return true;
824855
}

src/gpl/src/nesterovPlace.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ class NesterovPlace
170170
int recursionCntWlCoef_ = 0;
171171
int recursionCntInitSLPCoef_ = 0;
172172

173+
int placement_gif_key_ = -1;
174+
int routability_gif_key_ = -1;
175+
173176
void init();
174177
void reset();
175178

0 commit comments

Comments
 (0)