Skip to content

Commit e09e3e3

Browse files
committed
gpl: move member function definition to cpp file,
include some other missing get prefixes on member functions Signed-off-by: Augusto Berndt <[email protected]>
1 parent 3422a98 commit e09e3e3

File tree

5 files changed

+107
-95
lines changed

5 files changed

+107
-95
lines changed

src/gpl/src/graphics.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -487,13 +487,13 @@ void Graphics::status(const std::string& message)
487487
double Graphics::getGridXSize() const
488488
{
489489
const BinGrid& grid = nbVec_[0]->getBinGrid();
490-
return grid.binSizeX() / (double) getBlock()->getDbUnitsPerMicron();
490+
return grid.getBinSizeX() / (double) getBlock()->getDbUnitsPerMicron();
491491
}
492492

493493
double Graphics::getGridYSize() const
494494
{
495495
const BinGrid& grid = nbVec_[0]->getBinGrid();
496-
return grid.binSizeY() / (double) getBlock()->getDbUnitsPerMicron();
496+
return grid.getBinSizeY() / (double) getBlock()->getDbUnitsPerMicron();
497497
}
498498

499499
odb::Rect Graphics::getBounds() const
@@ -515,10 +515,11 @@ bool Graphics::populateMap()
515515
const float scaledBinArea
516516
= static_cast<float>(binArea * bin.getTargetDensity());
517517

518-
double value = std::max(
519-
0.0f,
520-
static_cast<float>(bin.getInstPlacedAreaUnscaled())
521-
+ static_cast<float>(bin.getNonPlaceAreaUnscaled()) - scaledBinArea);
518+
double value
519+
= std::max(0.0f,
520+
static_cast<float>(bin.getInstPlacedAreaUnscaled())
521+
+ static_cast<float>(bin.getNonPlaceAreaUnscaled())
522+
- scaledBinArea);
522523
value = block->dbuAreaToMicrons(value);
523524

524525
min_value = std::min(min_value, value);
@@ -537,10 +538,11 @@ bool Graphics::populateMap()
537538
const float scaledBinArea
538539
= static_cast<float>(binArea * bin.getTargetDensity());
539540

540-
double raw_value = std::max(
541-
0.0f,
542-
static_cast<float>(bin.getInstPlacedAreaUnscaled())
543-
+ static_cast<float>(bin.getNonPlaceAreaUnscaled()) - scaledBinArea);
541+
double raw_value
542+
= std::max(0.0f,
543+
static_cast<float>(bin.getInstPlacedAreaUnscaled())
544+
+ static_cast<float>(bin.getNonPlaceAreaUnscaled())
545+
- scaledBinArea);
544546
raw_value = block->dbuAreaToMicrons(raw_value);
545547

546548
if (heatmap_type_ == OverflowMinMax && max_value > min_value) {
@@ -560,8 +562,8 @@ void Graphics::populateXYGrid()
560562
{
561563
BinGrid& grid = nbVec_[0]->getBinGrid();
562564
std::vector<Bin>& bin = grid.getBins();
563-
int x_grid = grid.binCntX();
564-
int y_grid = grid.binCntY();
565+
int x_grid = grid.getBinCntX();
566+
int y_grid = grid.getBinCntY();
565567

566568
std::vector<int> x_grid_set, y_grid_set;
567569
x_grid_set.reserve(x_grid + 1);

src/gpl/src/nesterovBase.cpp

Lines changed: 76 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,13 @@ void GCell::print(utl::Logger* logger, bool print_only_name = true) const
283283
}
284284
}
285285

