Skip to content

Commit c532938

Browse files
committed
gpl: move minRcCellSize_ vector ownership to NBC
Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
1 parent 3fdcf12 commit c532938

5 files changed

Lines changed: 62 additions & 46 deletions

File tree

src/gpl/src/nesterovBase.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3025,7 +3025,7 @@ void NesterovBase::createCbkGCell(odb::dbInst* db_inst, size_t stor_index)
30253025
}
30263026
}
30273027

3028-
size_t NesterovBaseCommon::createCbkGCell(odb::dbInst* db_inst, RouteBase* rb)
3028+
size_t NesterovBaseCommon::createCbkGCell(odb::dbInst* db_inst)
30293029
{
30303030
debugPrint(log_, GPL, "callbacks", 2, "NBC createCbkGCell");
30313031
Instance gpl_inst(db_inst,
@@ -3037,7 +3037,7 @@ size_t NesterovBaseCommon::createCbkGCell(odb::dbInst* db_inst, RouteBase* rb)
30373037
pb_insts_stor_.push_back(gpl_inst);
30383038
GCell gcell(&pb_insts_stor_.back());
30393039
gCellStor_.push_back(gcell);
3040-
rb->pushBackMinRcCellSize(gcell.dx(), gcell.dy());
3040+
minRcCellSize_.emplace_back(gcell.dx(), gcell.dy());
30413041
GCell* gcell_ptr = &gCellStor_.back();
30423042
gCellMap_[gcell_ptr->insts()[0]] = gcell_ptr;
30433043
db_inst_to_nbc_index_map_[db_inst] = gCellStor_.size() - 1;
@@ -3075,7 +3075,7 @@ void NesterovBaseCommon::createCbkITerm(odb::dbITerm* iTerm)
30753075

30763076
// assuming fixpointers will be called later
30773077
// maintaining consistency in NBC::gcellStor_ and NB::gCells_
3078-
void NesterovBase::destroyCbkGCell(odb::dbInst* db_inst, RouteBase* rb)
3078+
void NesterovBase::destroyCbkGCell(odb::dbInst* db_inst)
30793079
{
30803080
debugPrint(log_, GPL, "callbacks", 2, "NesterovBase::destroyGCel");
30813081
auto db_it = db_inst_to_nb_index_map_.find(db_inst);
@@ -3113,7 +3113,7 @@ void NesterovBase::destroyCbkGCell(odb::dbInst* db_inst, RouteBase* rb)
31133113
db_inst_to_nb_index_map_[replacer_inst] = replacer_index;
31143114
}
31153115

3116-
std::pair<odb::dbInst*, size_t> replacer = nbc_->destroyCbkGCell(db_inst, rb);
3116+
std::pair<odb::dbInst*, size_t> replacer = nbc_->destroyCbkGCell(db_inst);
31173117

31183118
if (replacer.first != nullptr) {
31193119
auto it = db_inst_to_nb_index_map_.find(replacer.first);
@@ -3141,7 +3141,7 @@ void NesterovBase::destroyCbkGCell(odb::dbInst* db_inst, RouteBase* rb)
31413141
}
31423142

31433143
std::pair<odb::dbInst*, size_t> NesterovBaseCommon::destroyCbkGCell(
3144-
odb::dbInst* db_inst, RouteBase* rb)
3144+
odb::dbInst* db_inst)
31453145
{
31463146
auto it = db_inst_to_nbc_index_map_.find(db_inst);
31473147
if (it == db_inst_to_nbc_index_map_.end()) {
@@ -3159,7 +3159,7 @@ std::pair<odb::dbInst*, size_t> NesterovBaseCommon::destroyCbkGCell(
31593159

31603160
if (index_remove != last_index) {
31613161
std::swap(gCellStor_[index_remove], gCellStor_[last_index]);
3162-
std::swap(rb->getMinRcCellSize()[index_remove], rb->getMinRcCellSize()[last_index]);
3162+
std::swap(minRcCellSize_[index_remove], minRcCellSize_[last_index]);
31633163

31643164
odb::dbInst* swapped_inst = gCellStor_[index_remove].insts()[0]->dbInst();
31653165
db_inst_to_nbc_index_map_[swapped_inst] = index_remove;
@@ -3171,7 +3171,7 @@ std::pair<odb::dbInst*, size_t> NesterovBaseCommon::destroyCbkGCell(
31713171
delta_area_ -= area_change;
31723172

31733173
gCellStor_.pop_back();
3174-
rb->getMinRcCellSize().pop_back();
3174+
minRcCellSize_.pop_back();
31753175
return replacement;
31763176
}
31773177

src/gpl/src/nesterovBase.h

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -828,16 +828,52 @@ class NesterovBaseCommon
828828
GCell* getGCellByIndex(size_t i);
829829

830830
void setCbk(nesterovDbCbk* cbk) { db_cbk_ = cbk; }
831-
size_t createCbkGCell(odb::dbInst* db_inst, RouteBase* rb);
831+
size_t createCbkGCell(odb::dbInst* db_inst);
832832
void createCbkGNet(odb::dbNet* net, bool skip_io_mode);
833833
void createCbkITerm(odb::dbITerm* iTerm);
834-
std::pair<odb::dbInst*, size_t> destroyCbkGCell(odb::dbInst* db_inst, RouteBase* rb);
834+
std::pair<odb::dbInst*, size_t> destroyCbkGCell(odb::dbInst* db_inst);
835835
void destroyCbkGNet(odb::dbNet*);
836836
void destroyCbkITerm(odb::dbITerm*);
837837
void resizeGCell(odb::dbInst* db_inst);
838838
void moveGCell(odb::dbInst* db_inst);
839839
void fixPointers();
840840

841+
void resetMinRcCellSize()
842+
{
843+
minRcCellSize_.clear();
844+
minRcCellSize_.shrink_to_fit();
845+
}
846+
847+
void resizeMinRcCellSize()
848+
{
849+
minRcCellSize_.resize(nbc_gcells_.size(), std::make_pair(0, 0));
850+
}
851+
void updateMinRcCellSize()
852+
{
853+
for (auto& gCell : nbc_gcells_) {
854+
if (!gCell->isStdInstance()) {
855+
continue;
856+
}
857+
858+
minRcCellSize_[&gCell - nbc_gcells_.data()]
859+
= std::make_pair(gCell->dx(), gCell->dy());
860+
}
861+
}
862+
863+
void revertGCellSizeToMinRc()
864+
{
865+
// revert back the gcell sizes
866+
for (auto& gCell : nbc_gcells_) {
867+
if (!gCell->isStdInstance()) {
868+
continue;
869+
}
870+
871+
int idx = &gCell - nbc_gcells_.data();
872+
873+
gCell->setSize(minRcCellSize_[idx].first, minRcCellSize_[idx].second);
874+
}
875+
}
876+
841877
GCell& getGCell(size_t index) { return gCellStor_[index]; }
842878

843879
size_t getGCellIndex(const GCell* gCell) const
@@ -866,7 +902,8 @@ class NesterovBaseCommon
866902
std::vector<GPin> gPinStor_;
867903

868904
std::vector<GCell*> nbc_gcells_;
869-
905+
// For usage in routability mode, parallel to nbc_gcells_
906+
std::vector<std::pair<int, int>> minRcCellSize_;
870907
std::vector<GNet*> gNets_;
871908
std::vector<GPin*> gPins_;
872909

@@ -1062,7 +1099,7 @@ class NesterovBase
10621099
bool isDiverged() const { return isDiverged_; }
10631100

10641101
void createCbkGCell(odb::dbInst* db_inst, size_t stor_index);
1065-
void destroyCbkGCell(odb::dbInst* db_inst, RouteBase* rb);
1102+
void destroyCbkGCell(odb::dbInst* db_inst);
10661103
void destroyFillerGCell(size_t index_remove);
10671104

10681105
// Resets all pointers to storages of gcells, gpins, and gnets.

src/gpl/src/nesterovPlace.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ nesterovDbCbk::nesterovDbCbk(NesterovPlace* nesterov_place)
775775

776776
void NesterovPlace::createCbkGCell(odb::dbInst* db_inst)
777777
{
778-
auto gcell_index = nbc_->createCbkGCell(db_inst, rb_.get());
778+
auto gcell_index = nbc_->createCbkGCell(db_inst);
779779
for (auto& nesterov : nbVec_) {
780780
// TODO: manage regions, not every NB should create a
781781
// gcell.
@@ -786,7 +786,7 @@ void NesterovPlace::createCbkGCell(odb::dbInst* db_inst)
786786
void NesterovPlace::destroyCbkGCell(odb::dbInst* db_inst)
787787
{
788788
for (auto& nesterov : nbVec_) {
789-
nesterov->destroyCbkGCell(db_inst, rb_.get());
789+
nesterov->destroyCbkGCell(db_inst);
790790
}
791791
}
792792

src/gpl/src/routeBase.cpp

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ void RouteBase::reset()
266266
minRcTargetDensity_ = 0;
267267
minRcViolatedCnt_ = 0;
268268

269-
minRcCellSize_.clear();
270-
minRcCellSize_.shrink_to_fit();
269+
nbc_->resetMinRcCellSize();
271270

272271
resetRoutabilityResources();
273272
}
@@ -289,7 +288,7 @@ void RouteBase::init()
289288
tg_ = std::move(tg);
290289

291290
tg_->setLogger(log_);
292-
minRcCellSize_.resize(nbc_->getGCells().size(), std::make_pair(0, 0));
291+
nbc_->resizeMinRcCellSize();
293292
}
294293

295294
void RouteBase::getRudyResult()
@@ -565,14 +564,8 @@ std::pair<bool, bool> RouteBase::routability()
565564
minRcViolatedCnt_ = 0;
566565

567566
// save cell size info
568-
for (auto& gCell : nbc_->getGCells()) {
569-
if (!gCell->isStdInstance()) {
570-
continue;
571-
}
567+
nbc_->updateMinRcCellSize();
572568

573-
minRcCellSize_[&gCell - nbc_->getGCells().data()]
574-
= std::make_pair(gCell->dx(), gCell->dy());
575-
}
576569
} else {
577570
minRcViolatedCnt_++;
578571
log_->info(GPL,
@@ -717,7 +710,7 @@ std::pair<bool, bool> RouteBase::routability()
717710
minRcTargetDensity_);
718711

719712
nbVec_[0]->setTargetDensity(minRcTargetDensity_);
720-
revertGCellSizeToMinRc();
713+
nbc_->revertGCellSizeToMinRc();
721714
nbVec_[0]->updateDensitySize();
722715
resetRoutabilityResources();
723716

@@ -806,20 +799,6 @@ std::pair<bool, bool> RouteBase::routability()
806799
return std::make_pair(true, true);
807800
}
808801

809-
void RouteBase::revertGCellSizeToMinRc()
810-
{
811-
// revert back the gcell sizes
812-
for (auto& gCell : nbc_->getGCells()) {
813-
if (!gCell->isStdInstance()) {
814-
continue;
815-
}
816-
817-
int idx = &gCell - nbc_->getGCells().data();
818-
819-
gCell->setSize(minRcCellSize_[idx].first, minRcCellSize_[idx].second);
820-
}
821-
}
822-
823802
float RouteBase::getRudyRC() const
824803
{
825804
grt::Rudy* rudy = grouter_->getRudy();

src/gpl/src/routeBase.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,14 @@ class RouteBase
169169
int64_t inflatedAreaDelta() const;
170170
int numCall() const;
171171

172-
void revertGCellSizeToMinRc();
173-
void pushBackMinRcCellSize(int dx, int dy)
174-
{
175-
minRcCellSize_.emplace_back(dx, dy);
176-
}
177-
178-
std::vector<std::pair<int, int> > getMinRcCellSize() { return minRcCellSize_; }
172+
// void revertGCellSizeToMinRc();
173+
// void pushBackMinRcCellSize(int dx, int dy)
174+
// {
175+
// minRcCellSize_.emplace_back(dx, dy);
176+
// }
177+
178+
// std::vector<std::pair<int, int> > getMinRcCellSize() { return
179+
// minRcCellSize_; }
179180

180181
private:
181182
RouteBaseVars rbVars_;
@@ -199,7 +200,6 @@ class RouteBase
199200
float minRc_ = 1e30;
200201
float minRcTargetDensity_ = 0;
201202
int minRcViolatedCnt_ = 0;
202-
std::vector<std::pair<int, int> > minRcCellSize_;
203203

204204
void init();
205205
void reset();

0 commit comments

Comments
 (0)