Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
216 changes: 117 additions & 99 deletions src/gpl/src/graphicsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@

namespace gpl {

gui::Chart* GraphicsImpl::main_chart_ = nullptr;
gui::Chart* GraphicsImpl::density_chart_ = nullptr;
gui::Chart* GraphicsImpl::stepLength_chart_ = nullptr;
gui::Chart* GraphicsImpl::routing_chart_ = nullptr;

GraphicsImpl::GraphicsImpl(utl::Logger* logger)
: HeatMapDataSource(logger, "gpl", "gpl"), logger_(logger), mode_(Mbff)
{
addDisplayControl(kDrawInstances, true);
gui::Gui::get()->registerRenderer(this);
}

Expand Down Expand Up @@ -66,10 +70,8 @@ void GraphicsImpl::debugForNesterovPlace(
std::vector<std::shared_ptr<PlacerBase>>& pbVec,
std::vector<std::shared_ptr<NesterovBase>>& nbVec,
bool draw_bins,
odb::dbInst* inst)
odb::dbInst* debug_inst)
{
setDebugOn(true);

pbc_ = std::move(pbc);
nbc_ = std::move(nbc);
rb_ = std::move(rb);
Expand All @@ -82,58 +84,36 @@ void GraphicsImpl::debugForNesterovPlace(
if (!gui::Gui::enabled()) {
return;
}
// Setup charts
gui::Gui* gui = gui::Gui::get();
main_chart_ = gui->addChart("GPL", "Iteration", {"HPWL (μm)", "Overflow"});
main_chart_->setXAxisFormat("%d");
main_chart_->setYAxisFormats({"%.2e", "%.2f"});
main_chart_->setYAxisMin({std::nullopt, 0});

density_chart_ = gui->addChart(
"GPL Density Penalty", "Iteration", {"DensityPenalty", "phiCoef"});
density_chart_->setXAxisFormat("%d");
density_chart_->setYAxisFormats({"%.2e", "%.2f"});
density_chart_->setYAxisMin({0.0, nbc_->getNbVars().minPhiCoef});

stepLength_chart_ = gui->addChart(
"GPL StepLength",
"Iteration",
{"StepLength", "CoordiDistance", "GradDistance", "Std area"});
stepLength_chart_->setXAxisFormat("%d");
stepLength_chart_->setYAxisFormats({"%.2e", "%.2f", "%.2f", "%.2f"});
stepLength_chart_->setYAxisMin({0.0, 0.0, 0.0, 0.0});

routing_chart_ = gui->addChart(
"GPL Routing",
"Iteration",
{"avg RUDY", "Std area", "% Overflow Tiles", "Total RUDY Overflow"});
routing_chart_->setXAxisFormat("%d");
routing_chart_->setYAxisFormats({"%.2f", "%.2f", "%.2f", "%.2f"});
routing_chart_->setYAxisMin({0.0, 0.0, 0.0, 0.0});

initHeatmap();
if (inst) {
for (size_t idx = 0; idx < nbc_->getGCells().size(); ++idx) {
auto cell = nbc_->getGCellByIndex(idx);
if (cell->contains(inst)) {
selected_ = idx;
break;

if (debug_on_) {
initCharts();
addDisplayControl(kDrawInstances, true);
gui::Gui::get()->registerRenderer(this);

if (debug_inst) {
for (size_t idx = 0; idx < nbc_->getGCells().size(); ++idx) {
auto cell = nbc_->getGCellByIndex(idx);
if (cell->contains(debug_inst)) {
selected_ = idx;
break;
}
}
}
}

for (const auto& nb : nbVec_) {
for (size_t idx = 0; idx < nb->getGCells().size(); ++idx) {
GCellHandle cell_handle = nb->getGCells()[idx];
if (cell_handle->contains(inst)) {
nb_selected_index_ = &nb - nbVec_.data();
break;
for (const auto& nb : nbVec_) {
for (size_t idx = 0; idx < nb->getGCells().size(); ++idx) {
GCellHandle cell_handle = nb->getGCells()[idx];
if (cell_handle->contains(debug_inst)) {
nb_selected_index_ = &nb - nbVec_.data();
break;
}
}
}
initDebugHeatmap();
}
}

void GraphicsImpl::initHeatmap()
void GraphicsImpl::initDebugHeatmap()
{
addMultipleChoiceSetting(
"Type",
Expand Down Expand Up @@ -169,6 +149,51 @@ void GraphicsImpl::initHeatmap()
registerHeatMap();
}

void GraphicsImpl::initCharts()
{
if (!gui::Gui::enabled()) {
return;
}
gui::Gui* gui = gui::Gui::get();

if (main_chart_ == nullptr) {
main_chart_ = gui->addChart("GPL", "Iteration", {"HPWL (μm)", "Overflow"});
main_chart_->setXAxisFormat("%d");
main_chart_->setYAxisFormats({"%.2e", "%.2f"});
main_chart_->setYAxisMin({std::nullopt, 0});
}

if (density_chart_ == nullptr) {
density_chart_ = gui->addChart(
"GPL Density Penalty", "Iteration", {"DensityPenalty", "phiCoef"});
density_chart_->setXAxisFormat("%d");
density_chart_->setYAxisFormats({"%.2e", "%.2f"});
if (nbc_) {
density_chart_->setYAxisMin({0.0, nbc_->getNbVars().minPhiCoef});
}
}

if (stepLength_chart_ == nullptr) {
stepLength_chart_ = gui->addChart(
"GPL StepLength",
"Iteration",
{"StepLength", "CoordiDistance", "GradDistance", "Std area"});
stepLength_chart_->setXAxisFormat("%d");
stepLength_chart_->setYAxisFormats({"%.2e", "%.2f", "%.2f", "%.2f"});
stepLength_chart_->setYAxisMin({0.0, 0.0, 0.0, 0.0});
}

if (routing_chart_ == nullptr && np_->getNpVars().routability_driven_mode) {
routing_chart_ = gui->addChart(
"GPL Routing",
"Iteration",
{"avg RUDY", "Std area", "% Overflow Tiles", "Total RUDY Overflow"});
routing_chart_->setXAxisFormat("%d");
routing_chart_->setYAxisFormats({"%.2f", "%.2f", "%.2f", "%.2f"});
routing_chart_->setYAxisMin({0.0, 0.0, 0.0, 0.0});
}
}

void GraphicsImpl::drawBounds(gui::Painter& painter)
{
// draw core bounds
Expand Down Expand Up @@ -554,57 +579,50 @@ void GraphicsImpl::addIter(const int iter, const double overflow)
odb::dbBlock* block = pbc_->db()->getChip()->getBlock();
main_chart_->addPoint(iter, {block->dbuToMicrons(nbc_->getHpwl()), overflow});

if (density_chart_) {
std::vector<double> values;
if (!nbVec_.empty() && nbVec_[0]) {
values.push_back((static_cast<double>(nbVec_[0]->getDensityPenalty())));
values.push_back(static_cast<double>(nbVec_[0]->getStoredPhiCoef()));
} else {
values.push_back(0.0);
values.push_back(0.0);
}
density_chart_->addPoint(iter, values);
}

if (stepLength_chart_) {
std::vector<double> values;
if (!nbVec_.empty() && nbVec_[0]) {
values.push_back(static_cast<double>(nbVec_[0]->getStoredStepLength()));
values.push_back(
static_cast<double>(nbVec_[0]->getStoredCoordiDistance()));
values.push_back(static_cast<double>(nbVec_[0]->getStoredGradDistance()));
values.push_back(
block->dbuAreaToMicrons(nbVec_[0]->getNesterovInstsArea()));
} else {
values.push_back(0.0);
values.push_back(0.0);
values.push_back(0.0);
values.push_back(0.0);
}
stepLength_chart_->addPoint(iter, values);
}

if (routing_chart_) {
std::vector<double> values;
if (!nbVec_.empty() && nbVec_[0]) {
values.push_back(static_cast<double>(rb_->getRudyAverage()));
values.push_back(
block->dbuAreaToMicrons(nbVec_[0]->getNesterovInstsArea()));
const double total_tiles = static_cast<double>(rb_->getTotalTilesCount());
values.push_back(total_tiles > 0.0 ? (static_cast<double>(
rb_->getOverflowedTilesCount())
/ total_tiles * 100.0)
: 0.0);
values.push_back((rb_->getTotalRudyOverflow()));
} else {
values.push_back(0.0);
values.push_back(0.0);
values.push_back(0.0);
values.push_back(0.0);
values.push_back(0.0);
}
routing_chart_->addPoint(iter, values);
}
std::vector<double> values;
if (!nbVec_.empty() && nbVec_[0]) {
values.push_back((static_cast<double>(nbVec_[0]->getDensityPenalty())));
values.push_back(static_cast<double>(nbVec_[0]->getStoredPhiCoef()));
} else {
values.push_back(0.0);
values.push_back(0.0);
}
density_chart_->addPoint(iter, values);

values.clear();
if (!nbVec_.empty() && nbVec_[0]) {
values.push_back(static_cast<double>(nbVec_[0]->getStoredStepLength()));
values.push_back(static_cast<double>(nbVec_[0]->getStoredCoordiDistance()));
values.push_back(static_cast<double>(nbVec_[0]->getStoredGradDistance()));
values.push_back(
block->dbuAreaToMicrons(nbVec_[0]->getNesterovInstsArea()));
} else {
values.push_back(0.0);
values.push_back(0.0);
values.push_back(0.0);
values.push_back(0.0);
}
stepLength_chart_->addPoint(iter, values);

values.clear();
if (!nbVec_.empty() && nbVec_[0]) {
values.push_back(static_cast<double>(rb_->getRudyAverage()));
values.push_back(
block->dbuAreaToMicrons(nbVec_[0]->getNesterovInstsArea()));
const double total_tiles = static_cast<double>(rb_->getTotalTilesCount());
values.push_back(total_tiles > 0.0
? (static_cast<double>(rb_->getOverflowedTilesCount())
/ total_tiles * 100.0)
: 0.0);
values.push_back((rb_->getTotalRudyOverflow()));
} else {
values.push_back(0.0);
values.push_back(0.0);
values.push_back(0.0);
values.push_back(0.0);
values.push_back(0.0);
}
routing_chart_->addPoint(iter, values);
}

void GraphicsImpl::addTimingDrivenIter(const int iter)
Expand Down
12 changes: 6 additions & 6 deletions src/gpl/src/graphicsImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class GraphicsImpl : public gpl::AbstractGraphics,
void setDebugOn(bool set_on) override { debug_on_ = set_on; }

void setDisplayControl(std::string_view name, bool value) override;

const char* getDisplayControlGroupName() override { return "GPL"; }

int gifStart(std::string_view path) override;
Expand Down Expand Up @@ -177,13 +176,14 @@ class GraphicsImpl : public gpl::AbstractGraphics,
LineSegs mbff_edges_;
std::vector<odb::dbInst*> mbff_cluster_;
Mode mode_;
gui::Chart* main_chart_{nullptr};
gui::Chart* density_chart_{nullptr};
gui::Chart* stepLength_chart_{nullptr};
gui::Chart* routing_chart_{nullptr};
static gui::Chart* main_chart_;
static gui::Chart* density_chart_;
static gui::Chart* stepLength_chart_;
static gui::Chart* routing_chart_;
Comment on lines +179 to +182
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these static now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were generating the main_chart_ twice and populating it only once. I suspect it was because we can build the nesterov object more than once at replace.cpp. This guarantees we don't generate anything twice.

bool debug_on_{false};

void initHeatmap();
void initCharts();
void initDebugHeatmap();
void drawNesterov(gui::Painter& painter);
void drawInitial(gui::Painter& painter);
void drawMBFF(gui::Painter& painter);
Expand Down
9 changes: 3 additions & 6 deletions src/gpl/src/nesterovPlace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,12 @@ void NesterovPlace::updateIterGraphics(
int timing_driven_count,
bool& final_routability_image_saved)
{
if (!graphics_ || !graphics_->enabled()) {
if (!graphics_ || !graphics_->enabled() || !npVars_.debug) {
return;
}

graphics_->addIter(iter, average_overflow_unscaled_);

// For JPEG Saving
updateDb();

Expand All @@ -292,11 +294,6 @@ void NesterovPlace::updateIterGraphics(
rb_->updateRudyAverage(/*verbose=*/false);
}

graphics_->addIter(iter, average_overflow_unscaled_);

if (!npVars_.debug) {
return;
}
int debug_start_iter = npVars_.debug_start_iter;
if (debug_start_iter == 0 || iter + 1 >= debug_start_iter) {
bool update
Expand Down
Loading