hide init() and reset() + some implementation

This commit is contained in:
mgwoo
2020-01-20 17:17:38 -08:00
parent a63244910a
commit 656bd66b8f
8 changed files with 44 additions and 22 deletions

View File

@@ -10,9 +10,11 @@ namespace sta {
namespace replace {
class PlacerBase;
class NesterovBase;
class InitialPlace;
class NesterovPlace;
class PlacerBase;
class Replace
{
@@ -54,9 +56,11 @@ class Replace
odb::dbDatabase* db_;
sta::dbSta* sta_;
PlacerBase* pb_;
NesterovBase* nb_;
InitialPlace* ip_;
NesterovPlace* np_;
PlacerBase* pb_;
int initialPlaceMaxIter_;
int initialPlaceMinDiffLength_;

View File

@@ -27,7 +27,6 @@ class InitialPlace {
InitialPlace(PlacerBase* placerBase);
~InitialPlace();
void reset();
void setInitialPlaceVars(InitialPlaceVars initialPlaceVars);
void doBicgstabPlace();
@@ -60,6 +59,7 @@ class InitialPlace {
void updatePinInfo();
void createSparseMatrix();
void updateCoordi();
void reset();
};
}

View File

@@ -213,9 +213,6 @@ class NesterovBase {
NesterovBase();
NesterovBase(PlacerBase* pb);
~NesterovBase();
void init();
void reset();
const std::vector<GCell*> & gCells() const { return gCellsPtr_; }
const std::vector<GCell*> & gCellInsts() const { return gCellInsts_; }
@@ -227,6 +224,7 @@ class NesterovBase {
private:
PlacerBase* pb_;
std::vector<GCell> gCells_;
std::vector<GNet> gNets_;
std::vector<GPin> gPins_;
@@ -238,6 +236,8 @@ class NesterovBase {
std::vector<GNet*> gNetsPtr_;
std::vector<GPin*> gPinsPtr_;
void init();
void reset();
};
}

View File

@@ -2,12 +2,13 @@
namespace replace {
NesterovPlace::NesterovPlace() : pb_(nullptr) {}
NesterovPlace::NesterovPlace(PlacerBase* placerBase)
: pb_(placerBase) {}
NesterovPlace::NesterovPlace() : pb_(nullptr), nb_(nullptr) {}
NesterovPlace::NesterovPlace(PlacerBase* placerBase, NesterovBase* nesterovBase)
: pb_(placerBase), nb_(nesterovBase) {}
NesterovPlace::~NesterovPlace() {
pb_ = nullptr;
nb_ = nullptr;
}
void

View File

@@ -6,18 +6,22 @@ namespace replace
class PlacerBase;
class Instance;
class NesterovBase;
class NesterovPlace {
public:
NesterovPlace();
NesterovPlace(PlacerBase* placerBase);
NesterovPlace(PlacerBase* placerBase, NesterovBase* nesterovBase);
~NesterovPlace();
void init();
void doNesterovPlace();
private:
PlacerBase* pb_;
NesterovBase* nb_;
void init();
void reset();
};
}

View File

@@ -12,7 +12,7 @@ static odb::adsRect
getCoreRectFromDb(dbSet<odb::dbRow> &rows);
static int
fastModule(const int input, const int ceil);
fastModulo(const int input, const int ceil);
static std::pair<int, int>
getMinMaxIdx(int ll, int uu, int coreLL,
@@ -100,6 +100,11 @@ Instance::setLocation(int x, int y) {
lx_ = x;
ly_ = y;
// pins update
for(auto& pin : pins_) {
pin->updateLocation(this);
}
}
void
@@ -110,6 +115,11 @@ Instance::setCenterLocation(int x, int y) {
ly_ = y - halfY;
ux_ = x + halfX;
uy_ = y + halfY;
// pins update
for(auto& pin : pins_) {
pin->updateLocation(this);
}
}
void
@@ -827,7 +837,7 @@ std::pair<int, int>
BinGrid::getMinMaxIdxX(GCell* gcell) {
int lowerIdx = (gcell->lx() - lx())/binSizeX_;
int upperIdx =
( fastModule((gcell->ux() - lx()), binSizeX_) == 0)?
( fastModulo((gcell->ux() - lx()), binSizeX_) == 0)?
(gcell->ux() - lx()) / binSizeX_ : (gcell->ux()-lx())/binSizeX_ + 1;
return std::make_pair(lowerIdx, upperIdx);
}
@@ -836,7 +846,7 @@ std::pair<int, int>
BinGrid::getMinMaxIdxY(GCell* gcell) {
int lowerIdx = (gcell->ly() - ly())/binSizeY_;
int upperIdx =
( fastModule((gcell->uy() - ly()), binSizeY_) == 0)?
( fastModulo((gcell->uy() - ly()), binSizeY_) == 0)?
(gcell->uy() - ly()) / binSizeY_ : (gcell->uy()-ly())/binSizeY_ + 1;
return std::make_pair(lowerIdx, upperIdx);
}
@@ -1189,7 +1199,7 @@ getCoreRectFromDb(dbSet<odb::dbRow> &rows) {
// https://stackoverflow.com/questions/33333363/built-in-mod-vs-custom-mod-function-improve-the-performance-of-modulus-op
static int
fastModule(const int input, const int ceil) {
fastModulo(const int input, const int ceil) {
return input >= ceil? input % ceil : input;
}
@@ -1197,7 +1207,7 @@ static std::pair<int, int>
getMinMaxIdx(int ll, int uu, int coreLL, int siteSize) {
int lowerIdx = (ll - coreLL)/siteSize;
int upperIdx =
( fastModule((uu - coreLL), siteSize) == 0)?
( fastModulo((uu - coreLL), siteSize) == 0)?
(uu - coreLL) / siteSize : (uu - coreLL)/siteSize + 1;
return std::make_pair(lowerIdx, upperIdx);
}

View File

@@ -325,9 +325,6 @@ public:
PlacerBase(odb::dbDatabase* db);
~PlacerBase();
void init();
void reset();
const std::vector<Instance*>& insts() const { return insts_; }
const std::vector<Pin*>& pins() const { return pins_; }
const std::vector<Net*>& nets() const { return nets_; }
@@ -386,8 +383,11 @@ private:
uint64_t placeInstsArea_;
uint64_t nonPlaceInstsArea_;
void init();
void initBinGrid();
void initInstsForFragmentedRow();
void reset();
};
}

View File

@@ -2,6 +2,7 @@
#include "initialPlace.h"
#include "nesterovPlace.h"
#include "placerBase.h"
#include "nesterovBase.h"
#include <iostream>
namespace replace {
@@ -10,8 +11,9 @@ using namespace std;
Replace::Replace()
: db_(nullptr),
sta_(nullptr), ip_(nullptr),
np_(nullptr), pb_(nullptr),
sta_(nullptr),
pb_(nullptr), nb_(nullptr),
ip_(nullptr), np_(nullptr),
initialPlaceMaxIter_(20),
initialPlaceMinDiffLength_(1500),
initialPlaceMaxSolverIter_(100),
@@ -32,7 +34,8 @@ Replace::~Replace() {
void Replace::init() {
pb_ = new PlacerBase(db_);
ip_ = new InitialPlace(pb_);
np_ = new NesterovPlace(pb_);
nb_ = new NesterovBase(pb_);
np_ = new NesterovPlace(pb_, nb_);
}
void Replace::reset() {