286-
void GCell::writeAttributesToCSV(std::ostream& out) const {
287-
out << "," << insts_.size() << "," << gPins_.size();
288-
out << "," << lx_ << "," << ly_ << "," << ux_ << "," << uy_;
289-
out << "," << dLx_ << "," << dLy_ << "," << dUx_ << "," << dUy_;
290-
out << "," << densityScale_ << "," << gradientX_ << "," << gradientY_;
291-
}
286+
void GCell::writeAttributesToCSV(std::ostream& out) const
287+
{
288+
out << "," << insts_.size() << "," << gPins_.size();
289+
out << "," << lx_ << "," << ly_ << "," << ux_ << "," << uy_;
290+
out << "," << dLx_ << "," << dLy_ << "," << dUx_ << "," << dUy_;
291+
out << "," << densityScale_ << "," << gradientX_ << "," << gradientY_;
292+
}
292293

293294
////////////////////////////////////////////////
294295
// GNet
@@ -659,22 +660,22 @@ int BinGrid::dy() const
659660
{
660661
return (uy_ - ly_);
661662
}
662-
int BinGrid::binCntX() const
663+
int BinGrid::getBinCntX() const
663664
{
664665
return binCntX_;
665666
}
666667

667-
int BinGrid::binCntY() const
668+
int BinGrid::getBinCntY() const
668669
{
669670
return binCntY_;
670671
}
671672

672-
double BinGrid::binSizeX() const
673+
double BinGrid::getBinSizeX() const
673674
{
674675
return binSizeX_;
675676
}
676677

677-
double BinGrid::binSizeY() const
678+
double BinGrid::getBinSizeY() const
678679
{
679680
return binSizeY_;
680681
}
@@ -930,10 +931,11 @@ void BinGrid::updateBinsGCellDensityArea(const std::vector<GCellHandle>& cells)
930931
+ static_cast<float>(bin.getNonPlaceArea()) - scaledBinArea);
931932
sumOverflowArea_ += overflowArea; // NOLINT
932933

