Skip to content

Commit b08ba66

Browse files
committed
gpl: add HPWL vs Iteration chart in debug mode
Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
1 parent 689863b commit b08ba66

4 files changed

Lines changed: 25 additions & 5 deletions

File tree

src/gpl/src/graphics.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,16 @@ Graphics::Graphics(utl::Logger* logger,
5555
logger_(logger),
5656
mode_(Nesterov)
5757
{
58-
gui::Gui::get()->registerRenderer(this);
58+
gui::Gui* gui = gui::Gui::get();
59+
gui->registerRenderer(this);
60+
61+
// Setup the chart
62+
chart_ = gui->addChart("GPL");
63+
chart_->setAxisLabel("Iteration", odb::horizontal);
64+
chart_->setAxisLabel("HPWL (μm)", odb::vertical);
65+
chart_->setAxisFormat("%d", odb::horizontal);
66+
chart_->setAxisFormat("%.2e", odb::vertical);
67+
5968
initHeatmap();
6069
if (inst) {
6170
for (size_t idx = 0; idx < nbc_->getGCells().size(); ++idx) {
@@ -226,7 +235,7 @@ void Graphics::drawSingleGCell(const GCell* gCell, gui::Painter& painter)
226235
}
227236

228237
// Highlight selection (highest priority)
229-
if (gCell == nbc_->getGCellByIndex(selected_)) {
238+
if (selected_ != kInvalidIndex && gCell == nbc_->getGCellByIndex(selected_)) {
230239
color = gui::Painter::kYellow;
231240
color.a = 180;
232241
}
@@ -293,7 +302,7 @@ void Graphics::drawNesterov(gui::Painter& painter)
293302
}
294303

295304
// Draw lines to neighbors
296-
if (nbc_->getGCellByIndex(selected_)) {
305+
if (selected_ != kInvalidIndex && nbc_->getGCellByIndex(selected_)) {
297306
painter.setPen(gui::Painter::kYellow, true);
298307
for (GPin* pin : nbc_->getGCellByIndex(selected_)->gPins()) {
299308
GNet* net = pin->gNet();
@@ -385,6 +394,12 @@ void Graphics::reportSelected()
385394
}
386395
}
387396

397+
void Graphics::addIter(const int iter)
398+
{
399+
odb::dbBlock* block = pbc_->db()->getChip()->getBlock();
400+
chart_->addPoint(iter, block->dbuToMicrons(nbc_->getHpwl()));
401+
}
402+
388403
void Graphics::cellPlot(bool pause)
389404
{
390405
gui::Gui::get()->redraw();

src/gpl/src/graphics.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ class Graphics : public gui::Renderer, public gui::HeatMapDataSource
5454
// Draw the graphics; optionally pausing afterwards
5555
void cellPlot(bool pause = false);
5656

57+
// Update the chart for the current iter
58+
void addIter(int iter);
59+
5760
// Draw the MBFF mapping
5861
void mbffMapping(const LineSegs& segs);
5962
void mbffFlopClusters(const std::vector<odb::dbInst*>& ffs);
@@ -130,6 +133,7 @@ class Graphics : public gui::Renderer, public gui::HeatMapDataSource
130133
LineSegs mbff_edges_;
131134
std::vector<odb::dbInst*> mbff_cluster_;
132135
Mode mode_;
136+
gui::Chart* chart_{nullptr};
133137

134138
void initHeatmap();
135139
void drawNesterov(gui::Painter& painter);

src/gpl/src/nesterovPlace.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ int NesterovPlace::doNesterovPlace(int start_iter)
423423

424424
const int debug_start_iter = npVars_.debug_start_iter;
425425
if (graphics_ && (debug_start_iter == 0 || iter + 1 >= debug_start_iter)) {
426+
graphics_->addIter(iter);
426427
bool update
427428
= (iter == 0 || (iter + 1) % npVars_.debug_update_iterations == 0);
428429
if (update) {

src/gui/src/chartsWidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class GuiChart : public Chart
3333

3434
void setAxisLabel(const std::string& label,
3535
odb::Orientation2D orientation) override;
36-
void setAxisFormat(const std::string& label,
36+
void setAxisFormat(const std::string& format,
3737
odb::Orientation2D orientation) override;
38-
void addPoint(const double x, const double y) override;
38+
void addPoint(double x, double y) override;
3939

4040
private:
4141
QChart* chart_;

0 commit comments

Comments
 (0)