Skip to content

Commit 9f8394a

Browse files
committed
gpl: instance colors based on type of rsz change,
red for new instances, orange for upsize blue for downsize, also include a chart for steplength related values Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
1 parent 5114b0e commit 9f8394a

5 files changed

Lines changed: 132 additions & 52 deletions

File tree

src/gpl/src/graphicsImpl.cpp

Lines changed: 97 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,17 @@ void GraphicsImpl::debugForNesterovPlace(
7777

7878
if (enabled()) {
7979
// Setup the chart
80-
chart_ = gui::Gui::get()->addChart(
81-
"GPL", "Iteration", {"HPWL (μm)", "Overflow"});
82-
chart_->setXAxisFormat("%d");
83-
chart_->setYAxisFormats({"%.2e", "%.2f"});
84-
chart_->setYAxisMin({std::nullopt, 0});
80+
gui::Gui* gui = gui::Gui::get();
81+
main_chart_ = gui->addChart("GPL", "Iteration", {"HPWL (μm)", "Overflow"});
82+
main_chart_->setXAxisFormat("%d");
83+
main_chart_->setYAxisFormats({"%.2e", "%.2f"});
84+
main_chart_->setYAxisMin({std::nullopt, 0});
8585

8686
// Useful for debugging multiple NesterovBase: Density penalty and PhiCoef
8787
if (logger_->debugCheck(utl::GPL, "penaltyPlot", 1)) {
8888
if (!nbVec_.empty()) {
89-
std::vector<std::string> series_names;
90-
series_names.reserve(nbVec_.size());
89+
std::vector<std::string> region_names;
90+
region_names.reserve(nbVec_.size());
9191
for (size_t i = 0; i < nbVec_.size(); ++i) {
9292
std::string name;
9393
if (nbVec_[i] && nbVec_[i]->getPb() && nbVec_[i]->getPb()->group()) {
@@ -96,24 +96,38 @@ void GraphicsImpl::debugForNesterovPlace(
9696
} else {
9797
name = fmt::format("nb[{}]", i);
9898
}
99-
series_names.push_back(name);
99+
region_names.push_back(name);
100100
}
101-
density_chart_ = gui::Gui::get()->addChart(
102-
"GPL Density Penalty", "Iteration", series_names);
101+
density_chart_ = gui->addChart(
102+
"GPL Density Penalty", "Iteration", {"DensityPenalty", "phiCoef"});
103103
density_chart_->setXAxisFormat("%d");
104-
std::vector<std::string> y_formats(nbVec_.size(), "%.3f");
105-
density_chart_->setYAxisFormats(y_formats);
106-
std::vector<std::optional<double>> y_mins(nbVec_.size(), 0.0);
107-
density_chart_->setYAxisMin(y_mins);
108-
109-
phi_chart_ = gui::Gui::get()->addChart(
110-
"GPL PhiCoef", "Iteration", series_names);
111-
phi_chart_->setXAxisFormat("%d");
112-
phi_chart_->setYAxisFormats(y_formats);
113-
phi_chart_->setYAxisMin(y_mins);
104+
density_chart_->setYAxisFormats({"%.2e", "%.2f"});
105+
density_chart_->setYAxisMin({0.0, nbc_->getNbVars().minPhiCoef});
106+
107+
stepLength_chart_ = gui->addChart(
108+
"GPL StepLength",
109+
"Iteration",
110+
{"StepLength", "CoordiDistance", "GradDistance", "Std area"});
111+
stepLength_chart_->setXAxisFormat("%d");
112+
stepLength_chart_->setYAxisFormats({"%.2e", "%.2f", "%.2f"});
113+
stepLength_chart_->setYAxisMin({0.0, 0.0, 0.0});
114+
115+
// Version with regions
116+
// density_chart_
117+
// = gui->addChart("GPL Density Penalty", "Iteration",
118+
// series_names);
119+
// density_chart_->setXAxisFormat("%d");
120+
// std::vector<std::string> y_formats(nbVec_.size(), "%.3f");
121+
// density_chart_->setYAxisFormats(y_formats);
122+
// std::vector<std::optional<double>> y_mins(nbVec_.size(), 0.0);
123+
// density_chart_->setYAxisMin(y_mins);
124+
125+
// phi_chart_ = gui->addChart("GPL PhiCoef", "Iteration", series_names);
126+
// phi_chart_->setXAxisFormat("%d");
127+
// phi_chart_->setYAxisFormats(y_formats);
128+
// phi_chart_->setYAxisMin(y_mins);
114129
}
115130
}
116-
117131
initHeatmap();
118132
if (inst) {
119133
for (size_t idx = 0; idx < nbc_->getGCells().size(); ++idx) {
@@ -284,10 +298,19 @@ void GraphicsImpl::drawSingleGCell(const GCell* gCell,
284298
// Highlight modified instances (overrides base color, unless selected)
285299
switch (gCell->changeType()) {
286300
case GCell::GCellChange::kRoutability:
287-
color = {255, 255, 255, 100}; // White
301+
color = gui::Painter::kWhite;
302+
break;
303+
case GCell::GCellChange::kNewInstance:
304+
color = gui::Painter::kDarkRed;
305+
break;
306+
case GCell::GCellChange::kDownsize:
307+
color = gui::Painter::kDarkBlue;
288308
break;
289-
case GCell::GCellChange::kTimingDriven:
290-
color = {180, 150, 255, 100}; // Light purple
309+
case GCell::GCellChange::kUpsize:
310+
color = gui::Painter::kOrange;
311+
break;
312+
case GCell::GCellChange::kResizeNoChange:
313+
color = gui::Painter::kDarkYellow;
291314
break;
292315
default:
293316
if (gCell->isInstance()) {
@@ -537,48 +560,80 @@ void GraphicsImpl::reportSelected()
537560
void GraphicsImpl::addIter(const int iter, const double overflow)
538561
{
539562
odb::dbBlock* block = pbc_->db()->getChip()->getBlock();
540-
chart_->addPoint(iter, {block->dbuToMicrons(nbc_->getHpwl()), overflow});
563+
main_chart_->addPoint(iter, {block->dbuToMicrons(nbc_->getHpwl()), overflow});
541564

542565
// Add density penalties snapshot for each NesterovBase
543566
if (logger_->debugCheck(utl::GPL, "penaltyPlot", 1)) {
544567
if (density_chart_) {
545-
std::vector<double> penalties;
546-
penalties.reserve(nbVec_.size());
547-
for (const auto& nb : nbVec_) {
548-
double penalty
549-
= nb ? static_cast<double>(nb->getDensityPenalty()) : 0.0;
550-
penalties.push_back(penalty);
568+
std::vector<double> values;
569+
if (!nbVec_.empty() && nbVec_[0]) {
570+
// values.push_back(std::log(static_cast<double>(nbVec_[0]->getDensityPenalty())));
571+
values.push_back((static_cast<double>(nbVec_[0]->getDensityPenalty())));
572+
values.push_back(static_cast<double>(nbVec_[0]->getStoredPhiCoef()));
573+
} else {
574+
values.push_back(0.0);
575+
values.push_back(0.0);
551576
}
552-
density_chart_->addPoint(iter, penalties);
577+
density_chart_->addPoint(iter, values);
553578
}
554579

555-
if (phi_chart_) {
556-
std::vector<double> coefs;
557-
coefs.reserve(nbVec_.size());
558-
for (const auto& nb : nbVec_) {
559-
double coef = nb ? static_cast<double>(nb->getStoredPhiCoef()) : 0.0;
560-
coefs.push_back(coef);
580+
// Version with regions
581+
// if (density_chart_) {
582+
// std::vector<double> penalties;
583+
// penalties.reserve(nbVec_.size());
584+
// for (const auto& nb : nbVec_) {
585+
// double penalty
586+
// = nb ? static_cast<double>(nb->getDensityPenalty()) : 0.0;
587+
// penalties.push_back(penalty);
588+
// }
589+
// density_chart_->addPoint(iter, penalties);
590+
// }
591+
// if (phi_chart_) {
592+
// std::vector<double> coefs;
593+
// coefs.reserve(nbVec_.size());
594+
// for (const auto& nb : nbVec_) {
595+
// double coef = nb ? static_cast<double>(nb->getStoredPhiCoef()) : 0.0;
596+
// coefs.push_back(coef);
597+
// }
598+
// phi_chart_->addPoint(iter, coefs);
599+
// }
600+
601+
if (stepLength_chart_) {
602+
std::vector<double> values;
603+
if (!nbVec_.empty() && nbVec_[0]) {
604+
values.push_back(static_cast<double>(nbVec_[0]->getStoredStepLength()));
605+
values.push_back(
606+
static_cast<double>(nbVec_[0]->getStoredCoordiDistance()));
607+
values.push_back(
608+
static_cast<double>(nbVec_[0]->getStoredGradDistance()));
609+
values.push_back(
610+
static_cast<double>(nbVec_[0]->getNesterovInstsArea()));
611+
} else {
612+
values.push_back(0.0);
613+
values.push_back(0.0);
614+
values.push_back(0.0);
615+
values.push_back(0.0);
561616
}
562-
phi_chart_->addPoint(iter, coefs);
617+
stepLength_chart_->addPoint(iter, values);
563618
}
564619
}
565620
}
566621

567622
void GraphicsImpl::addTimingDrivenIter(const int iter)
568623
{
569-
chart_->addVerticalMarker(iter, gui::Painter::kTurquoise);
624+
main_chart_->addVerticalMarker(iter, gui::Painter::kTurquoise);
570625
}
571626

572627
void GraphicsImpl::addRoutabilitySnapshot(int iter)
573628
{
574-
chart_->addVerticalMarker(iter, gui::Painter::kYellow);
629+
main_chart_->addVerticalMarker(iter, gui::Painter::kYellow);
575630
}
576631

577632
void GraphicsImpl::addRoutabilityIter(const int iter, const bool revert)
578633
{
579634
gui::Painter::Color color
580635
= revert ? gui::Painter::kRed : gui::Painter::kGreen;
581-
chart_->addVerticalMarker(iter, color);
636+
main_chart_->addVerticalMarker(iter, color);
582637
}
583638

584639
void GraphicsImpl::cellPlotImpl(bool pause)

src/gpl/src/graphicsImpl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,10 @@ class GraphicsImpl : public gpl::AbstractGraphics,
167167
LineSegs mbff_edges_;
168168
std::vector<odb::dbInst*> mbff_cluster_;
169169
Mode mode_;
170-
gui::Chart* chart_{nullptr};
170+
gui::Chart* main_chart_{nullptr};
171171
gui::Chart* density_chart_{nullptr};
172172
gui::Chart* phi_chart_{nullptr};
173+
gui::Chart* stepLength_chart_{nullptr};
173174
bool debug_on_ = false;
174175

175176
void initHeatmap();

src/gpl/src/nesterovBase.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,19 +2390,18 @@ float NesterovBase::getStepLength(
23902390
const std::vector<FloatPoint>& curSLPCoordi_,
23912391
const std::vector<FloatPoint>& curSLPSumGrads_)
23922392
{
2393-
float coordiDistance = getDistance(prevSLPCoordi_, curSLPCoordi_);
2394-
float gradDistance = getDistance(prevSLPSumGrads_, curSLPSumGrads_);
2395-
2393+
coordiDistance_ = getDistance(prevSLPCoordi_, curSLPCoordi_);
2394+
gradDistance_ = getDistance(prevSLPSumGrads_, curSLPSumGrads_);
23962395
debugPrint(log_,
23972396
GPL,
23982397
"getStepLength",
23992398
1,
2400-
"CoordinateDistance: {:g}",
2401-
coordiDistance);
2402-
debugPrint(
2403-
log_, GPL, "getStepLength", 1, "GradientDistance: {:g}", gradDistance);
2399+
"CoordinateDis {:g}, GradientDist {:g}, StepLength: {:g}",
2400+
coordiDistance_,
2401+
gradDistance_,
2402+
stepLength_);
24042403

2405-
return coordiDistance / gradDistance;
2404+
return coordiDistance_ / gradDistance_;
24062405
}
24072406

24082407
// to execute following function,
@@ -3071,6 +3070,13 @@ void NesterovBaseCommon::resizeGCell(odb::dbInst* db_inst)
30713070
= static_cast<int64_t>(gcell->dx()) * static_cast<int64_t>(gcell->dy());
30723071
int64_t area_change = newCellArea - prevCellArea;
30733072
delta_area_ += area_change;
3073+
if (area_change > 0) {
3074+
gcell->setAreaChangeType(GCell::GCellChange::kUpsize);
3075+
} else if (area_change < 0) {
3076+
gcell->setAreaChangeType(GCell::GCellChange::kDownsize);
3077+
} else {
3078+
gcell->setAreaChangeType(GCell::GCellChange::kResizeNoChange);
3079+
}
30743080
}
30753081

30763082
void NesterovBase::updateGCellState(float wlCoeffX, float wlCoeffY)
@@ -3203,6 +3209,7 @@ size_t NesterovBaseCommon::createCbkGCell(odb::dbInst* db_inst)
32033209
* static_cast<int64_t>(gcell_ptr->dy());
32043210
delta_area_ += area_change;
32053211
new_gcells_count_++;
3212+
gcell_ptr->setAreaChangeType(GCell::GCellChange::kNewInstance);
32063213
return gCellStor_.size() - 1;
32073214
}
32083215

src/gpl/src/nesterovBase.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ class GCell
5656
kNone,
5757
kRoutability,
5858
kTimingDriven,
59+
kNewInstance,
60+
kDownsize,
61+
kUpsize,
62+
kResizeNoChange
5963
};
6064

6165
// instance cells
@@ -874,6 +878,8 @@ class NesterovBaseCommon
874878
int64_t getNewGcellsCount() { return new_gcells_count_; }
875879
void resetNewGcellsCount() { new_gcells_count_ = 0; }
876880

881+
NesterovBaseVars& getNbVars() { return nbVars_; }
882+
877883
private:
878884
NesterovBaseVars nbVars_;
879885
std::shared_ptr<PlacerBaseCommon> pbc_;
@@ -1060,6 +1066,9 @@ class NesterovBase
10601066
void setTrueReprintIterHeader() { reprint_iter_header_ = true; }
10611067
float getPhiCoef(float scaledDiffHpwl) const;
10621068
float getStoredPhiCoef() const { return phiCoef_; }
1069+
float getStoredStepLength() const { return stepLength_; }
1070+
float getStoredCoordiDistance() const { return coordiDistance_; }
1071+
float getStoredGradDistance() const { return gradDistance_; }
10631072

10641073
bool checkConvergence(int gpl_iter_count,
10651074
int routability_gpl_iter_count,
@@ -1169,6 +1178,13 @@ class NesterovBase
11691178
float targetDensity_ = 0;
11701179
float uniformTargetDensity_ = 0;
11711180

1181+
// StepLength parameters (also included in the np debugPrint)
1182+
float stepLength_ = 0;
1183+
float coordiDistance_ = 0;
1184+
float gradDistance_ = 0;
1185+
// numBackTrack (nesterovPlace.cpp)
1186+
// newWireLengthCoef (nesterovPlace.cpp)
1187+
11721188
// Nesterov loop data for each region, using parallel vectors
11731189
// SLP is Step Length Prediction.
11741190
//
@@ -1215,7 +1231,7 @@ class NesterovBase
12151231
float densityGradSum_ = 0;
12161232

12171233
// alpha
1218-
float stepLength_ = 0;
1234+
// float stepLength_ = 0;
12191235

12201236
// opt_phi_cof
12211237
float densityPenalty_ = 0;

src/gpl/src/nesterovPlace.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class NesterovPlace
5959

6060
float getWireLengthCoefX() const { return wireLengthCoefX_; }
6161
float getWireLengthCoefY() const { return wireLengthCoefY_; }
62+
NesterovPlaceVars& getNpVars() { return npVars_; }
6263

6364
void setTargetOverflow(float overflow) { npVars_.targetOverflow = overflow; }
6465
void setMaxIters(int limit) { npVars_.maxNesterovIter = limit; }

0 commit comments

Comments
 (0)