933-
const float overflowAreaUnscaled = std::max(
934-
0.0f,
935-
static_cast<float>(bin.getInstPlacedAreaUnscaled())
936-
+ static_cast<float>(bin.getNonPlaceAreaUnscaled()) - scaledBinArea);
934+
const float overflowAreaUnscaled
935+
= std::max(0.0f,
936+
static_cast<float>(bin.getInstPlacedAreaUnscaled())
937+
+ static_cast<float>(bin.getNonPlaceAreaUnscaled())
938+
- scaledBinArea);
937939
sumOverflowAreaUnscaled_ += overflowAreaUnscaled;
938940
if (overflowAreaUnscaled > 0) {
939941
debugPrint(log_,
@@ -1736,8 +1738,10 @@ NesterovBase::NesterovBase(NesterovBaseVars nbVars,
17361738
bg_.initBins();
17371739

17381740
// initialize fft structrue based on bins
1739-
std::unique_ptr<FFT> fft(
1740-
new FFT(bg_.binCntX(), bg_.binCntY(), bg_.binSizeX(), bg_.binSizeY()));
1741+
std::unique_ptr<FFT> fft(new FFT(bg_.getBinCntX(),
1742+
bg_.getBinCntY(),
1743+
bg_.getBinSizeX(),
1744+
bg_.getBinSizeY()));
17411745

17421746
fft_ = std::move(fft);
17431747

@@ -1987,22 +1991,22 @@ void NesterovBase::setTargetDensity(float density)
19871991

19881992
int NesterovBase::getBinCntX() const
19891993
{
1990-
return bg_.binCntX();
1994+
return bg_.getBinCntX();
19911995
}
19921996

19931997
int NesterovBase::getBinCntY() const
19941998
{
1995-
return bg_.binCntY();
1999+
return bg_.getBinCntY();
19962000
}
19972001

1998-
double NesterovBase::binSizeX() const
2002+
double NesterovBase::getBinSizeX() const
19992003
{
2000-
return bg_.binSizeX();
2004+
return bg_.getBinSizeX();
20012005
}
20022006

2003-
double NesterovBase::binSizeY() const
2007+
double NesterovBase::getBinSizeY() const
20042008
{
2005-
return bg_.binSizeY();
2009+
return bg_.getBinSizeY();
20062010
}
20072011

20082012
int64_t NesterovBase::getOverflowArea() const
@@ -2035,18 +2039,18 @@ int64_t NesterovBase::getFillerCellArea() const
20352039
return static_cast<int64_t>(fillerDx_) * static_cast<int64_t>(fillerDy_);
20362040
}
20372041

2038-
GCell& NesterovBase::getFillerGCell(size_t index)
2039-
{
2040-
if (index >= fillerStor_.size()) {
2041-
log_->error(
2042-
utl::GPL,
2043-
314,
2044-
"getFillerGCell: index {} out of bounds (fillerStor_.size() = {}).",
2045-
index,
2046-
fillerStor_.size());
2047-
}
2048-
return fillerStor_[index];
2042+
GCell& NesterovBase::getFillerGCell(size_t index)
2043+
{
2044+
if (index >= fillerStor_.size()) {
2045+
log_->error(
2046+
utl::GPL,
2047+
314,
2048+
"getFillerGCell: index {} out of bounds (fillerStor_.size() = {}).",
2049+
index,
2050+
fillerStor_.size());
20492051
}
2052+
return fillerStor_[index];
2053+
}
20502054

20512055
int64_t NesterovBase::getWhiteSpaceArea() const
20522056
{
@@ -2075,7 +2079,7 @@ float NesterovBase::getSumPhi() const
20752079
return sumPhi_;
20762080
}
20772081

2078-
float NesterovBase::uniformTargetDensity() const
2082+
float NesterovBase::getUniformTargetDensity() const
20792083
{
20802084
return uniformTargetDensity_;
20812085
}
@@ -2099,19 +2103,19 @@ void NesterovBase::updateDensitySize()
20992103
auto& gCell = *it; // old-style loop for old OpenMP
21002104
float scaleX = 0, scaleY = 0;
21012105
float densitySizeX = 0, densitySizeY = 0;
2102-
if (gCell->dx() < REPLACE_SQRT2 * bg_.binSizeX()) {
2106+
if (gCell->dx() < REPLACE_SQRT2 * bg_.getBinSizeX()) {
21032107
scaleX = static_cast<float>(gCell->dx())
2104-
/ static_cast<float>(REPLACE_SQRT2 * bg_.binSizeX());
2105-
densitySizeX = REPLACE_SQRT2 * static_cast<float>(bg_.binSizeX());
2108+
/ static_cast<float>(REPLACE_SQRT2 * bg_.getBinSizeX());
2109+
densitySizeX = REPLACE_SQRT2 * static_cast<float>(bg_.getBinSizeX());
21062110
} else {
21072111
scaleX = 1.0;
21082112
densitySizeX = gCell->dx();
21092113
}
21102114

2111-
if (gCell->dy() < REPLACE_SQRT2 * bg_.binSizeY()) {
2115+
if (gCell->dy() < REPLACE_SQRT2 * bg_.getBinSizeY()) {
21122116
scaleY = static_cast<float>(gCell->dy())
2113-
/ static_cast<float>(REPLACE_SQRT2 * bg_.binSizeY());
2114-
densitySizeY = REPLACE_SQRT2 * static_cast<float>(bg_.binSizeY());
2117+
/ static_cast<float>(REPLACE_SQRT2 * bg_.getBinSizeY());
2118+
densitySizeY = REPLACE_SQRT2 * static_cast<float>(bg_.getBinSizeY());
21152119
} else {
21162120
scaleY = 1.0;
21172121
densitySizeY = gCell->dy();
@@ -2310,8 +2314,9 @@ void NesterovBase::initDensity1()
23102314
// FFT update
23112315
updateDensityForceBin();
23122316

2313-
baseWireLengthCoef_ = npVars_->initWireLengthCoef
2314-
/ (static_cast<float>(binSizeX() + binSizeY()) * 0.5);
2317+
baseWireLengthCoef_
2318+
= npVars_->initWireLengthCoef
2319+
/ (static_cast<float>(getBinSizeX() + getBinSizeY()) * 0.5);
23152320

23162321
sumOverflow_ = static_cast<float>(getOverflowArea())
23172322
/ static_cast<float>(getNesterovInstsArea());
@@ -2871,11 +2876,11 @@ bool NesterovBase::checkConvergence()
28712876

28722877
if (static_cast<double>(getNesterovInstsArea()) / (whiteSpaceArea_ * 0.50)
28732878
<= 1.0) {
2874-
log_->info(
2875-
GPL,
2876-
1009,
2877-
" - For 50% usage of free space: {:.4f}",
2878-
static_cast<double>(getNesterovInstsArea()) / (whiteSpaceArea_ * 0.50));
2879+
log_->info(GPL,
2880+
1009,
2881+
" - For 50% usage of free space: {:.4f}",
2882+
static_cast<double>(getNesterovInstsArea())
2883+
/ (whiteSpaceArea_ * 0.50));
28792884
}
28802885

28812886
if (uniformTargetDensity_ > 0.95f) {
@@ -3010,19 +3015,19 @@ void NesterovBase::updateGCellState(float wlCoeffX, float wlCoeffY)
30103015
// analogous to NesterovBase::updateDensitySize()
30113016
float scaleX = 0, scaleY = 0;
30123017
float densitySizeX = 0, densitySizeY = 0;
3013-
if (gcell->dx() < REPLACE_SQRT2 * bg_.binSizeX()) {
3018+
if (gcell->dx() < REPLACE_SQRT2 * bg_.getBinSizeX()) {
30143019
scaleX = static_cast<float>(gcell->dx())
3015-
/ static_cast<float>(REPLACE_SQRT2 * bg_.binSizeX());
3016-
densitySizeX = REPLACE_SQRT2 * static_cast<float>(bg_.binSizeX());
3020+
/ static_cast<float>(REPLACE_SQRT2 * bg_.getBinSizeX());
3021+
densitySizeX = REPLACE_SQRT2 * static_cast<float>(bg_.getBinSizeX());
30173022
} else {
30183023
scaleX = 1.0;
30193024
densitySizeX = gcell->dx();
30203025
}
30213026

3022-
if (gcell->dy() < REPLACE_SQRT2 * bg_.binSizeY()) {
3027+
if (gcell->dy() < REPLACE_SQRT2 * bg_.getBinSizeY()) {
30233028
scaleY = static_cast<float>(gcell->dy())
3024-
/ static_cast<float>(REPLACE_SQRT2 * bg_.binSizeY());
3025-
densitySizeY = REPLACE_SQRT2 * static_cast<float>(bg_.binSizeY());
3029+
/ static_cast<float>(REPLACE_SQRT2 * bg_.getBinSizeY());
3030+
densitySizeY = REPLACE_SQRT2 * static_cast<float>(bg_.getBinSizeY());
30263031
} else {
30273032
scaleY = 1.0;
30283033
densitySizeY = gcell->dy();
@@ -3548,7 +3553,8 @@ void NesterovBaseCommon::destroyCbkGNet(odb::dbNet* db_net)
35483553
std::swap(gNetStor_[index_remove], gNetStor_[last_index]);
35493554

35503555
// Update index map for the swapped net
3551-
odb::dbNet* swapped_net = gNetStor_[index_remove].getPbNets()[0]->getDbNet();
3556+
odb::dbNet* swapped_net
3557+
= gNetStor_[index_remove].getPbNets()[0]->getDbNet();
35523558
db_net_to_index_map_[swapped_net] = index_remove;
35533559
}
35543560

@@ -3573,7 +3579,8 @@ void NesterovBaseCommon::destroyCbkITerm(odb::dbITerm* db_iterm)
35733579
}
35743580
if (index_remove != last_index) {
35753581
std::swap(gPinStor_[index_remove], gPinStor_[last_index]);
3576-
odb::dbITerm* swapped_iterm = gPinStor_[index_remove].getPbPin()->getDbITerm();
3582+
odb::dbITerm* swapped_iterm
3583+
= gPinStor_[index_remove].getPbPin()->getDbITerm();
35773584
db_iterm_to_index_map_[swapped_iterm] = index_remove;
35783585
}
35793586
gPinStor_.pop_back();
@@ -3689,6 +3696,20 @@ void NesterovBaseCommon::printGPins()
36893696
}
36903697
}
36913698

3699+
void NesterovBase::appendGCellCSVNote(const std::string& filename,
3700+
int iteration,
3701+
const std::string& message) const
3702+
{
3703+
std::ofstream file(filename, std::ios::app);
3704+
if (!file.is_open()) {
3705+
log_->report("Could not open CSV file for appending message: {}", filename);
3706+
return;
3707+
}
3708+
3709+
file << "# NOTE @ iteration " << iteration << ": " << message << "\n";
3710+
file.close();
3711+
}
3712+
36923713
void NesterovBase::writeGCellVectorsToCSV(const std::string& filename,
36933714
int iteration,
36943715
bool write_header) const

src/gpl/src/nesterovBase.h

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -685,10 +685,10 @@ class BinGrid
685685
int dx() const;
686686
int dy() const;
687687

688-
int binCntX() const;
689-
int binCntY() const;
690-
double binSizeX() const;
691-
double binSizeY() const;
688+
int getBinCntX() const;
689+
int getBinCntY() const;
690+
double getBinSizeX() const;
691+
double getBinSizeY() const;
692692

693693
int64_t getOverflowArea() const;
694694
int64_t getOverflowAreaUnscaled() const;
@@ -950,8 +950,8 @@ class NesterovBase
950950

951951
int getBinCntX() const;
952952
int getBinCntY() const;
953-
double binSizeX() const;
954-
double binSizeY() const;
953+
double getBinSizeX() const;
954+
double getBinSizeY() const;
955955
int64_t getOverflowArea() const;
956956
int64_t getOverflowAreaUnscaled() const;
957957

@@ -990,7 +990,7 @@ class NesterovBase
990990
// return uniform (lower bound) target density
991991
// LB of target density is required for massive runs.
992992
//
993-
float uniformTargetDensity() const;
993+
float getUniformTargetDensity() const;
994994

995995
// initTargetDensity is set by users
996996
// targetDensity is equal to initTargetDensity and
@@ -1066,7 +1066,7 @@ class NesterovBase
10661066

10671067
void updateNextIter(int iter);
10681068
void setTrueReprintIterHeader() { reprint_iter_header_ = true; }
1069-
float getPhiCoef(float scaledDiffHpwl) const;
1069+
float getPhiCoef(float scaledDiffHpwl) const;
10701070

10711071
bool checkConvergence();
10721072
bool checkDivergence();
@@ -1101,19 +1101,7 @@ class NesterovBase
11011101

11021102
void appendGCellCSVNote(const std::string& filename,
11031103
int iteration,
1104-
const std::string& message) const
1105-
{
1106-
std::ofstream file(filename, std::ios::app);
1107-
if (!file.is_open()) {
1108-
log_->report("Could not open CSV file for appending message: {}",
1109-
filename);
1110-
return;
1111-
}
1112-
1113-
file << "# NOTE @ iteration " << iteration << ": " << message << "\n";
1114-
file.close();
1115-
}
1116-
1104+
const std::string& message) const;
11171105
void writeGCellVectorsToCSV(const std::string& filename,
11181106
int iteration,
11191107
bool write_header) const;

src/gpl/src/replace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ float Replace::getUniformTargetDensity(int threads)
439439

440440
float density = 1.0f;
441441
if (initNesterovPlace(threads)) {
442-
density = nbVec_[0]->uniformTargetDensity();
442+
density = nbVec_[0]->getUniformTargetDensity();
443443
}
444444

445445
std::string _ = log_->redirectStringEnd();

0 commit comments

Comments
 (0)