Skip to content

Commit

Permalink
(1)support ispd18/19 (2)fix bugs (3)improve runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
liulixinkerry committed Dec 27, 2023
1 parent eaad483 commit ba01cd3
Show file tree
Hide file tree
Showing 40 changed files with 1,164 additions and 220 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,14 @@ python main.py --dataset ispd2015_fix --design_name mgc_fft_1 --load_from_raw Tr
python main.py --dataset ispd2015_fix --run_all True --load_from_raw True --detail_placement True
```

- To run Routability GP + DP flow for ISPD2015 dataset:
- To run Routability GP + DP flow for ISPD2015/2018/2019 dataset:
```bash
# run all the designs in ispd2015 with routability optimization
# run all the designs with routability optimization
python main.py --dataset ispd2015_fix --run_all True --load_from_raw True --detail_placement True --use_cell_inflate True

python main.py --dataset ispd2018 --run_all True --load_from_raw True --detail_placement True --use_cell_inflate True

python main.py --dataset ispd2019_no_fence --run_all True --load_from_raw True --detail_placement True --use_cell_inflate True
```

**NOTE**: We default enable the deterministic mode. If you don't need determinism and want to run placement in an extremely fast mode, please try to set `--deterministic False` in the Python arguments.
Expand Down
48 changes: 3 additions & 45 deletions cpp_to_py/common/db/Cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,8 @@ void Cell::ctype(CellType* t) {

int Cell::lx() const { return _lx; }
int Cell::ly() const { return _ly; }
bool Cell::flipX() const { return _flipX; }
bool Cell::flipY() const { return _flipY; }
int Cell::orient() const {
if (!flipX() && !flipY()) {
return 0; // N
} else if (flipX() && flipY()) {
return 2; // S
} else if (flipX() && !flipY()) {
return 4; // FN
} else if (!flipX() && flipY()) {
return 6; // FS
}
return 0;
return _orient;
}

bool Cell::placed() const { return (lx() != INT_MIN) && (ly() != INT_MIN); }
Expand All @@ -70,46 +59,15 @@ void Cell::place(int x, int y, int orient) {
}
_lx = x;
_ly = y;
switch (orient) {
case 0:
_flipX = false;
_flipY = false;
break;
case 2:
_flipX = true;
_flipY = true;
break;
case 4:
_flipX = true;
_flipY = false;
break;
case 6:
_flipX = false;
_flipY = true;
break;
default:
_flipX = false;
_flipY = false;
break;
}
}

void Cell::place(int x, int y, bool flipX, bool flipY) {
if (_fixed) {
logger.warning("moving fixed cell %s to (%d,%d)", _name.c_str(), x, y);
}
_lx = x;
_ly = y;
_flipX = flipX;
_flipY = flipY;
_orient = orient;
}

void Cell::unplace() {
if (_fixed) {
logger.warning("unplace fixed cell %s", _name.c_str());
}
_lx = _ly = INT_MIN;
_flipX = _flipY = false;
_orient = -1;
}

/***** Cell Type *****/
Expand Down
16 changes: 6 additions & 10 deletions cpp_to_py/common/db/Cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ class CellType {
char _topPower = 'x';
vector<Geometry> _obs;

// _nonRegularRects.size() > 0 implies that this cell is a fixed cell and
// its shape is a polygon. Each rectangle is also appended into
// _nonRegularRects.size() > 0 implies that this cell is a fixed cell and
// its shape is a polygon. Each rectangle is also appended into
// Databased.placeBlockages during parsing the polygon-shape cell.
// NOTE: We only support this feature for ICCAD/DAC 2012 benchmarks.
// When processing GPDatabase, we will set this kind of cells' width and
// When processing GPDatabase, we will set this kind of cells' width and
// height as 0 and use placeement blockages to represent their shapes.
vector<Rectangle> _nonRegularRects;
vector<Rectangle> _nonRegularRects;

int _libcell = -1;

public:
std::string name = "";
char cls = 'x';
std::string cls = "x";
bool stdcell = false;
int width = 0;
int height = 0;
Expand Down Expand Up @@ -84,8 +84,7 @@ class Cell {

int _lx = INT_MIN;
int _ly = INT_MIN;
bool _flipX = false;
bool _flipY = false;
int _orient = -1; // 0:N, 1:W, 2:S, 3:E, 4:FN, 5:FW, 6:FS, 7:FE, -1:NONE

public:
bool highlighted = false;
Expand All @@ -107,8 +106,6 @@ class Cell {
int hy() const { return ly() + height(); }
int cx() const { return lx() + width() / 2; }
int cy() const { return ly() + height() / 2; }
bool flipX() const;
bool flipY() const;
int orient() const;
int width() const { return _type->width + _spaceL + _spaceR; }
int height() const { return _type->height + _spaceB + _spaceT; }
Expand All @@ -119,7 +116,6 @@ class Cell {
bool placed() const;
void place(int x, int y);
void place(int x, int y, int orient);
void place(int x, int y, bool flipX, bool flipY);
void unplace();
unsigned numPins() const { return _pins.size(); }

Expand Down
6 changes: 5 additions & 1 deletion cpp_to_py/common/db/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,11 @@ void Database::SetupRows() {
// verify row flipping conflict
bool flipCheckPass = true;
std::vector<char> flip(nSitesY, 0);
std::vector<int> orients(nSitesY, -1);
for (Row* row : rows) {
char isFlip = (row->flip() ? 1 : 2);
int y = (row->y() - coreLY) / siteH;
orients[y] = row->orient(); // TODO: how to handle multiple ROW definitions on same y?
if (flip[y] == 0) {
flip[y] = isFlip;
} else if (flip[y] != isFlip) {
Expand Down Expand Up @@ -525,6 +527,7 @@ void Database::SetupRows() {
rows[y]->xNum(nSitesX);
rows[y]->yNum(1);
rows[y]->flip(flip[y] == 1);
rows[y]->orient(orients[y]);
}

// set row power-rail
Expand Down Expand Up @@ -722,10 +725,11 @@ Row* Database::addRow(const string& name,
const int y,
const unsigned xNum,
const unsigned yNum,
const int orient,
const bool flip,
const unsigned xStep,
const unsigned yStep) {
Row* newrow = new Row(name, macro, x, y, xNum, yNum, flip, xStep, yStep);
Row* newrow = new Row(name, macro, x, y, xNum, yNum, orient, flip, xStep, yStep);
rows.push_back(newrow);
return newrow;
}
Expand Down
1 change: 1 addition & 0 deletions cpp_to_py/common/db/Database.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class Database {
const int y,
const unsigned xNum = 0,
const unsigned yNum = 0,
const int orient = 0,
const bool flip = false,
const unsigned xStep = 0,
const unsigned yStep = 0);
Expand Down
2 changes: 1 addition & 1 deletion cpp_to_py/common/db/Pin.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class IOPin {
string name = "";
int x = INT_MIN;
int y = INT_MIN;
int _orient = 0; // 0:N, 1:W, 2:S, 3:E, 4:FN, 5:FW, 6:FS, 7:FE
int _orient = -1; // 0:N, 1:W, 2:S, 3:E, 4:FN, 5:FW, 6:FS, 7:FE, -1:NONE
PinType* type;
Pin* pin;
int gpdb_id = -1;
Expand Down
6 changes: 5 additions & 1 deletion cpp_to_py/common/db/Row.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Row {
int _y = 0;
unsigned _xNum = 0;
unsigned _yNum = 0;
int _orient = 0; // 0:N, 1:W, 2:S, 3:E, 4:FN, 5:FW, 6:FS, 7:FE, -1:NONE
bool _flip = false;
unsigned _xStep = 0;
unsigned _yStep = 0;
Expand All @@ -20,13 +21,14 @@ class Row {
public:
std::vector<RowSegment> segments;

Row(const string& name, const string& macro, const int x, const int y, const unsigned xNum = 0, const unsigned yNum = 0, const bool flip = false, const unsigned xStep = 0, const unsigned yStep = 0)
Row(const string& name, const string& macro, const int x, const int y, const unsigned xNum = 0, const unsigned yNum = 0, const int orient = 0, const bool flip = false, const unsigned xStep = 0, const unsigned yStep = 0)
: _name(name)
, _macro(macro)
, _x(x)
, _y(y)
, _xNum(xNum)
, _yNum(yNum)
, _orient(orient)
, _flip(flip)
, _xStep(xStep)
, _yStep(yStep) {}
Expand All @@ -46,6 +48,7 @@ class Row {
int y() const { return _y; }
unsigned xNum() const { return _xNum; }
unsigned yNum() const { return _yNum; }
int orient() const { return _orient; }
bool flip() const { return _flip; }
unsigned xStep() const { return _xStep; }
unsigned yStep() const { return _yStep; }
Expand All @@ -56,6 +59,7 @@ class Row {
void y(const int value) { _y = value; }
void xNum(const unsigned value) { _xNum = value; }
void yNum(const unsigned value) { _yNum = value; }
void orient(const int value) { _orient = value; }
void flip(const bool value) { _flip = value; }
void xStep(const unsigned value) { _xStep = value; }
void yStep(const unsigned value) { _yStep = value; }
Expand Down
4 changes: 3 additions & 1 deletion cpp_to_py/common/io/file_bkshf_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
row->xNum(bsData.rowSites[i]);
row->yNum(1);
row->flip((i % 2) == 1);
row->orient((i % 2) * 6); // 0:N or 6:FS
this->dieLX = std::min(this->dieLX, row->x());
this->dieLY = std::min(this->dieLY, row->y());
this->dieHX = std::max(this->dieHX, row->x() + (int)row->width());
Expand Down Expand Up @@ -575,7 +576,8 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
} else {
string celltypename(bsData.typeName[typeID]);
Cell* cell = this->addCell(bsData.cellName[i], this->getCellType(celltypename));
cell->place(bsData.cellX[i], bsData.cellY[i], false, false);
// In Bookshelf, we don't need to consider the cell orient, set it as -1
cell->place(bsData.cellX[i], bsData.cellY[i], -1);
// cout<<cell->x<<","<<cell->y<<endl;
cell->fixed((bsData.cellFixed[i] == (char)1));
}
Expand Down
Loading

0 comments on commit ba01cd3

Please sign in to comment.