Refine cpp code to avoid always including torch and pybind
This commit is contained in:
parent
8e7c817f46
commit
7e6a0b0ba7
@ -30,19 +30,8 @@
|
|||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
// Torch library
|
|
||||||
#include <torch/extension.h>
|
|
||||||
|
|
||||||
// utils
|
// utils
|
||||||
#include "common/utils/utils.h"
|
#include "common/utils/utils.h"
|
||||||
|
|
||||||
// Pybind11
|
|
||||||
#include <pybind11/pybind11.h>
|
|
||||||
#include <pybind11/stl.h>
|
|
||||||
#include <pybind11/stl_bind.h>
|
|
||||||
#include <pybind11/numpy.h>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
using utils::assert_msg;
|
using utils::assert_msg;
|
||||||
using utils::logger;
|
using utils::logger;
|
||||||
@ -119,7 +119,7 @@ public:
|
|||||||
void unplace();
|
void unplace();
|
||||||
unsigned numPins() const { return _pins.size(); }
|
unsigned numPins() const { return _pins.size(); }
|
||||||
|
|
||||||
friend ostream& operator<<(ostream& os, const Cell& c) {
|
friend std::ostream& operator<<(std::ostream& os, const Cell& c) {
|
||||||
return os << c._name << "\t(" << c.lx() << ", " << c.ly() << ')';
|
return os << c._name << "\t(" << c.lx() << ", " << c.ly() << ')';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -526,7 +526,7 @@ void Database::SetupRows() {
|
|||||||
// NOTE: currently we only support horizontal row
|
// NOTE: currently we only support horizontal row
|
||||||
|
|
||||||
for (unsigned y = 0; y != nSitesY; ++y) {
|
for (unsigned y = 0; y != nSitesY; ++y) {
|
||||||
rows[y] = new Row("core_SITE_ROW_" + to_string(y), "core", coreLX, coreLY + y * siteH);
|
rows[y] = new Row("core_SITE_ROW_" + std::to_string(y), "core", coreLX, coreLY + y * siteH);
|
||||||
rows[y]->xStep(stepX);
|
rows[y]->xStep(stepX);
|
||||||
rows[y]->yStep(0);
|
rows[y]->yStep(0);
|
||||||
rows[y]->xNum(nSitesX);
|
rows[y]->xNum(nSitesX);
|
||||||
@ -814,10 +814,10 @@ long long Database::getHPWL() {
|
|||||||
Pin* pin = nets[i]->pins[j];
|
Pin* pin = nets[i]->pins[j];
|
||||||
int x, y;
|
int x, y;
|
||||||
pin->getPinCenter(x, y);
|
pin->getPinCenter(x, y);
|
||||||
lx = min(lx, x);
|
lx = std::min(lx, x);
|
||||||
ly = min(ly, y);
|
ly = std::min(ly, y);
|
||||||
hx = max(hx, x);
|
hx = std::max(hx, x);
|
||||||
hy = max(hy, y);
|
hy = std::max(hy, y);
|
||||||
}
|
}
|
||||||
hpwl += (hx - lx) + (hy - ly);
|
hpwl += (hx - lx) + (hy - ly);
|
||||||
}
|
}
|
||||||
@ -896,7 +896,7 @@ Region* Database::getRegion(const unsigned char id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NDR* Database::getNDR(const string& name) const {
|
NDR* Database::getNDR(const string& name) const {
|
||||||
map<string, NDR*>::const_iterator mi = ndrs.find(name);
|
std::map<string, NDR*>::const_iterator mi = ndrs.find(name);
|
||||||
if (mi == ndrs.end()) {
|
if (mi == ndrs.end()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/common.h"
|
|
||||||
#include "Setting.h"
|
#include "Setting.h"
|
||||||
|
#include "common/common.h"
|
||||||
|
|
||||||
namespace db {
|
namespace db {
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
class Rectangle;
|
class Rectangle;
|
||||||
class Geometry;
|
class Geometry;
|
||||||
class GeoMap;
|
class GeoMap;
|
||||||
@ -31,20 +35,20 @@ class GCellGrid;
|
|||||||
class BsRouteInfo;
|
class BsRouteInfo;
|
||||||
} // namespace db
|
} // namespace db
|
||||||
|
|
||||||
|
#include "BsRouteInfo.h"
|
||||||
#include "Cell.h"
|
#include "Cell.h"
|
||||||
#include "DesignRule.h"
|
#include "DesignRule.h"
|
||||||
|
#include "GCellGrid.h"
|
||||||
#include "Geometry.h"
|
#include "Geometry.h"
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include "SiteMap.h"
|
|
||||||
#include "Net.h"
|
#include "Net.h"
|
||||||
#include "Pin.h"
|
#include "Pin.h"
|
||||||
#include "Region.h"
|
#include "Region.h"
|
||||||
#include "GCellGrid.h"
|
|
||||||
#include "Row.h"
|
#include "Row.h"
|
||||||
#include "Site.h"
|
|
||||||
#include "SNet.h"
|
#include "SNet.h"
|
||||||
|
#include "Site.h"
|
||||||
|
#include "SiteMap.h"
|
||||||
#include "Via.h"
|
#include "Via.h"
|
||||||
#include "BsRouteInfo.h"
|
|
||||||
|
|
||||||
namespace db {
|
namespace db {
|
||||||
|
|
||||||
@ -91,7 +95,7 @@ public:
|
|||||||
vector<Net*> nets;
|
vector<Net*> nets;
|
||||||
vector<Row*> rows;
|
vector<Row*> rows;
|
||||||
vector<Region*> regions;
|
vector<Region*> regions;
|
||||||
map<string, NDR*> ndrs;
|
std::map<string, NDR*> ndrs;
|
||||||
vector<SNet*> snets;
|
vector<SNet*> snets;
|
||||||
vector<Track*> tracks;
|
vector<Track*> tracks;
|
||||||
|
|
||||||
@ -220,9 +224,9 @@ public:
|
|||||||
bool writeDEF(const std::string& file);
|
bool writeDEF(const std::string& file);
|
||||||
bool writeICCAD2017(const string& inputDef, const string& outputDef);
|
bool writeICCAD2017(const string& inputDef, const string& outputDef);
|
||||||
bool writeICCAD2017(const string& outputDef);
|
bool writeICCAD2017(const string& outputDef);
|
||||||
bool writeComponents(ofstream& ofs);
|
bool writeComponents(std::ofstream& ofs);
|
||||||
bool writeBuffer(ofstream& ofs, const string& line);
|
bool writeBuffer(std::ofstream& ofs, const string& line);
|
||||||
void writeBufferFlush(ofstream& ofs);
|
void writeBufferFlush(std::ofstream& ofs);
|
||||||
|
|
||||||
bool readBSAux(const std::string& auxFile, const std::string& plFile);
|
bool readBSAux(const std::string& auxFile, const std::string& plFile);
|
||||||
bool readBSNodes(const std::string& file);
|
bool readBSNodes(const std::string& file);
|
||||||
|
|||||||
@ -4,10 +4,10 @@ using namespace db;
|
|||||||
/***** Rectangle *****/
|
/***** Rectangle *****/
|
||||||
|
|
||||||
Rectangle& Rectangle::operator+=(const Rectangle& geo) {
|
Rectangle& Rectangle::operator+=(const Rectangle& geo) {
|
||||||
lx = min(lx, geo.lx);
|
lx = std::min(lx, geo.lx);
|
||||||
ly = min(ly, geo.ly);
|
ly = std::min(ly, geo.ly);
|
||||||
hx = max(hx, geo.hx);
|
hx = std::max(hx, geo.hx);
|
||||||
hy = max(hy, geo.hy);
|
hy = std::max(hy, geo.hy);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,8 +45,8 @@ void Rectangle::sliceH(vector<Rectangle>& rects) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (L.hx >= R.lx) {
|
if (L.hx >= R.lx) {
|
||||||
R.lx = min(L.lx, R.lx);
|
R.lx = std::min(L.lx, R.lx);
|
||||||
R.hx = max(L.hx, R.hx);
|
R.hx = std::max(L.hx, R.hx);
|
||||||
L.hx = L.lx;
|
L.hx = L.lx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,8 +92,8 @@ void Rectangle::sliceV(vector<Rectangle>& rects) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (L.hy >= R.ly) {
|
if (L.hy >= R.ly) {
|
||||||
R.ly = min(L.ly, R.ly);
|
R.ly = std::min(L.ly, R.ly);
|
||||||
R.hy = max(L.hy, R.hy);
|
R.hy = std::max(L.hy, R.hy);
|
||||||
L.hy = L.ly;
|
L.hy = L.ly;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,7 @@ public:
|
|||||||
static void sliceH(vector<Rectangle>& rects);
|
static void sliceH(vector<Rectangle>& rects);
|
||||||
static void sliceV(vector<Rectangle>& rects);
|
static void sliceV(vector<Rectangle>& rects);
|
||||||
|
|
||||||
friend ostream& operator<<(ostream& os, const Rectangle& r) {
|
friend std::ostream& operator<<(std::ostream& os, const Rectangle& r) {
|
||||||
return os << '(' << r.lx << ", " << r.ly << ")\t(" << r.hx << ", " << r.hy << ')';
|
return os << '(' << r.lx << ", " << r.ly << ")\t(" << r.hx << ", " << r.hy << ')';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -52,7 +52,7 @@ public:
|
|||||||
|
|
||||||
class GeoMap : public Rectangle {
|
class GeoMap : public Rectangle {
|
||||||
private:
|
private:
|
||||||
map<int, Geometry> _map;
|
std::map<int, Geometry> _map;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool empty() const noexcept { return _map.empty(); }
|
bool empty() const noexcept { return _map.empty(); }
|
||||||
@ -60,9 +60,9 @@ public:
|
|||||||
const Geometry& front() const { return _map.begin()->second; }
|
const Geometry& front() const { return _map.begin()->second; }
|
||||||
const Geometry& front2() const { return (++_map.begin())->second; }
|
const Geometry& front2() const { return (++_map.begin())->second; }
|
||||||
const Geometry& back() const { return _map.rbegin()->second; }
|
const Geometry& back() const { return _map.rbegin()->second; }
|
||||||
map<int, Geometry>::const_iterator begin() const noexcept { return _map.begin(); }
|
std::map<int, Geometry>::const_iterator begin() const noexcept { return _map.begin(); }
|
||||||
map<int, Geometry>::const_iterator end() const noexcept { return _map.end(); }
|
std::map<int, Geometry>::const_iterator end() const noexcept { return _map.end(); }
|
||||||
map<int, Geometry>::const_iterator find(const int k) const { return _map.find(k); }
|
std::map<int, Geometry>::const_iterator find(const int k) const { return _map.find(k); }
|
||||||
|
|
||||||
const Geometry& at(const int k) const { return _map.at(k); }
|
const Geometry& at(const int k) const { return _map.at(k); }
|
||||||
|
|
||||||
|
|||||||
@ -109,7 +109,7 @@ void Net::addPin(Pin* pin) {
|
|||||||
/***** PowerNet *****/
|
/***** PowerNet *****/
|
||||||
|
|
||||||
void PowerNet::addRail(SNet* snet, int lx, int hx, int y) {
|
void PowerNet::addRail(SNet* snet, int lx, int hx, int y) {
|
||||||
map<int, SNet*>::iterator rail = rails.find(y);
|
std::map<int, SNet*>::iterator rail = rails.find(y);
|
||||||
if (rail != rails.end() && rail->second != snet) {
|
if (rail != rails.end() && rail->second != snet) {
|
||||||
logger.error("rail %s already exists at y=%d , new rail %s is from %d to %d", rail->second->name.c_str(),
|
logger.error("rail %s already exists at y=%d , new rail %s is from %d to %d", rail->second->name.c_str(),
|
||||||
y, snet->name.c_str(),
|
y, snet->name.c_str(),
|
||||||
@ -125,13 +125,13 @@ bool PowerNet::getRowPower(int ly, int hy, char& topPower, char& botPower) {
|
|||||||
bool valid = true;
|
bool valid = true;
|
||||||
topPower = 'x';
|
topPower = 'x';
|
||||||
botPower = 'x';
|
botPower = 'x';
|
||||||
map<int, SNet*>::iterator topRail = rails.find(hy);
|
std::map<int, SNet*>::iterator topRail = rails.find(hy);
|
||||||
if (topRail != rails.end()) {
|
if (topRail != rails.end()) {
|
||||||
topPower = topRail->second->type;
|
topPower = topRail->second->type;
|
||||||
} else {
|
} else {
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
map<int, SNet*>::iterator botRail = rails.find(ly);
|
std::map<int, SNet*>::iterator botRail = rails.find(ly);
|
||||||
if (botRail != rails.end()) {
|
if (botRail != rails.end()) {
|
||||||
botPower = botRail->second->type;
|
botPower = botRail->second->type;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -26,7 +26,7 @@ public:
|
|||||||
unsigned toNode;
|
unsigned toNode;
|
||||||
// path = [<direction,len>]
|
// path = [<direction,len>]
|
||||||
// direction : N,S,E,W,U,D
|
// direction : N,S,E,W,U,D
|
||||||
vector<pair<char, int>> path;
|
vector<std::pair<char, int>> path;
|
||||||
|
|
||||||
NetRouteSegment(const unsigned fromi = 0, const unsigned toi = 0, const char dir = '\0', const unsigned len = 0);
|
NetRouteSegment(const unsigned fromi = 0, const unsigned toi = 0, const char dir = '\0', const unsigned len = 0);
|
||||||
|
|
||||||
|
|||||||
@ -104,10 +104,10 @@ utils::PointT<int> Pin::getPinParentCenter() const {
|
|||||||
/***** Pin Type *****/
|
/***** Pin Type *****/
|
||||||
|
|
||||||
void PinType::addShape(const Layer& layer, const int lx, const int ly, const int hx, const int hy) {
|
void PinType::addShape(const Layer& layer, const int lx, const int ly, const int hx, const int hy) {
|
||||||
boundLX = min(boundLX, lx);
|
boundLX = std::min(boundLX, lx);
|
||||||
boundLY = min(boundLY, ly);
|
boundLY = std::min(boundLY, ly);
|
||||||
boundHX = max(boundHX, hx);
|
boundHX = std::max(boundHX, hx);
|
||||||
boundHY = max(boundHY, hy);
|
boundHY = std::max(boundHY, hy);
|
||||||
shapes.emplace_back(layer, lx, ly, hx, hy);
|
shapes.emplace_back(layer, lx, ly, hx, hy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,8 +5,8 @@ using namespace db;
|
|||||||
|
|
||||||
void Region::addRect(const int xl, const int yl, const int xh, const int yh) {
|
void Region::addRect(const int xl, const int yl, const int xh, const int yh) {
|
||||||
rects.emplace_back(xl, yl, xh, yh);
|
rects.emplace_back(xl, yl, xh, yh);
|
||||||
lx = min(lx, xl);
|
lx = std::min(lx, xl);
|
||||||
ly = min(ly, yl);
|
ly = std::min(ly, yl);
|
||||||
hx = max(hx, xh);
|
hx = std::max(hx, xh);
|
||||||
hy = max(hy, yh);
|
hy = std::max(hy, yh);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
string name = "";
|
string name = "";
|
||||||
set<Geometry> rects;
|
std::set<Geometry> rects;
|
||||||
ViaRule rule;
|
ViaRule rule;
|
||||||
|
|
||||||
ViaType(const string& name = "", const bool isDef = false) : isDef_(isDef), name(name) {}
|
ViaType(const string& name = "", const bool isDef = false) : isDef_(isDef), name(name) {}
|
||||||
|
|||||||
@ -54,7 +54,7 @@ public:
|
|||||||
int tileH;
|
int tileH;
|
||||||
double blockagePorosity;
|
double blockagePorosity;
|
||||||
vector<int> IOPinRouteLayer;
|
vector<int> IOPinRouteLayer;
|
||||||
vector<pair<int, vector<int>>> routeBlkgs; // cellID, BlockedLayers
|
vector<std::pair<int, vector<int>>> routeBlkgs; // cellID, BlockedLayers
|
||||||
|
|
||||||
BookshelfData() {
|
BookshelfData() {
|
||||||
nCells = 0;
|
nCells = 0;
|
||||||
@ -163,8 +163,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void estimateSiteSize() {
|
void estimateSiteSize() {
|
||||||
set<int> sizeSet;
|
std::set<int> sizeSet;
|
||||||
set<int> heightSet;
|
std::set<int> heightSet;
|
||||||
|
|
||||||
for (int i = 0; i < nCells; i++) {
|
for (int i = 0; i < nCells; i++) {
|
||||||
if (!typeStdCell[i]) {
|
if (!typeStdCell[i]) {
|
||||||
@ -186,8 +186,8 @@ public:
|
|||||||
|
|
||||||
vector<int> sizes;
|
vector<int> sizes;
|
||||||
vector<int> heights;
|
vector<int> heights;
|
||||||
set<int>::iterator ii = sizeSet.begin();
|
std::set<int>::iterator ii = sizeSet.begin();
|
||||||
set<int>::iterator ie = sizeSet.end();
|
std::set<int>::iterator ie = sizeSet.end();
|
||||||
for (; ii != ie; ++ii) {
|
for (; ii != ie; ++ii) {
|
||||||
sizes.push_back(*ii);
|
sizes.push_back(*ii);
|
||||||
}
|
}
|
||||||
@ -273,7 +273,7 @@ bool isBookshelfSymbol(unsigned char c) {
|
|||||||
return symbols[(int)c] != 0;
|
return symbols[(int)c] != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool readBSLine(istream& is, vector<string>& tokens) {
|
bool readBSLine(std::istream& is, vector<string>& tokens) {
|
||||||
tokens.clear();
|
tokens.clear();
|
||||||
string line;
|
string line;
|
||||||
while (is && tokens.empty()) {
|
while (is && tokens.empty()) {
|
||||||
@ -332,7 +332,7 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
|
|||||||
}
|
}
|
||||||
logger.info("dir = %s", directory.c_str());
|
logger.info("dir = %s", directory.c_str());
|
||||||
|
|
||||||
ifstream fs(auxFile.c_str());
|
std::ifstream fs(auxFile.c_str());
|
||||||
if (!fs.good()) {
|
if (!fs.good()) {
|
||||||
logger.error("cannot open file: %s", auxFile.c_str());
|
logger.error("cannot open file: %s", auxFile.c_str());
|
||||||
return false;
|
return false;
|
||||||
@ -440,7 +440,7 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
|
|||||||
this->dieHY = INT_MIN;
|
this->dieHY = INT_MIN;
|
||||||
unsigned int minRowXStep = INT_MAX;
|
unsigned int minRowXStep = INT_MAX;
|
||||||
for (int i = 0; i < bsData.nRows; i++) {
|
for (int i = 0; i < bsData.nRows; i++) {
|
||||||
Row* row = this->addRow("core_SITE_ROW_" + to_string(i), "core", bsData.rowX[i], bsData.rowY[i]);
|
Row* row = this->addRow("core_SITE_ROW_" + std::to_string(i), "core", bsData.rowX[i], bsData.rowY[i]);
|
||||||
row->xStep(bsData.rowXStep[i]);
|
row->xStep(bsData.rowXStep[i]);
|
||||||
row->yStep(bsData.rowHeight[i]);
|
row->yStep(bsData.rowHeight[i]);
|
||||||
row->xNum(bsData.rowSites[i]);
|
row->xNum(bsData.rowSites[i]);
|
||||||
@ -523,7 +523,7 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
|
|||||||
m2direction = (this->bsRouteInfo.capV[1] > 0) ? 'v' : 'h';
|
m2direction = (this->bsRouteInfo.capV[1] > 0) ? 'v' : 'h';
|
||||||
}
|
}
|
||||||
for (unsigned i = 0; i != nLayers; ++i) {
|
for (unsigned i = 0; i != nLayers; ++i) {
|
||||||
Layer& layer = this->addLayer(string("M").append(to_string(i + 1)), 'r');
|
Layer& layer = this->addLayer(string("M").append(std::to_string(i + 1)), 'r');
|
||||||
// if (!i) {
|
// if (!i) {
|
||||||
// layer.direction = 'x';
|
// layer.direction = 'x';
|
||||||
// layer.track.direction = 'x';
|
// layer.track.direction = 'x';
|
||||||
@ -558,7 +558,7 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
|
|||||||
if (i + 1 == nLayers) {
|
if (i + 1 == nLayers) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
this->addLayer(string("N").append(to_string(i + 1)), 'c');
|
this->addLayer(string("N").append(std::to_string(i + 1)), 'c');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -690,7 +690,7 @@ bool Database::readBSAux(const std::string& auxFile, const std::string& plFile)
|
|||||||
}
|
}
|
||||||
bool Database::readBSNodes(const std::string& file) {
|
bool Database::readBSNodes(const std::string& file) {
|
||||||
logger.info("reading nodes");
|
logger.info("reading nodes");
|
||||||
ifstream fs(file.c_str());
|
std::ifstream fs(file.c_str());
|
||||||
if (!fs.good()) {
|
if (!fs.good()) {
|
||||||
logger.error("cannot open file: %s", file.c_str());
|
logger.error("cannot open file: %s", file.c_str());
|
||||||
return false;
|
return false;
|
||||||
@ -768,7 +768,7 @@ bool Database::readBSNodes(const std::string& file) {
|
|||||||
|
|
||||||
bool Database::readBSNets(const std::string& file) {
|
bool Database::readBSNets(const std::string& file) {
|
||||||
logger.info("reading net");
|
logger.info("reading net");
|
||||||
ifstream fs(file.c_str());
|
std::ifstream fs(file.c_str());
|
||||||
if (!fs.good()) {
|
if (!fs.good()) {
|
||||||
logger.error("cannot open file: %s", file.c_str());
|
logger.error("cannot open file: %s", file.c_str());
|
||||||
return false;
|
return false;
|
||||||
@ -821,7 +821,7 @@ bool Database::readBSNets(const std::string& file) {
|
|||||||
|
|
||||||
string tpName;
|
string tpName;
|
||||||
if (pinName == "" && typeID >= 0) {
|
if (pinName == "" && typeID >= 0) {
|
||||||
stringstream ss;
|
std::stringstream ss;
|
||||||
ss << bsData.typeNPins[typeID];
|
ss << bsData.typeNPins[typeID];
|
||||||
pinName = ss.str();
|
pinName = ss.str();
|
||||||
// logger.info("pinname = %s", pinName.c_str());
|
// logger.info("pinname = %s", pinName.c_str());
|
||||||
@ -865,7 +865,7 @@ bool Database::readBSNets(const std::string& file) {
|
|||||||
|
|
||||||
bool Database::readBSScl(const std::string& file) {
|
bool Database::readBSScl(const std::string& file) {
|
||||||
logger.info("reading scl");
|
logger.info("reading scl");
|
||||||
ifstream fs(file.c_str());
|
std::ifstream fs(file.c_str());
|
||||||
if (!fs.good()) {
|
if (!fs.good()) {
|
||||||
logger.error("cannot open file: %s", file.c_str());
|
logger.error("cannot open file: %s", file.c_str());
|
||||||
return false;
|
return false;
|
||||||
@ -909,7 +909,7 @@ bool Database::readBSScl(const std::string& file) {
|
|||||||
|
|
||||||
bool Database::readBSRoute(const std::string& file) {
|
bool Database::readBSRoute(const std::string& file) {
|
||||||
logger.info("reading route");
|
logger.info("reading route");
|
||||||
ifstream fs(file.c_str());
|
std::ifstream fs(file.c_str());
|
||||||
if (!fs.good()) {
|
if (!fs.good()) {
|
||||||
logger.error("cannot open file: %s", file.c_str());
|
logger.error("cannot open file: %s", file.c_str());
|
||||||
return false;
|
return false;
|
||||||
@ -1004,7 +1004,7 @@ bool Database::readBSRoute(const std::string& file) {
|
|||||||
|
|
||||||
bool Database::readBSShapes(const std::string& file) {
|
bool Database::readBSShapes(const std::string& file) {
|
||||||
logger.info("reading shapes");
|
logger.info("reading shapes");
|
||||||
ifstream fs(file.c_str());
|
std::ifstream fs(file.c_str());
|
||||||
if (!fs.good()) {
|
if (!fs.good()) {
|
||||||
logger.error("cannot open file: %s", file.c_str());
|
logger.error("cannot open file: %s", file.c_str());
|
||||||
return false;
|
return false;
|
||||||
@ -1039,7 +1039,7 @@ bool Database::readBSShapes(const std::string& file) {
|
|||||||
|
|
||||||
bool Database::readBSWts(const std::string& file) {
|
bool Database::readBSWts(const std::string& file) {
|
||||||
logger.info("reading weights");
|
logger.info("reading weights");
|
||||||
ifstream fs(file.c_str());
|
std::ifstream fs(file.c_str());
|
||||||
if (!fs.good()) {
|
if (!fs.good()) {
|
||||||
logger.error("cannot open file: %s", file.c_str());
|
logger.error("cannot open file: %s", file.c_str());
|
||||||
return false;
|
return false;
|
||||||
@ -1051,7 +1051,7 @@ bool Database::readBSWts(const std::string& file) {
|
|||||||
|
|
||||||
bool Database::readBSPl(const std::string& file) {
|
bool Database::readBSPl(const std::string& file) {
|
||||||
logger.info("reading placement");
|
logger.info("reading placement");
|
||||||
ifstream fs(file.c_str());
|
std::ifstream fs(file.c_str());
|
||||||
if (!fs.good()) {
|
if (!fs.good()) {
|
||||||
logger.error("cannot open file: %s", file.c_str());
|
logger.error("cannot open file: %s", file.c_str());
|
||||||
return false;
|
return false;
|
||||||
@ -1085,7 +1085,7 @@ bool Database::readBSPl(const std::string& file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Database::writeBSPl(const std::string& file) {
|
bool Database::writeBSPl(const std::string& file) {
|
||||||
ofstream fs(file.c_str());
|
std::ofstream fs(file.c_str());
|
||||||
if (!fs.good()) {
|
if (!fs.good()) {
|
||||||
logger.error("cannot open file: %s", file.c_str());
|
logger.error("cannot open file: %s", file.c_str());
|
||||||
return false;
|
return false;
|
||||||
@ -1093,8 +1093,8 @@ bool Database::writeBSPl(const std::string& file) {
|
|||||||
fs << "UCLA pl 1.0\n";
|
fs << "UCLA pl 1.0\n";
|
||||||
fs << "# User : Chinese University of Hong Kong\n\n";
|
fs << "# User : Chinese University of Hong Kong\n\n";
|
||||||
for (auto cell : this->cells) {
|
for (auto cell : this->cells) {
|
||||||
fs << '\t' << left << setw(60) << cell->name() << right << setw(8) << cell->lx() / siteW << setw(8)
|
fs << '\t' << std::left << std::setw(60) << cell->name() << std::right << std::setw(8) << cell->lx() / siteW
|
||||||
<< cell->ly() / siteW << " : N";
|
<< std::setw(8) << cell->ly() / siteW << " : N";
|
||||||
if (cell->fixed()) {
|
if (cell->fixed()) {
|
||||||
if (cell->width() / siteW == 1 && cell->height() / siteW == 1) {
|
if (cell->width() / siteW == 1 && cell->height() / siteW == 1) {
|
||||||
fs << " /FIXED_NI";
|
fs << " /FIXED_NI";
|
||||||
@ -1102,7 +1102,7 @@ bool Database::writeBSPl(const std::string& file) {
|
|||||||
fs << " /FIXED";
|
fs << " /FIXED";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fs << endl;
|
fs << std::endl;
|
||||||
}
|
}
|
||||||
fs.close();
|
fs.close();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -4,7 +4,7 @@ using namespace db;
|
|||||||
|
|
||||||
bool Database::readConstraints(const std::string& file) {
|
bool Database::readConstraints(const std::string& file) {
|
||||||
string buffer;
|
string buffer;
|
||||||
ifstream ifs(file.c_str());
|
std::ifstream ifs(file.c_str());
|
||||||
if (!ifs.good()) {
|
if (!ifs.good()) {
|
||||||
logger.error("cannot open constraint file: %s", file.c_str());
|
logger.error("cannot open constraint file: %s", file.c_str());
|
||||||
return false;
|
return false;
|
||||||
@ -35,7 +35,7 @@ bool Database::readConstraints(const std::string& file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Database::readSize(const std::string& file) {
|
bool Database::readSize(const std::string& file) {
|
||||||
ifstream fs(file.c_str());
|
std::ifstream fs(file.c_str());
|
||||||
if (!fs.good()) {
|
if (!fs.good()) {
|
||||||
logger.error("cannot open size file: %s", file.c_str());
|
logger.error("cannot open size file: %s", file.c_str());
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -261,7 +261,7 @@ bool Database::readDEF(const std::string& file) {
|
|||||||
bool Database::readDEFPG(const std::string& file) {
|
bool Database::readDEFPG(const std::string& file) {
|
||||||
// shape of pre-routed PG mesh is not supported by the reader
|
// shape of pre-routed PG mesh is not supported by the reader
|
||||||
string buffer;
|
string buffer;
|
||||||
ifstream ifs(file.c_str());
|
std::ifstream ifs(file.c_str());
|
||||||
if (!ifs.good()) {
|
if (!ifs.good()) {
|
||||||
logger.error("Unable to open DEF PG file: %s", file.c_str());
|
logger.error("Unable to open DEF PG file: %s", file.c_str());
|
||||||
return false;
|
return false;
|
||||||
@ -373,34 +373,34 @@ bool Database::readDEFPG(const std::string& file) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::writeComponents(ofstream& ofs) {
|
bool Database::writeComponents(std::ofstream& ofs) {
|
||||||
int nCells = cells.size();
|
int nCells = cells.size();
|
||||||
ofs << "COMPONENTS " << nCells << " ;" << endl;
|
ofs << "COMPONENTS " << nCells << " ;" << std::endl;
|
||||||
// ofs << "COMPONENTS " << nCells << " ;" << endl;
|
// ofs << "COMPONENTS " << nCells << " ;" << std::endl;
|
||||||
for (int i = 0; i < nCells; i++) {
|
for (int i = 0; i < nCells; i++) {
|
||||||
Cell* cell = cells[i];
|
Cell* cell = cells[i];
|
||||||
#ifdef WRITE_BUFFER
|
#ifdef WRITE_BUFFER
|
||||||
ostringstream oss;
|
std::ostringstream oss;
|
||||||
#else
|
#else
|
||||||
ofstream& oss = ofs;
|
std::ofstream& oss = ofs;
|
||||||
#endif
|
#endif
|
||||||
oss << " - " << cell->name() << " " << cell->ctype()->name << endl;
|
oss << " - " << cell->name() << " " << cell->ctype()->name << std::endl;
|
||||||
// ofs << " - " << cell->name() << " " << cell->ctype()->name << endl;
|
// ofs << " - " << cell->name() << " " << cell->ctype()->name << std::endl;
|
||||||
if (cell->fixed()) {
|
if (cell->fixed()) {
|
||||||
oss << " + FIXED ( " << cell->lx() << " " << cell->ly() << " ) " << getOrient(cell->orient()) << " ;"
|
oss << " + FIXED ( " << cell->lx() << " " << cell->ly() << " ) " << getOrient(cell->orient()) << " ;"
|
||||||
<< endl;
|
<< std::endl;
|
||||||
// ofs << " + FIXED ( " << cell->lx() << " " << cell->ly() << " ) "
|
// ofs << " + FIXED ( " << cell->lx() << " " << cell->ly() << " ) "
|
||||||
// << getOrient(cell->orient())
|
// << getOrient(cell->orient())
|
||||||
// << " ;" << endl;
|
// << " ;" << std::endl;
|
||||||
} else if (cell->placed()) {
|
} else if (cell->placed()) {
|
||||||
oss << " + PLACED ( " << cell->lx() << " " << cell->ly() << " ) " << getOrient(cell->orient()) << " ;"
|
oss << " + PLACED ( " << cell->lx() << " " << cell->ly() << " ) " << getOrient(cell->orient()) << " ;"
|
||||||
<< endl;
|
<< std::endl;
|
||||||
// ofs << " + PLACED ( " << cell->lx() << " " << cell->ly() << " ) "
|
// ofs << " + PLACED ( " << cell->lx() << " " << cell->ly() << " ) "
|
||||||
// << getOrient(cell->orient())
|
// << getOrient(cell->orient())
|
||||||
// << " ;" << endl;
|
// << " ;" << std::endl;
|
||||||
} else {
|
} else {
|
||||||
oss << " + UNPLACED ;" << endl;
|
oss << " + UNPLACED ;" << std::endl;
|
||||||
// ofs << " + UNPLACED ;" << endl;
|
// ofs << " + UNPLACED ;" << std::endl;
|
||||||
}
|
}
|
||||||
#ifdef WRITE_BUFFER
|
#ifdef WRITE_BUFFER
|
||||||
string lines = oss.str();
|
string lines = oss.str();
|
||||||
@ -415,7 +415,7 @@ bool Database::writeComponents(ofstream& ofs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Database::writeICCAD2017(const string& inputDef, const string& outputDef) {
|
bool Database::writeICCAD2017(const string& inputDef, const string& outputDef) {
|
||||||
ifstream ifs(inputDef.c_str());
|
std::ifstream ifs(inputDef.c_str());
|
||||||
if (!ifs.good()) {
|
if (!ifs.good()) {
|
||||||
logger.error("Unable to create/open DEF: %s", inputDef.c_str());
|
logger.error("Unable to create/open DEF: %s", inputDef.c_str());
|
||||||
return false;
|
return false;
|
||||||
@ -425,7 +425,7 @@ bool Database::writeICCAD2017(const string& inputDef, const string& outputDef) {
|
|||||||
logger.info("reading %s", inputDef.c_str());
|
logger.info("reading %s", inputDef.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ofstream ofs(outputDef.c_str());
|
std::ofstream ofs(outputDef.c_str());
|
||||||
if (!ofs.good()) {
|
if (!ofs.good()) {
|
||||||
logger.error("Unable to create/open DEF: %s", outputDef.c_str());
|
logger.error("Unable to create/open DEF: %s", outputDef.c_str());
|
||||||
return false;
|
return false;
|
||||||
@ -434,18 +434,18 @@ bool Database::writeICCAD2017(const string& inputDef, const string& outputDef) {
|
|||||||
|
|
||||||
string line;
|
string line;
|
||||||
while (getline(ifs, line)) {
|
while (getline(ifs, line)) {
|
||||||
istringstream iss(line);
|
std::istringstream iss(line);
|
||||||
string s;
|
string s;
|
||||||
if (!(iss >> s)) {
|
if (!(iss >> s)) {
|
||||||
ofs << line << endl;
|
ofs << line << std::endl;
|
||||||
continue;
|
continue;
|
||||||
} else if (s != "COMPONENTS") {
|
} else if (s != "COMPONENTS") {
|
||||||
ofs << line << endl;
|
ofs << line << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
writeComponents(ofs);
|
writeComponents(ofs);
|
||||||
while (getline(ifs, line)) {
|
while (getline(ifs, line)) {
|
||||||
istringstream iss(line);
|
std::istringstream iss(line);
|
||||||
if (iss >> s && s == "END") {
|
if (iss >> s && s == "END") {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -456,7 +456,7 @@ bool Database::writeICCAD2017(const string& inputDef, const string& outputDef) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Database::writeICCAD2017(const string& outputDef) {
|
bool Database::writeICCAD2017(const string& outputDef) {
|
||||||
ofstream ofs(outputDef.c_str(), ios::app);
|
std::ofstream ofs(outputDef.c_str(), std::ios::app);
|
||||||
if (!ofs.good()) {
|
if (!ofs.good()) {
|
||||||
logger.error("Unable to create/open DEF: %s", outputDef.c_str());
|
logger.error("Unable to create/open DEF: %s", outputDef.c_str());
|
||||||
return false;
|
return false;
|
||||||
@ -465,24 +465,24 @@ bool Database::writeICCAD2017(const string& outputDef) {
|
|||||||
|
|
||||||
writeComponents(ofs); // just replace the information of components, while others keep remain.
|
writeComponents(ofs); // just replace the information of components, while others keep remain.
|
||||||
|
|
||||||
ofs << "END DESIGN\n\n" << endl;
|
ofs << "END DESIGN\n\n" << std::endl;
|
||||||
|
|
||||||
ofs.close();
|
ofs.close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::writeDEF(const string& file) {
|
bool Database::writeDEF(const string& file) {
|
||||||
ofstream ofs(file.c_str());
|
std::ofstream ofs(file.c_str());
|
||||||
if (!ofs.good()) {
|
if (!ofs.good()) {
|
||||||
logger.error("Unable to create/open DEF: %s", file.c_str());
|
logger.error("Unable to create/open DEF: %s", file.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
logger.info("writing %s", file.c_str());
|
logger.info("writing %s", file.c_str());
|
||||||
|
|
||||||
ofs << "VERSION 5.8 ;" << endl;
|
ofs << "VERSION 5.8 ;" << std::endl;
|
||||||
ofs << "DIVIDERCHAR \"/\" ;" << endl;
|
ofs << "DIVIDERCHAR \"/\" ;" << std::endl;
|
||||||
ofs << "BUSBITCHARS \"[]\" ;" << endl;
|
ofs << "BUSBITCHARS \"[]\" ;" << std::endl;
|
||||||
ofs << "DESIGN " << designName << " ;" << endl;
|
ofs << "DESIGN " << designName << " ;" << std::endl;
|
||||||
ofs << "UNITS DISTANCE MICRONS " << (int)DBU_Micron << " ; \n\n";
|
ofs << "UNITS DISTANCE MICRONS " << (int)DBU_Micron << " ; \n\n";
|
||||||
ofs << "DIEAREA ( " << dieLX << ' ' << dieLY << " ) ( " << dieHX << ' ' << dieHY << " ) ;\n\n";
|
ofs << "DIEAREA ( " << dieLX << ' ' << dieLY << " ) ( " << dieHX << ' ' << dieHY << " ) ;\n\n";
|
||||||
|
|
||||||
@ -492,7 +492,7 @@ bool Database::writeDEF(const string& file) {
|
|||||||
ofs << " DO " << row->xNum() << " BY " << row->yNum() << " STEP " << row->xStep() << ' ' << row->yStep()
|
ofs << " DO " << row->xNum() << " BY " << row->yNum() << " STEP " << row->xStep() << ' ' << row->yStep()
|
||||||
<< " ;\n";
|
<< " ;\n";
|
||||||
}
|
}
|
||||||
ofs << endl;
|
ofs << std::endl;
|
||||||
|
|
||||||
for (Track* track : tracks) {
|
for (Track* track : tracks) {
|
||||||
ofs << "TRACKS " << track->macro() << ' ' << track->start << " DO " << track->num << " STEP " << track->step
|
ofs << "TRACKS " << track->macro() << ' ' << track->start << " DO " << track->num << " STEP " << track->step
|
||||||
@ -502,9 +502,9 @@ bool Database::writeDEF(const string& file) {
|
|||||||
}
|
}
|
||||||
ofs << ";\n";
|
ofs << ";\n";
|
||||||
}
|
}
|
||||||
ofs << endl;
|
ofs << std::endl;
|
||||||
|
|
||||||
ostringstream ossv;
|
std::ostringstream ossv;
|
||||||
unsigned nVias = 0;
|
unsigned nVias = 0;
|
||||||
for (ViaType* via : viatypes) {
|
for (ViaType* via : viatypes) {
|
||||||
if (!via->isDef()) {
|
if (!via->isDef()) {
|
||||||
@ -542,7 +542,7 @@ bool Database::writeDEF(const string& file) {
|
|||||||
}
|
}
|
||||||
ofs << "END NONDEFAULTRULES\n\n";
|
ofs << "END NONDEFAULTRULES\n\n";
|
||||||
|
|
||||||
ostringstream ossr;
|
std::ostringstream ossr;
|
||||||
unsigned nRegions = 0;
|
unsigned nRegions = 0;
|
||||||
for (Region* region : regions) {
|
for (Region* region : regions) {
|
||||||
if (region->name() == "default") {
|
if (region->name() == "default") {
|
||||||
@ -597,7 +597,7 @@ bool Database::writeDEF(const string& file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ofs << "END DESIGN" << endl;
|
ofs << "END DESIGN" << std::endl;
|
||||||
|
|
||||||
ofs.close();
|
ofs.close();
|
||||||
return true;
|
return true;
|
||||||
@ -608,7 +608,7 @@ bool Database::writeDEF(const string& file) {
|
|||||||
/***********************************/
|
/***********************************/
|
||||||
|
|
||||||
/// a buffered writing scheme
|
/// a buffered writing scheme
|
||||||
bool Database::writeBuffer(ofstream& ofs, const string& line) {
|
bool Database::writeBuffer(std::ofstream& ofs, const string& line) {
|
||||||
const char* b = line.c_str();
|
const char* b = line.c_str();
|
||||||
size_t n = line.size();
|
size_t n = line.size();
|
||||||
while (_bufferSize + n > _bufferCapacity) // output exceeds the capacity
|
while (_bufferSize + n > _bufferCapacity) // output exceeds the capacity
|
||||||
@ -633,7 +633,7 @@ bool Database::writeBuffer(ofstream& ofs, const string& line) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::writeBufferFlush(ofstream& ofs) {
|
void Database::writeBufferFlush(std::ofstream& ofs) {
|
||||||
if (_bufferSize) // remember to write the rest content in the buffer
|
if (_bufferSize) // remember to write the rest content in the buffer
|
||||||
{
|
{
|
||||||
ofs.write(_buffer, _bufferSize);
|
ofs.write(_buffer, _bufferSize);
|
||||||
@ -679,7 +679,7 @@ int readLefUnits(lefrCallbackType_e c, lefiUnits* unit, lefiUserData ud) {
|
|||||||
int readLefProp(lefrCallbackType_e c, lefiProp* prop, lefiUserData ud) {
|
int readLefProp(lefrCallbackType_e c, lefiProp* prop, lefiUserData ud) {
|
||||||
Database* db = (Database*)ud;
|
Database* db = (Database*)ud;
|
||||||
if (prop->lefiProp::hasString() && !strcmp(prop->lefiProp::propName(), "LEF58_CELLEDGESPACINGTABLE")) {
|
if (prop->lefiProp::hasString() && !strcmp(prop->lefiProp::propName(), "LEF58_CELLEDGESPACINGTABLE")) {
|
||||||
stringstream sstable(prop->lefiProp::string());
|
std::stringstream sstable(prop->lefiProp::string());
|
||||||
string buffer;
|
string buffer;
|
||||||
|
|
||||||
while (!sstable.eof()) {
|
while (!sstable.eof()) {
|
||||||
@ -1021,12 +1021,12 @@ int readLefPin(lefrCallbackType_e c, lefiPin* pin, lefiUserData ud) {
|
|||||||
|
|
||||||
PinType* pintype = celltype->addPin(name, direction, type);
|
PinType* pintype = celltype->addPin(name, direction, type);
|
||||||
|
|
||||||
set<Point> nodes;
|
std::set<Point> nodes;
|
||||||
Layer* layer = nullptr;
|
Layer* layer = nullptr;
|
||||||
lefiGeomRect* rect = nullptr;
|
lefiGeomRect* rect = nullptr;
|
||||||
lefiGeomPolygon* polygon = nullptr;
|
lefiGeomPolygon* polygon = nullptr;
|
||||||
lefiGeometries* geom = pin->port(0);
|
lefiGeometries* geom = pin->port(0);
|
||||||
vector<pair<int, int>> poly;
|
vector<std::pair<int, int>> poly;
|
||||||
unsigned bj = 0;
|
unsigned bj = 0;
|
||||||
bool has45 = false;
|
bool has45 = false;
|
||||||
for (unsigned i = 0; i != (unsigned)geom->numItems(); ++i) {
|
for (unsigned i = 0; i != (unsigned)geom->numItems(); ++i) {
|
||||||
@ -1095,10 +1095,10 @@ int readLefPin(lefrCallbackType_e c, lefiPin* pin, lefiUserData ud) {
|
|||||||
nodes.emplace(poly[j].first, poly[j].second, dir);
|
nodes.emplace(poly[j].first, poly[j].second, dir);
|
||||||
}
|
}
|
||||||
while (nodes.size()) {
|
while (nodes.size()) {
|
||||||
set<Point>::iterator pk;
|
std::set<Point>::iterator pk;
|
||||||
set<Point>::iterator pl;
|
std::set<Point>::iterator pl;
|
||||||
set<Point>::iterator pm;
|
std::set<Point>::iterator pm;
|
||||||
set<Point>::iterator pn;
|
std::set<Point>::iterator pn;
|
||||||
|
|
||||||
while (nodes.size()) {
|
while (nodes.size()) {
|
||||||
pk = nodes.begin();
|
pk = nodes.begin();
|
||||||
@ -1118,12 +1118,12 @@ int readLefPin(lefrCallbackType_e c, lefiPin* pin, lefiUserData ud) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (nodes.size() < 4) {
|
if (nodes.size() < 4) {
|
||||||
cout << "Error when partitioning rectangles." << endl;
|
std::cout << "Error when partitioning rectangles." << std::endl;
|
||||||
cout << "Remaining points: ";
|
std::cout << "Remaining points: ";
|
||||||
for (const Point& p : nodes) {
|
for (const Point& p : nodes) {
|
||||||
printf("(%d, %d), ", p.x, p.y);
|
printf("(%d, %d), ", p.x, p.y);
|
||||||
}
|
}
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1219,7 +1219,7 @@ int readLefMacro(lefrCallbackType_e c, lefiMacro* macro, lefiUserData ud) {
|
|||||||
|
|
||||||
for (int i = 0; i < macro->numProperties(); ++i) {
|
for (int i = 0; i < macro->numProperties(); ++i) {
|
||||||
if (!strcmp(macro->propName(i), "LEF58_EDGETYPE")) {
|
if (!strcmp(macro->propName(i), "LEF58_EDGETYPE")) {
|
||||||
stringstream ssedgetype(macro->propValue(i));
|
std::stringstream ssedgetype(macro->propValue(i));
|
||||||
string buffer;
|
string buffer;
|
||||||
while (!ssedgetype.eof()) {
|
while (!ssedgetype.eof()) {
|
||||||
ssedgetype >> buffer;
|
ssedgetype >> buffer;
|
||||||
|
|||||||
@ -30,7 +30,7 @@ bool isVerilogSymbol(unsigned char c) {
|
|||||||
}
|
}
|
||||||
return symbols[(int)c] != 0;
|
return symbols[(int)c] != 0;
|
||||||
}
|
}
|
||||||
bool readVerilogLine(istream &is, vector<string> &tokens) {
|
bool readVerilogLine(std::istream &is, vector<string> &tokens) {
|
||||||
tokens.clear();
|
tokens.clear();
|
||||||
string line;
|
string line;
|
||||||
while (is && tokens.empty()) {
|
while (is && tokens.empty()) {
|
||||||
@ -73,7 +73,7 @@ bool readVerilogLine(istream &is, vector<string> &tokens) {
|
|||||||
|
|
||||||
bool Database::readVerilog(const std::string &file) {
|
bool Database::readVerilog(const std::string &file) {
|
||||||
logger.info("Reading verilog...");
|
logger.info("Reading verilog...");
|
||||||
ifstream fs(file.c_str());
|
std::ifstream fs(file.c_str());
|
||||||
if (!fs.good()) {
|
if (!fs.good()) {
|
||||||
logger.error("cannot open verilog file: %s", file.c_str());
|
logger.error("cannot open verilog file: %s", file.c_str());
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -2,6 +2,10 @@
|
|||||||
// Adapt from https://github.com/limbo018/DREAMPlace/blob/master/dreamplace/ops/draw_place/src/PlaceDrawer.h
|
// Adapt from https://github.com/limbo018/DREAMPlace/blob/master/dreamplace/ops/draw_place/src/PlaceDrawer.h
|
||||||
|
|
||||||
#include "Drawer.h"
|
#include "Drawer.h"
|
||||||
|
#include <cairo-pdf.h>
|
||||||
|
#include <cairo-ps.h>
|
||||||
|
#include <cairo-svg.h>
|
||||||
|
#include <cairo.h>
|
||||||
|
|
||||||
Drawer::Drawer(const std::vector<std::tuple<std::string, double, double, double, double>>& ele_type_to_rgba_vec,
|
Drawer::Drawer(const std::vector<std::tuple<std::string, double, double, double, double>>& ele_type_to_rgba_vec,
|
||||||
const std::string& filename_,
|
const std::string& filename_,
|
||||||
|
|||||||
@ -1,4 +1,21 @@
|
|||||||
#include "global.h"
|
#pragma once
|
||||||
|
|
||||||
|
// STL libraries
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
|
#include <numeric>
|
||||||
|
#include <stack>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
using index_type = int64_t;
|
||||||
|
|
||||||
class Drawer {
|
class Drawer {
|
||||||
private:
|
private:
|
||||||
std::unordered_map<std::string, std::tuple<double, double, double, double>> type_to_rgba;
|
std::unordered_map<std::string, std::tuple<double, double, double, double>> type_to_rgba;
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
#include "Drawer.h"
|
#include "Drawer.h"
|
||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
|
||||||
bool DrawGlobalPlacement(
|
bool DrawGlobalPlacement(
|
||||||
const std::vector<double>& node_pos_x,
|
const std::vector<double>& node_pos_x,
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
#include "common/db/Database.h"
|
#include "common/db/Database.h"
|
||||||
#include "gpudp/db/dp_torch.h"
|
#include "gpudp/db/dp_torch.h"
|
||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
#include <pybind11/stl_bind.h>
|
||||||
|
|
||||||
namespace Xplace {
|
namespace Xplace {
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <torch/extension.h>
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
#include "common/db/Database.h"
|
#include "common/db/Database.h"
|
||||||
|
|
||||||
|
|||||||
@ -206,7 +206,7 @@ void fillerLegalization(DPTorchRawDB& at_db) {
|
|||||||
|
|
||||||
// sort all blanks and create blank bucket list
|
// sort all blanks and create blank bucket list
|
||||||
int maxDegree = 0;
|
int maxDegree = 0;
|
||||||
robin_hood::unordered_map<int, vector<FillerBlank<float>>> blank_bucket_list;
|
robin_hood::unordered_map<int, std::vector<FillerBlank<float>>> blank_bucket_list;
|
||||||
for (int i = 0; i < num_blanks_x * num_blanks_y; i += 1) {
|
for (int i = 0; i < num_blanks_x * num_blanks_y; i += 1) {
|
||||||
std::vector<FillerBlank<float>>& blanks = bin_blanks.at(i);
|
std::vector<FillerBlank<float>>& blanks = bin_blanks.at(i);
|
||||||
for (unsigned int j = 0; j < blanks.size(); ++j) {
|
for (unsigned int j = 0; j < blanks.size(); ++j) {
|
||||||
@ -219,7 +219,7 @@ void fillerLegalization(DPTorchRawDB& at_db) {
|
|||||||
logger.info("%s maxDegree = %d", "Blanks", maxDegree);
|
logger.info("%s maxDegree = %d", "Blanks", maxDegree);
|
||||||
|
|
||||||
// sorted filler cell id
|
// sorted filler cell id
|
||||||
vector<int> fillers_to_blank(db.num_movable_nodes - db.num_conn_movable_nodes);
|
std::vector<int> fillers_to_blank(db.num_movable_nodes - db.num_conn_movable_nodes);
|
||||||
for (int i = 0; i < db.num_movable_nodes - db.num_conn_movable_nodes; i += 1) {
|
for (int i = 0; i < db.num_movable_nodes - db.num_conn_movable_nodes; i += 1) {
|
||||||
fillers_to_blank[i] = db.num_conn_movable_nodes + i;
|
fillers_to_blank[i] = db.num_conn_movable_nodes + i;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,9 @@
|
|||||||
#include "gpugr/db/GRDatabase.h"
|
#include "gpugr/db/GRDatabase.h"
|
||||||
#include "gpugr/gr/RouteForce.h"
|
#include "gpugr/gr/RouteForce.h"
|
||||||
#include "flute.h"
|
#include "flute.h"
|
||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
#include <pybind11/stl_bind.h>
|
||||||
|
|
||||||
namespace Xplace {
|
namespace Xplace {
|
||||||
|
|
||||||
|
|||||||
@ -191,7 +191,7 @@ void GRDatabase::setupCapacity() {
|
|||||||
void GRDatabase::setupCapacityBookshelf() {
|
void GRDatabase::setupCapacityBookshelf() {
|
||||||
capacity.resize(gridGraphSize, 0);
|
capacity.resize(gridGraphSize, 0);
|
||||||
for (int i = 0; i < nLayers; i++) {
|
for (int i = 0; i < nLayers; i++) {
|
||||||
int oricap = max(rawdb.bsRouteInfo.capH[i], rawdb.bsRouteInfo.capV[i]);
|
int oricap = std::max(rawdb.bsRouteInfo.capH[i], rawdb.bsRouteInfo.capV[i]);
|
||||||
float cap = oricap / (layerPitch[i]);
|
float cap = oricap / (layerPitch[i]);
|
||||||
if ((i & 1) ^ m1direction) {
|
if ((i & 1) ^ m1direction) {
|
||||||
for (int j = 0; j < xSize; j++) {
|
for (int j = 0; j < xSize; j++) {
|
||||||
@ -380,8 +380,8 @@ void GRDatabase::addCellObs(std::vector<RectOnLayer>& allObs, db::Cell* cell) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tuple<int, int, int, int> GRDatabase::getOrientOffset(int orient, int lx, int ly, int hx, int hy) {
|
std::tuple<int, int, int, int> GRDatabase::getOrientOffset(int orient, int lx, int ly, int hx, int hy) {
|
||||||
tuple<int, int, int, int> offset; // lx, ly, hx, hy
|
std::tuple<int, int, int, int> offset; // lx, ly, hx, hy
|
||||||
// 0:N, 1:W, 2:S, 3:E, 4:FN, 5:FW, 6:FS, 7:FE, -1:NONE
|
// 0:N, 1:W, 2:S, 3:E, 4:FN, 5:FW, 6:FS, 7:FE, -1:NONE
|
||||||
switch (orient) {
|
switch (orient) {
|
||||||
case 0: // N
|
case 0: // N
|
||||||
@ -470,7 +470,7 @@ void GRDatabase::markObs(std::vector<RectOnLayer>& allObs,
|
|||||||
wireUsage.resize(gridGraphSize, 0);
|
wireUsage.resize(gridGraphSize, 0);
|
||||||
wireTotalLength.resize(gridGraphSize, 0);
|
wireTotalLength.resize(gridGraphSize, 0);
|
||||||
|
|
||||||
vector<vector<int>> layerToObjIdx(nLayers);
|
std::vector<std::vector<int>> layerToObjIdx(nLayers);
|
||||||
for (unsigned i = 0; i < allObs.size(); i++) {
|
for (unsigned i = 0; i < allObs.size(); i++) {
|
||||||
int l = allObs[i].layer;
|
int l = allObs[i].layer;
|
||||||
if (l < obsStartLayer) continue;
|
if (l < obsStartLayer) continue;
|
||||||
@ -480,7 +480,7 @@ void GRDatabase::markObs(std::vector<RectOnLayer>& allObs,
|
|||||||
auto& t = tracks[l];
|
auto& t = tracks[l];
|
||||||
int dir = (l & 1) ^ m1direction;
|
int dir = (l & 1) ^ m1direction;
|
||||||
|
|
||||||
vector<vector<vector<std::pair<utils::IntervalT<int>, int>>>> markingBufferLUT;
|
std::vector<std::vector<std::vector<std::pair<utils::IntervalT<int>, int>>>> markingBufferLUT;
|
||||||
|
|
||||||
auto searchLowerBoundTrack = [&](int p) {
|
auto searchLowerBoundTrack = [&](int p) {
|
||||||
int pos = lower_bound(t.begin(), t.end(), p) - t.begin();
|
int pos = lower_bound(t.begin(), t.end(), p) - t.begin();
|
||||||
@ -545,8 +545,8 @@ void GRDatabase::markObs(std::vector<RectOnLayer>& allObs,
|
|||||||
utils::IntervalT<int> trackIntvl = rangeSearchTracks(obsBox[1 - dir], l);
|
utils::IntervalT<int> trackIntvl = rangeSearchTracks(obsBox[1 - dir], l);
|
||||||
if (!trackIntvl.IsValid()) continue;
|
if (!trackIntvl.IsValid()) continue;
|
||||||
|
|
||||||
int jmin = max(grBox[dir].low - 1, 0);
|
int jmin = std::max(grBox[dir].low - 1, 0);
|
||||||
int jmax = min(grBox[dir].high, (dir == 0 ? xSize : ySize) - 2);
|
int jmax = std::min(grBox[dir].high, (dir == 0 ? xSize : ySize) - 2);
|
||||||
for (int i = grBox[1 - dir].low; i <= grBox[1 - dir].high; i++) {
|
for (int i = grBox[1 - dir].low; i <= grBox[1 - dir].high; i++) {
|
||||||
utils::IntervalT<int> gridTrackIntvl(searchLowerBoundTrack(gridlines[1 - dir][i]),
|
utils::IntervalT<int> gridTrackIntvl(searchLowerBoundTrack(gridlines[1 - dir][i]),
|
||||||
searchLowerBoundTrack(gridlines[1 - dir][i + 1]) - 1);
|
searchLowerBoundTrack(gridlines[1 - dir][i + 1]) - 1);
|
||||||
@ -570,7 +570,7 @@ void GRDatabase::markObs(std::vector<RectOnLayer>& allObs,
|
|||||||
for (int j = 0; j < markingBufferLUT[i].size(); j++) {
|
for (int j = 0; j < markingBufferLUT[i].size(); j++) {
|
||||||
if (markingBufferLUT[i][j].size() == 0) continue;
|
if (markingBufferLUT[i][j].size() == 0) continue;
|
||||||
const auto& buf = markingBufferLUT[i][j];
|
const auto& buf = markingBufferLUT[i][j];
|
||||||
vector<int> trackBlocked(gridTrackIntvl.range() + 1, 0); // blocked track length
|
std::vector<int> trackBlocked(gridTrackIntvl.range() + 1, 0); // blocked track length
|
||||||
for (auto& pair : buf) {
|
for (auto& pair : buf) {
|
||||||
for (int k = pair.first.low; k <= pair.first.high; k++) {
|
for (int k = pair.first.low; k <= pair.first.high; k++) {
|
||||||
trackBlocked[k - gridTrackIntvl.low] += pair.second;
|
trackBlocked[k - gridTrackIntvl.low] += pair.second;
|
||||||
@ -599,16 +599,16 @@ void GRDatabase::markObsBookShelf(std::vector<RectOnLayer>& allObs,
|
|||||||
wireUsage.resize(gridGraphSize, 0);
|
wireUsage.resize(gridGraphSize, 0);
|
||||||
wireTotalLength.resize(gridGraphSize, 0);
|
wireTotalLength.resize(gridGraphSize, 0);
|
||||||
|
|
||||||
vector<vector<int>> layerToObjIdx(nLayers);
|
std::vector<std::vector<int>> layerToObjIdx(nLayers);
|
||||||
for (unsigned i = 0; i < allObs.size(); i++) {
|
for (unsigned i = 0; i < allObs.size(); i++) {
|
||||||
int l = allObs[i].layer;
|
int l = allObs[i].layer;
|
||||||
if (l < obsStartLayer) continue;
|
if (l < obsStartLayer) continue;
|
||||||
layerToObjIdx[allObs[i].layer].push_back(i);
|
layerToObjIdx[allObs[i].layer].push_back(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<float> layer2oricap(nLayers, 0.0);
|
std::vector<float> layer2oricap(nLayers, 0.0);
|
||||||
for (int i = 0; i < nLayers; i++) {
|
for (int i = 0; i < nLayers; i++) {
|
||||||
int oricap = max(rawdb.bsRouteInfo.capH[i], rawdb.bsRouteInfo.capV[i]);
|
int oricap = std::max(rawdb.bsRouteInfo.capH[i], rawdb.bsRouteInfo.capV[i]);
|
||||||
float cap = oricap / (layerPitch[i]);
|
float cap = oricap / (layerPitch[i]);
|
||||||
layer2oricap[i] = oricap;
|
layer2oricap[i] = oricap;
|
||||||
}
|
}
|
||||||
@ -616,7 +616,7 @@ void GRDatabase::markObsBookShelf(std::vector<RectOnLayer>& allObs,
|
|||||||
for (int l = obsStartLayer; l < nLayers; l++) {
|
for (int l = obsStartLayer; l < nLayers; l++) {
|
||||||
int dir = (l & 1) ^ m1direction;
|
int dir = (l & 1) ^ m1direction;
|
||||||
|
|
||||||
vector<vector<vector<utils::IntervalT<int>>>> markingBufferLUT;
|
std::vector<std::vector<std::vector<utils::IntervalT<int>>>> markingBufferLUT;
|
||||||
markingBufferLUT.resize((dir == 0 ? ySize : xSize));
|
markingBufferLUT.resize((dir == 0 ? ySize : xSize));
|
||||||
int lutInnerSize = (dir == 0 ? xSize : ySize);
|
int lutInnerSize = (dir == 0 ? xSize : ySize);
|
||||||
for (auto& e : markingBufferLUT) {
|
for (auto& e : markingBufferLUT) {
|
||||||
@ -645,8 +645,8 @@ void GRDatabase::markObsBookShelf(std::vector<RectOnLayer>& allObs,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
utils::BoxT<int> grBox(xmin, ymin, xmax, ymax);
|
utils::BoxT<int> grBox(xmin, ymin, xmax, ymax);
|
||||||
int jmin = max(grBox[dir].low - 1, 0);
|
int jmin = std::max(grBox[dir].low - 1, 0);
|
||||||
int jmax = min(grBox[dir].high, (dir == 0 ? xSize : ySize) - 2);
|
int jmax = std::min(grBox[dir].high, (dir == 0 ? xSize : ySize) - 2);
|
||||||
for (int i = grBox[1 - dir].low; i <= grBox[1 - dir].high; i++) {
|
for (int i = grBox[1 - dir].low; i <= grBox[1 - dir].high; i++) {
|
||||||
utils::IntervalT<int> gridIntvl(gridlines[1 - dir][i], gridlines[1 - dir][i + 1]);
|
utils::IntervalT<int> gridIntvl(gridlines[1 - dir][i], gridlines[1 - dir][i + 1]);
|
||||||
utils::IntervalT<int> blockedIntvl = gridIntvl.IntersectWith(obsBox[1 - dir]);
|
utils::IntervalT<int> blockedIntvl = gridIntvl.IntersectWith(obsBox[1 - dir]);
|
||||||
@ -664,7 +664,7 @@ void GRDatabase::markObsBookShelf(std::vector<RectOnLayer>& allObs,
|
|||||||
for (int j = 0; j < markingBufferLUT[i].size(); j++) {
|
for (int j = 0; j < markingBufferLUT[i].size(); j++) {
|
||||||
if (markingBufferLUT[i][j].size() == 0) continue;
|
if (markingBufferLUT[i][j].size() == 0) continue;
|
||||||
utils::IntervalT<int> gridIntvl(gridlines[1 - dir][i], gridlines[1 - dir][i + 1]);
|
utils::IntervalT<int> gridIntvl(gridlines[1 - dir][i], gridlines[1 - dir][i + 1]);
|
||||||
vector<utils::IntervalT<int>>& buf = markingBufferLUT[i][j];
|
std::vector<utils::IntervalT<int>>& buf = markingBufferLUT[i][j];
|
||||||
int ovlpLen = 0;
|
int ovlpLen = 0;
|
||||||
if (buf.size() > 1) {
|
if (buf.size() > 1) {
|
||||||
std::stable_sort(
|
std::stable_sort(
|
||||||
@ -675,10 +675,10 @@ void GRDatabase::markObsBookShelf(std::vector<RectOnLayer>& allObs,
|
|||||||
for (int bufIdx = 1; bufIdx < buf.size(); bufIdx++) {
|
for (int bufIdx = 1; bufIdx < buf.size(); bufIdx++) {
|
||||||
utils::IntervalT<int>& curIntvl = buf[bufIdx];
|
utils::IntervalT<int>& curIntvl = buf[bufIdx];
|
||||||
if (curIntvl.low == tmpIntvl.low) {
|
if (curIntvl.low == tmpIntvl.low) {
|
||||||
tmpIntvl.high = max(tmpIntvl.high, curIntvl.high);
|
tmpIntvl.high = std::max(tmpIntvl.high, curIntvl.high);
|
||||||
} else if (curIntvl.low > tmpIntvl.low) {
|
} else if (curIntvl.low > tmpIntvl.low) {
|
||||||
if (curIntvl.low <= tmpIntvl.high) {
|
if (curIntvl.low <= tmpIntvl.high) {
|
||||||
tmpIntvl.high = max(tmpIntvl.high, curIntvl.high);
|
tmpIntvl.high = std::max(tmpIntvl.high, curIntvl.high);
|
||||||
} else {
|
} else {
|
||||||
ovlpLen += tmpIntvl.range();
|
ovlpLen += tmpIntvl.range();
|
||||||
tmpIntvl.low = curIntvl.low;
|
tmpIntvl.low = curIntvl.low;
|
||||||
@ -698,12 +698,12 @@ void GRDatabase::markObsBookShelf(std::vector<RectOnLayer>& allObs,
|
|||||||
float blocked = floor((float)ovlpLen * (1.0 - rawdb.bsRouteInfo.blockagePorosity));
|
float blocked = floor((float)ovlpLen * (1.0 - rawdb.bsRouteInfo.blockagePorosity));
|
||||||
float availableSpace = ((float)gridIntvl.range() - blocked) / (float)gridIntvl.range();
|
float availableSpace = ((float)gridIntvl.range() - blocked) / (float)gridIntvl.range();
|
||||||
int adjustedCap = layer2oricap[l] * availableSpace;
|
int adjustedCap = layer2oricap[l] * availableSpace;
|
||||||
adjustedCap = max(0, adjustedCap);
|
adjustedCap = std::max(0, adjustedCap);
|
||||||
int numTracksAvailable = adjustedCap / layerPitch[l];
|
int numTracksAvailable = adjustedCap / layerPitch[l];
|
||||||
float bcount = capacity[l * nMaxGrid * nMaxGrid + i * nMaxGrid + j] - (float)numTracksAvailable;
|
float bcount = capacity[l * nMaxGrid * nMaxGrid + i * nMaxGrid + j] - (float)numTracksAvailable;
|
||||||
// Assign value, we suppose tracks are completely blocked
|
// Assign value, we suppose tracks are completely blocked
|
||||||
wireUsage[l * nMaxGrid * nMaxGrid + i * nMaxGrid + j] =
|
wireUsage[l * nMaxGrid * nMaxGrid + i * nMaxGrid + j] =
|
||||||
min(bcount, capacity[l * nMaxGrid * nMaxGrid + i * nMaxGrid + j]);
|
std::min(bcount, capacity[l * nMaxGrid * nMaxGrid + i * nMaxGrid + j]);
|
||||||
wireTotalLength[l * nMaxGrid * nMaxGrid + i * nMaxGrid + j] =
|
wireTotalLength[l * nMaxGrid * nMaxGrid + i * nMaxGrid + j] =
|
||||||
wireDist[l * nMaxGrid * nMaxGrid + i * nMaxGrid + j] *
|
wireDist[l * nMaxGrid * nMaxGrid + i * nMaxGrid + j] *
|
||||||
wireUsage[l * nMaxGrid * nMaxGrid + i * nMaxGrid + j];
|
wireUsage[l * nMaxGrid * nMaxGrid + i * nMaxGrid + j];
|
||||||
@ -1036,9 +1036,9 @@ void GRDatabase::writeGuides(std::string outputFile) {
|
|||||||
int l = p / nMaxGrid / nMaxGrid, x = p % (nMaxGrid * nMaxGrid) / nMaxGrid, y = p % nMaxGrid;
|
int l = p / nMaxGrid / nMaxGrid, x = p % (nMaxGrid * nMaxGrid) / nMaxGrid, y = p % nMaxGrid;
|
||||||
if (!(l & 1) ^ m1direction) std::swap(x, y);
|
if (!(l & 1) ^ m1direction) std::swap(x, y);
|
||||||
// int xmin = x, xmax = x, ymin = y, ymax = y;
|
// int xmin = x, xmax = x, ymin = y, ymax = y;
|
||||||
int lmin = max(0, l - 2), lmax = min(nLayers - 1, l + 2);
|
int lmin = std::max(0, l - 2), lmax = std::min(nLayers - 1, l + 2);
|
||||||
int xmin = max(0, x - 1), xmax = min(xSize - 1, x + 1);
|
int xmin = std::max(0, x - 1), xmax = std::min(xSize - 1, x + 1);
|
||||||
int ymin = max(0, y - 1), ymax = min(ySize - 1, y + 1);
|
int ymin = std::max(0, y - 1), ymax = std::min(ySize - 1, y + 1);
|
||||||
for (int i = lmin; i <= lmax; i++) singleGuide(xmin, xmax, ymin, ymax, i);
|
for (int i = lmin; i <= lmax; i++) singleGuide(xmin, xmax, ymin, ymax, i);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -92,7 +92,7 @@ public:
|
|||||||
void writeGuides(std::string outputFile);
|
void writeGuides(std::string outputFile);
|
||||||
|
|
||||||
int encodeId(int l, int x, int y);
|
int encodeId(int l, int x, int y);
|
||||||
tuple<int, int, int, int> getOrientOffset(int orient, int lx, int ly, int hx, int hy);
|
std::tuple<int, int, int, int> getOrientOffset(int orient, int lx, int ly, int hx, int hy);
|
||||||
int getEOLSpace(int width, int l);
|
int getEOLSpace(int width, int l);
|
||||||
int getParallelRunSpace(int l, int width, int length);
|
int getParallelRunSpace(int l, int width, int length);
|
||||||
utils::PointT<int> getObsMargin(RectOnLayer box, AggrParaRunSpace aggr);
|
utils::PointT<int> getObsMargin(RectOnLayer box, AggrParaRunSpace aggr);
|
||||||
|
|||||||
@ -90,7 +90,7 @@ void GPURouter::setUnitViaMultiplier(float value) {
|
|||||||
unitViaMultiplier = value;
|
unitViaMultiplier = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPURouter::setUnitVioCost(vector<float>& values, float discount) {
|
void GPURouter::setUnitVioCost(std::vector<float>& values, float discount) {
|
||||||
//printf("??? setUnitVioCost %.2f\n", discount);
|
//printf("??? setUnitVioCost %.2f\n", discount);
|
||||||
float temp[100];
|
float temp[100];
|
||||||
for(int i = 0; i < LAYER; i++)
|
for(int i = 0; i < LAYER; i++)
|
||||||
@ -106,9 +106,9 @@ void GPURouter::setUnitViaCost(float value) {
|
|||||||
unitViaCost = value;
|
unitViaCost = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPURouter::setMap(const vector<float> &cap, const vector<float> &wir, const vector<float> &fixedL, const vector<float> &fix) {
|
void GPURouter::setMap(const std::vector<float> &cap, const std::vector<float> &wir, const std::vector<float> &fixedL, const std::vector<float> &fix) {
|
||||||
int gridGraphSize = LAYER * N * N;
|
int gridGraphSize = LAYER * N * N;
|
||||||
auto copy = [&] (const vector<float> &vec, float *target) {
|
auto copy = [&] (const std::vector<float> &vec, float *target) {
|
||||||
cudaMemcpy(target, vec.data(), gridGraphSize * sizeof(float), cudaMemcpyHostToDevice);
|
cudaMemcpy(target, vec.data(), gridGraphSize * sizeof(float), cudaMemcpyHostToDevice);
|
||||||
};
|
};
|
||||||
copy(cap, capacity);
|
copy(cap, capacity);
|
||||||
@ -187,7 +187,7 @@ __global__ void calculateCoarseVia(float *cell_resource, int *coarseVia, int *wi
|
|||||||
else
|
else
|
||||||
sum += cell_resource[layer * N * N + j * N + i];
|
sum += cell_resource[layer * N * N + j * N + i];
|
||||||
|
|
||||||
ans += 1.0 / max(0.1, sum / (maxx - minx + 1) / (maxy - miny + 1));
|
ans += 1.0 / max((float)0.1, sum / (maxx - minx + 1) / (maxy - miny + 1));
|
||||||
sum = 0;
|
sum = 0;
|
||||||
for(int i = minx; i <= maxx; i++)
|
for(int i = minx; i <= maxx; i++)
|
||||||
for(int j = miny; j <= maxy; j++)
|
for(int j = miny; j <= maxy; j++)
|
||||||
@ -195,7 +195,7 @@ __global__ void calculateCoarseVia(float *cell_resource, int *coarseVia, int *wi
|
|||||||
sum += cell_resource[(layer + 1) * N * N + i * N + j];
|
sum += cell_resource[(layer + 1) * N * N + i * N + j];
|
||||||
else
|
else
|
||||||
sum += cell_resource[(layer + 1) * N * N + j * N + i];
|
sum += cell_resource[(layer + 1) * N * N + j * N + i];
|
||||||
ans += 1.0 / max(0.1, sum / (maxx - minx + 1) / (maxy - miny + 1));
|
ans += 1.0 / max((float)0.1, sum / (maxx - minx + 1) / (maxy - miny + 1));
|
||||||
coarseVia[layer * xsize * ysize + x * ysize + y] = 100 * ans;
|
coarseVia[layer * xsize * ysize + x * ysize + y] = 100 * ans;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -243,7 +243,7 @@ __global__ void traceBack(int *modifiedWire, int *modifiedVia, dtype *dist, int
|
|||||||
}
|
}
|
||||||
//if(netId == debug)
|
//if(netId == debug)
|
||||||
// printf("Start tracing result: %d %d %d\n", p / N / N, p % (N * N) / N, p % N);
|
// printf("Start tracing result: %d %d %d\n", p / N / N, p % (N * N) / N, p % N);
|
||||||
maxval = max(maxval, 1.0 * dist[p]);
|
maxval = std::max(maxval, 1.0 * dist[p]);
|
||||||
int expected = p;
|
int expected = p;
|
||||||
while(dist[expected] > 0)
|
while(dist[expected] > 0)
|
||||||
expected = prev[expected];
|
expected = prev[expected];
|
||||||
@ -554,12 +554,12 @@ __global__ void generateBatch(int n, int *minx, int *maxx, int *miny, int *maxy,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPURouter::route(vector<GrNet> &nets, int iter) {
|
void GPURouter::route(std::vector<GrNet> &nets, int iter) {
|
||||||
logger.info("GPU Routing start... DIRECTION: %d", DIRECTION);
|
logger.info("GPU Routing start... DIRECTION: %d", DIRECTION);
|
||||||
|
|
||||||
double prtime = 0, prpreparetime = 0, batchgentime = 0, timer2 = 0;
|
double prtime = 0, prpreparetime = 0, batchgentime = 0, timer2 = 0;
|
||||||
|
|
||||||
vector<int> netsToRoute;
|
std::vector<int> netsToRoute;
|
||||||
if(iter > 0) {
|
if(iter > 0) {
|
||||||
logger.info("Maze Routing...");
|
logger.info("Maze Routing...");
|
||||||
ripupOverflowNets<<<BLOCK_NUMBER(NET_NUM), BLOCK_SIZE>>> (isOverflowNet, routes, routesOffset, wires, vias, NET_NUM);
|
ripupOverflowNets<<<BLOCK_NUMBER(NET_NUM), BLOCK_SIZE>>> (isOverflowNet, routes, routesOffset, wires, vias, NET_NUM);
|
||||||
@ -584,7 +584,7 @@ void GPURouter::route(vector<GrNet> &nets, int iter) {
|
|||||||
markUnrouteUsage<<<BLOCK_NUMBER(cnt), BLOCK_SIZE>>> (allpins, vias, cnt);
|
markUnrouteUsage<<<BLOCK_NUMBER(cnt), BLOCK_SIZE>>> (allpins, vias, cnt);
|
||||||
cudaDeviceSynchronize();*/
|
cudaDeviceSynchronize();*/
|
||||||
}
|
}
|
||||||
vector<int> batchSizes;
|
std::vector<int> batchSizes;
|
||||||
{
|
{
|
||||||
double t = clock();
|
double t = clock();
|
||||||
constexpr bool check_vis_correctness = false;
|
constexpr bool check_vis_correctness = false;
|
||||||
@ -674,8 +674,8 @@ void GPURouter::route(vector<GrNet> &nets, int iter) {
|
|||||||
// for(int i = net.lowerx; i <= net.upperx; i++)
|
// for(int i = net.lowerx; i <= net.upperx; i++)
|
||||||
// for(int j = net.lowery; j <= net.uppery; j++)
|
// for(int j = net.lowery; j <= net.uppery; j++)
|
||||||
// if(vis[i][j]) return false;
|
// if(vis[i][j]) return false;
|
||||||
for(int i = max(0, net.lowerx - margin); i <= net.upperx + margin; i++)
|
for(int i = std::max(0, net.lowerx - margin); i <= net.upperx + margin; i++)
|
||||||
for(int j = max(0, net.lowery - margin); j <= net.uppery + margin; j++)
|
for(int j = std::max(0, net.lowery - margin); j <= net.uppery + margin; j++)
|
||||||
if(vis[i][j]) return false;
|
if(vis[i][j]) return false;
|
||||||
/*} else {
|
/*} else {
|
||||||
for(int i = net.lowerx; i <= net.upperx; i++) {
|
for(int i = net.lowerx; i <= net.upperx; i++) {
|
||||||
@ -689,8 +689,8 @@ void GPURouter::route(vector<GrNet> &nets, int iter) {
|
|||||||
auto insert = [&] (int netId) {
|
auto insert = [&] (int netId) {
|
||||||
//double t = clock();
|
//double t = clock();
|
||||||
const auto &net = nets[netId];
|
const auto &net = nets[netId];
|
||||||
int xl = max(0, net.lowerx - margin), xr = net.upperx + margin;
|
int xl = std::max(0, net.lowerx - margin), xr = net.upperx + margin;
|
||||||
int yl = max(0, net.lowery - margin), yr = net.uppery + margin;
|
int yl = std::max(0, net.lowery - margin), yr = net.uppery + margin;
|
||||||
//int blockL = yl / LEN - (yl % LEN == 0), blockR = yr / LEN + (yr % LEN == 0);
|
//int blockL = yl / LEN - (yl % LEN == 0), blockR = yr / LEN + (yr % LEN == 0);
|
||||||
for(int i = xl; i <= xr; i++) {
|
for(int i = xl; i <= xr; i++) {
|
||||||
for(int j = yl; j <= yr; j++) {
|
for(int j = yl; j <= yr; j++) {
|
||||||
@ -709,8 +709,8 @@ void GPURouter::route(vector<GrNet> &nets, int iter) {
|
|||||||
};
|
};
|
||||||
auto remove = [&] (int netId) {
|
auto remove = [&] (int netId) {
|
||||||
const auto &net = nets[netId];
|
const auto &net = nets[netId];
|
||||||
int xl = max(0, net.lowerx - margin), xr = net.upperx + margin;
|
int xl = std::max(0, net.lowerx - margin), xr = net.upperx + margin;
|
||||||
int yl = max(0, net.lowery - margin), yr = net.uppery + margin;
|
int yl = std::max(0, net.lowery - margin), yr = net.uppery + margin;
|
||||||
//int blockL = yl / LEN - (yl % LEN == 0), blockR = yr / LEN + (yr % LEN == 0);
|
//int blockL = yl / LEN - (yl % LEN == 0), blockR = yr / LEN + (yr % LEN == 0);
|
||||||
for(int i = xl; i <= xr; i++) {
|
for(int i = xl; i <= xr; i++) {
|
||||||
for(int j = yl; j <= yr; j++) {
|
for(int j = yl; j <= yr; j++) {
|
||||||
@ -880,7 +880,7 @@ void GPURouter::route(vector<GrNet> &nets, int iter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPURouter::setFromNets(vector<GrNet> &nets, int numPlPin_) {
|
void GPURouter::setFromNets(std::vector<GrNet> &nets, int numPlPin_) {
|
||||||
NET_NUM = nets.size();
|
NET_NUM = nets.size();
|
||||||
pinNumCPU = new int[NET_NUM];
|
pinNumCPU = new int[NET_NUM];
|
||||||
routesOffsetCPU = new int[NET_NUM + 1];
|
routesOffsetCPU = new int[NET_NUM + 1];
|
||||||
@ -929,15 +929,15 @@ void GPURouter::setFromNets(vector<GrNet> &nets, int numPlPin_) {
|
|||||||
cudaDeviceSynchronize();
|
cudaDeviceSynchronize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPURouter::setToNets(vector<GrNet> &nets) {
|
void GPURouter::setToNets(std::vector<GrNet> &nets) {
|
||||||
int *routesCPU = new int[routesOffsetCPU[NET_NUM]];
|
int *routesCPU = new int[routesOffsetCPU[NET_NUM]];
|
||||||
int mx = 0;
|
int mx = 0;
|
||||||
cudaMemcpy(routesCPU, routes, sizeof(int) * routesOffsetCPU[NET_NUM], cudaMemcpyDeviceToHost);
|
cudaMemcpy(routesCPU, routes, sizeof(int) * routesOffsetCPU[NET_NUM], cudaMemcpyDeviceToHost);
|
||||||
int num_net_use_too_many_route = 0;
|
int num_net_use_too_many_route = 0;
|
||||||
for(size_t netId = 0; netId < nets.size(); netId++) {
|
for(size_t netId = 0; netId < nets.size(); netId++) {
|
||||||
vector<int> wires, vias;
|
std::vector<int> wires, vias;
|
||||||
int *routesSub = routesCPU + routesOffsetCPU[netId];
|
int *routesSub = routesCPU + routesOffsetCPU[netId];
|
||||||
mx = max(mx, routesSub[0] / pinNumCPU[netId]);
|
mx = std::max(mx, routesSub[0] / pinNumCPU[netId]);
|
||||||
if(routesSub[0] > routesOffsetCPU[netId + 1] - routesOffsetCPU[netId]) {
|
if(routesSub[0] > routesOffsetCPU[netId + 1] - routesOffsetCPU[netId]) {
|
||||||
num_net_use_too_many_route++;
|
num_net_use_too_many_route++;
|
||||||
// std::cerr << "ERROR: too many routesSub! Please set MAX_ROUTE_LEN_PER_PIN larger than " << routesSub[0] / pinNumCPU[netId] << std::endl;
|
// std::cerr << "ERROR: too many routesSub! Please set MAX_ROUTE_LEN_PER_PIN larger than " << routesSub[0] / pinNumCPU[netId] << std::endl;
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#include "MazeRoute.h"
|
#include "MazeRoute.h"
|
||||||
#include "PatternRoute.h"
|
#include "PatternRoute.h"
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
|
#include <torch/extension.h>
|
||||||
#include "gpugr/db/GrNet.h"
|
#include "gpugr/db/GrNet.h"
|
||||||
|
|
||||||
namespace gr {
|
namespace gr {
|
||||||
@ -20,15 +21,15 @@ public:
|
|||||||
void initialize(
|
void initialize(
|
||||||
int device_id, int layer, int x, int y, int N_, int cgxsize_, int cgysize_, int direction, int csrn_scale);
|
int device_id, int layer, int x, int y, int N_, int cgxsize_, int cgysize_, int direction, int csrn_scale);
|
||||||
|
|
||||||
void setMap(const vector<float> &cap,
|
void setMap(const std::vector<float> &cap,
|
||||||
const vector<float> &wir,
|
const std::vector<float> &wir,
|
||||||
const vector<float> &fixedL,
|
const std::vector<float> &fixedL,
|
||||||
const vector<float> &fix);
|
const std::vector<float> &fix);
|
||||||
void setFromNets(vector<GrNet> &nets, int numPlPin_);
|
void setFromNets(std::vector<GrNet> &nets, int numPlPin_);
|
||||||
void setToNets(vector<GrNet> &nets);
|
void setToNets(std::vector<GrNet> &nets);
|
||||||
void route(vector<GrNet> &nets, int iterleft);
|
void route(std::vector<GrNet> &nets, int iterleft);
|
||||||
void setUnitViaMultiplier(float w);
|
void setUnitViaMultiplier(float w);
|
||||||
void setUnitVioCost(vector<float>& cost, float discount);
|
void setUnitVioCost(std::vector<float>& cost, float discount);
|
||||||
void setLogisticSlope(float value);
|
void setLogisticSlope(float value);
|
||||||
void setUnitViaCost(float value);
|
void setUnitViaCost(float value);
|
||||||
void query();
|
void query();
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#include "GPURouter.h"
|
#include "GPURouter.h"
|
||||||
#include "InCellUsage.cuh"
|
#include "InCellUsage.cuh"
|
||||||
|
#include <torch/extension.h>
|
||||||
|
|
||||||
namespace gr {
|
namespace gr {
|
||||||
|
|
||||||
@ -126,7 +127,7 @@ __global__ void compGcellRouteForce(
|
|||||||
}
|
}
|
||||||
// TODO: 1) should we also consider X direction?
|
// TODO: 1) should we also consider X direction?
|
||||||
// 2) consider via cost?
|
// 2) consider via cost?
|
||||||
float cost = unit_wire_cost / min(cap_map_2d[j][ly], 0.2);
|
float cost = unit_wire_cost / min(cap_map_2d[j][ly], (float)0.2);
|
||||||
grad += cost * route_gradmat[1][j][ly] * mask_map[j][ly] * cur_dist_weight;
|
grad += cost * route_gradmat[1][j][ly] * mask_map[j][ly] * cur_dist_weight;
|
||||||
total_weight += cur_dist_weight;
|
total_weight += cur_dist_weight;
|
||||||
}
|
}
|
||||||
@ -141,7 +142,7 @@ __global__ void compGcellRouteForce(
|
|||||||
} else {
|
} else {
|
||||||
cur_dist_weight = dist_weights[j - ly];
|
cur_dist_weight = dist_weights[j - ly];
|
||||||
}
|
}
|
||||||
float cost = unit_wire_cost / min(cap_map_2d[lx][j], 0.2);
|
float cost = unit_wire_cost / min(cap_map_2d[lx][j], (float)0.2);
|
||||||
grad += cost * route_gradmat[0][lx][j] * mask_map[lx][j] * cur_dist_weight;
|
grad += cost * route_gradmat[0][lx][j] * mask_map[lx][j] * cur_dist_weight;
|
||||||
total_weight += cur_dist_weight;
|
total_weight += cur_dist_weight;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -347,9 +347,9 @@ int prepare(double &count,
|
|||||||
*/
|
*/
|
||||||
} else {
|
} else {
|
||||||
if (x1 == x2)
|
if (x1 == x2)
|
||||||
for (int t = min(y1, y2); t < max(y1, y2); t++) cnty[x1][t]++;
|
for (int t = std::min(y1, y2); t < std::max(y1, y2); t++) cnty[x1][t]++;
|
||||||
else
|
else
|
||||||
for (int t = min(x1, x2); t < max(x1, x2); t++) cntx[t][y2]++;
|
for (int t = std::min(x1, x2); t < std::max(x1, x2); t++) cntx[t][y2]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(flutetree.branch);
|
free(flutetree.branch);
|
||||||
|
|||||||
@ -44,7 +44,7 @@ void RouteForce::run_ggr() {
|
|||||||
if (iter == 0) {
|
if (iter == 0) {
|
||||||
router.setUnitViaMultiplier(1);
|
router.setUnitViaMultiplier(1);
|
||||||
} else {
|
} else {
|
||||||
router.setUnitViaMultiplier(max(100 / pow(5, iter - 1), 4.0));
|
router.setUnitViaMultiplier(std::max(100 / pow(5, iter - 1), 4.0));
|
||||||
router.setUnitVioCost(_unitShortVioCost,
|
router.setUnitVioCost(_unitShortVioCost,
|
||||||
rrrInitVioCostDiscount + (1.0 - rrrInitVioCostDiscount) / (rrrIterLimit - 1) * iter);
|
rrrInitVioCostDiscount + (1.0 - rrrInitVioCostDiscount) / (rrrIterLimit - 1) * iter);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,9 @@
|
|||||||
#include "common/db/Database.h"
|
#include "common/db/Database.h"
|
||||||
#include "io_parser/gp/GPDatabase.h"
|
#include "io_parser/gp/GPDatabase.h"
|
||||||
|
|
||||||
namespace py = pybind11;
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
#include <pybind11/stl_bind.h>
|
||||||
|
|
||||||
namespace Xplace {
|
namespace Xplace {
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Xplace {
|
namespace Xplace {
|
||||||
|
|
||||||
bool loadParams(const py::dict& kwargs) {
|
bool loadParams(const pybind11::dict& kwargs) {
|
||||||
db::setting.reset();
|
db::setting.reset();
|
||||||
// ----- design related options -----
|
// ----- design related options -----
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ bool loadParams(const py::dict& kwargs) {
|
|||||||
for (auto lef_py : kwargs["lefs"]) {
|
for (auto lef_py : kwargs["lefs"]) {
|
||||||
auto lef = lef_py.cast<std::string>();
|
auto lef = lef_py.cast<std::string>();
|
||||||
db::setting.LefFiles.emplace_back(lef);
|
db::setting.LefFiles.emplace_back(lef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kwargs.contains("constraints")) {
|
if (kwargs.contains("constraints")) {
|
||||||
@ -112,7 +112,7 @@ bool loadParams(const py::dict& kwargs) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<std::shared_ptr<db::Database>, std::shared_ptr<gp::GPDatabase>> start_all(const py::dict& kwargs) {
|
std::tuple<std::shared_ptr<db::Database>, std::shared_ptr<gp::GPDatabase>> start_all(const pybind11::dict& kwargs) {
|
||||||
bool load_status = loadParams(kwargs);
|
bool load_status = loadParams(kwargs);
|
||||||
if (!load_status) {
|
if (!load_status) {
|
||||||
throw std::invalid_argument("Received invalid params. Please check!");
|
throw std::invalid_argument("Received invalid params. Please check!");
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <torch/extension.h>
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
#include "common/db/Database.h"
|
#include "common/db/Database.h"
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#include <torch/extension.h>
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
#include "common/db/Database.h"
|
#include "common/db/Database.h"
|
||||||
#include "flute.h"
|
#include "flute.h"
|
||||||
|
|||||||
@ -361,7 +361,7 @@ def macro_legalization_main(node_pos: torch.Tensor, data: PlaceData, args, logge
|
|||||||
# Commit result
|
# Commit result
|
||||||
commit_to_node_pos(node_pos, data, lg_rawdb)
|
commit_to_node_pos(node_pos, data, lg_rawdb)
|
||||||
torch.cuda.synchronize(node_pos.device)
|
torch.cuda.synchronize(node_pos.device)
|
||||||
logger.info("***** Finish Macro Legalization, HPWL: %.4E Time: %.4f *****" % (
|
logger.info("***** Finish Macro Legalization, HPWL: %.6E Time: %.4f *****" % (
|
||||||
get_obj_hpwl(node_pos, data, args).item(), time.time() - ml_time
|
get_obj_hpwl(node_pos, data, args).item(), time.time() - ml_time
|
||||||
))
|
))
|
||||||
|
|
||||||
@ -419,7 +419,7 @@ def run_lg(node_pos: torch.Tensor, data: PlaceData, args, logger):
|
|||||||
# Commit result
|
# Commit result
|
||||||
commit_to_node_pos(node_pos, data, lg_rawdb)
|
commit_to_node_pos(node_pos, data, lg_rawdb)
|
||||||
torch.cuda.synchronize(node_pos.device)
|
torch.cuda.synchronize(node_pos.device)
|
||||||
logger.info("***** Finish Legalization, HPWL: %.4E Time: %.4f *****" % (
|
logger.info("***** Finish Legalization, HPWL: %.6E Time: %.4f *****" % (
|
||||||
get_obj_hpwl(node_pos, data, args).item(), time.time() - gl_time
|
get_obj_hpwl(node_pos, data, args).item(), time.time() - gl_time
|
||||||
))
|
))
|
||||||
|
|
||||||
@ -492,7 +492,7 @@ def run_dp(node_pos: torch.Tensor, data: PlaceData, args, logger):
|
|||||||
# update dp_rawdb for next step dp_func and update the final solution
|
# update dp_rawdb for next step dp_func and update the final solution
|
||||||
dp_rawdb.commit()
|
dp_rawdb.commit()
|
||||||
commit_to_node_pos(node_pos, data, dp_rawdb)
|
commit_to_node_pos(node_pos, data, dp_rawdb)
|
||||||
logger.info("***** Finish %s, HPWL: %.4E Time: %.4f *****" % (
|
logger.info("***** Finish %s, HPWL: %.6E Time: %.4f *****" % (
|
||||||
func_name, get_obj_hpwl(node_pos, data, args).item(), time.time() - start_time
|
func_name, get_obj_hpwl(node_pos, data, args).item(), time.time() - start_time
|
||||||
))
|
))
|
||||||
|
|
||||||
@ -545,7 +545,7 @@ def run_dp_route_opt(node_pos: torch.Tensor, gpdb, rawdb, ps, data: PlaceData, a
|
|||||||
logger.error("Check failed in %s. Rollback to previous DP iteration." % func_name)
|
logger.error("Check failed in %s. Rollback to previous DP iteration." % func_name)
|
||||||
node_pos[mov_lhs:mov_rhs].data.copy_(node_pos_bk[mov_lhs:mov_rhs])
|
node_pos[mov_lhs:mov_rhs].data.copy_(node_pos_bk[mov_lhs:mov_rhs])
|
||||||
|
|
||||||
logger.info("***** Finish %s, HPWL: %.4E Time: %.4f *****" % (
|
logger.info("***** Finish %s, HPWL: %.6E Time: %.4f *****" % (
|
||||||
func_name, get_obj_hpwl(node_pos, data, args).item(), time.time() - start_time
|
func_name, get_obj_hpwl(node_pos, data, args).item(), time.time() - start_time
|
||||||
))
|
))
|
||||||
|
|
||||||
@ -674,7 +674,7 @@ def external_detail_placement(input_file, data: PlaceData, args, logger, eval_mo
|
|||||||
else:
|
else:
|
||||||
logger.info("Finish external detailed placement. LG+DP Time: %.2f seconds" %
|
logger.info("Finish external detailed placement. LG+DP Time: %.2f seconds" %
|
||||||
(dp_end_time - dp_start_time))
|
(dp_end_time - dp_start_time))
|
||||||
logger.info("After DP, HPWL: %.4E" % dp_hpwl)
|
logger.info("After DP, HPWL: %.6E" % dp_hpwl)
|
||||||
logger.info("Write detail placement in %s" % dp_out_file)
|
logger.info("Write detail placement in %s" % dp_out_file)
|
||||||
# del gpdb, rawdb
|
# del gpdb, rawdb
|
||||||
# logger.info("Evaluating detail placement result...")
|
# logger.info("Evaluating detail placement result...")
|
||||||
@ -684,7 +684,7 @@ def external_detail_placement(input_file, data: PlaceData, args, logger, eval_mo
|
|||||||
# hpwl = get_obj_hpwl(data.node_pos, data, args).item()
|
# hpwl = get_obj_hpwl(data.node_pos, data, args).item()
|
||||||
# info = (iteration + 1, hpwl, data.design_name)
|
# info = (iteration + 1, hpwl, data.design_name)
|
||||||
# draw_fig_with_cairo_cpp(data.node_pos, data.node_size, data, info, args)
|
# draw_fig_with_cairo_cpp(data.node_pos, data.node_size, data, info, args)
|
||||||
# logger.info("After DP, HPWL: %.4E" % hpwl)
|
# logger.info("After DP, HPWL: %.6E" % hpwl)
|
||||||
|
|
||||||
dp_time = dp_end_time - dp_start_time if dp_end_time is not None else 0.0
|
dp_time = dp_end_time - dp_start_time if dp_end_time is not None else 0.0
|
||||||
|
|
||||||
@ -716,7 +716,7 @@ def default_detail_placement(node_pos, gpdb, rawdb, ps, data: PlaceData, args, l
|
|||||||
info = ("%d_dp" % (ps.iter + 1), dp_hpwl, data.design_name)
|
info = ("%d_dp" % (ps.iter + 1), dp_hpwl, data.design_name)
|
||||||
if args.draw_placement:
|
if args.draw_placement:
|
||||||
draw_fig_with_cairo_cpp(node_pos, data.node_size, data, info, args)
|
draw_fig_with_cairo_cpp(node_pos, data.node_size, data, info, args)
|
||||||
logger.info("After DP, HPWL: %.4E" % dp_hpwl)
|
logger.info("After DP, HPWL: %.6E" % dp_hpwl)
|
||||||
|
|
||||||
lg_time = lg_end_time - lg_start_time
|
lg_time = lg_end_time - lg_start_time
|
||||||
dp_time = dp_end_time - dp_start_time
|
dp_time = dp_end_time - dp_start_time
|
||||||
@ -769,7 +769,7 @@ def detail_placement_main(node_pos, gpdb, rawdb, ps, data: PlaceData, args, logg
|
|||||||
ext_dp_hpwl, top5overflow, _ = external_detail_placement(
|
ext_dp_hpwl, top5overflow, _ = external_detail_placement(
|
||||||
dp_out_file, data, args, logger, eval_mode=True, dp_engine_name=args.eval_engine
|
dp_out_file, data, args, logger, eval_mode=True, dp_engine_name=args.eval_engine
|
||||||
)
|
)
|
||||||
logger.info("External engine evaluated DP HPWL: %.4E Top-5 OVFL: %.2f" %
|
logger.info("External engine evaluated DP HPWL: %.6E Top-5 OVFL: %.2f" %
|
||||||
(ext_dp_hpwl, top5overflow))
|
(ext_dp_hpwl, top5overflow))
|
||||||
dp_hpwl = ext_dp_hpwl
|
dp_hpwl = ext_dp_hpwl
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -164,7 +164,7 @@ def run_placement_main_nesterov(args, logger):
|
|||||||
if args.draw_placement:
|
if args.draw_placement:
|
||||||
info = ("%d_mixed_gp" % (iteration + 1), hpwl, data.design_name)
|
info = ("%d_mixed_gp" % (iteration + 1), hpwl, data.design_name)
|
||||||
draw_fig_with_cairo_cpp(node_pos, data.node_size, data, info, args)
|
draw_fig_with_cairo_cpp(node_pos, data.node_size, data, info, args)
|
||||||
logger.info("After Mixed-GP, best solution eval, exact HPWL: %.4E exact Overflow: %.4f" % (hpwl, overflow))
|
logger.info("After Mixed-GP, best solution eval, exact HPWL: %.6E exact Overflow: %.4f" % (hpwl, overflow))
|
||||||
# Run macro legalization to change node_pos inplace
|
# Run macro legalization to change node_pos inplace
|
||||||
macro_legalization_main(node_pos, data, args, logger)
|
macro_legalization_main(node_pos, data, args, logger)
|
||||||
if args.draw_placement:
|
if args.draw_placement:
|
||||||
@ -375,7 +375,7 @@ def run_placement_main_nesterov(args, logger):
|
|||||||
gp_end_time = time.time()
|
gp_end_time = time.time()
|
||||||
gp_time = gp_end_time - gp_start_time
|
gp_time = gp_end_time - gp_start_time
|
||||||
gp_per_iter = gp_time / (iteration + 1)
|
gp_per_iter = gp_time / (iteration + 1)
|
||||||
logger.info("GP Stop! #Iters %d masked_hpwl: %.4E overflow: %.4f GP Time: %.4fs perIterTime: %.6fs" %
|
logger.info("GP Stop! #Iters %d masked_hpwl: %.6E overflow: %.4f GP Time: %.4fs perIterTime: %.6fs" %
|
||||||
(iteration, hpwl, overflow, gp_time, gp_time / (iteration + 1))
|
(iteration, hpwl, overflow, gp_time, gp_time / (iteration + 1))
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -385,7 +385,7 @@ def run_placement_main_nesterov(args, logger):
|
|||||||
info = ("%d_gp" % (iteration + 1), hpwl, data.design_name)
|
info = ("%d_gp" % (iteration + 1), hpwl, data.design_name)
|
||||||
if args.draw_placement:
|
if args.draw_placement:
|
||||||
draw_fig_with_cairo_cpp(node_pos, data.node_size, data, info, args)
|
draw_fig_with_cairo_cpp(node_pos, data.node_size, data, info, args)
|
||||||
logger.info("After GP, best solution eval, exact HPWL: %.4E exact Overflow: %.4f" % (hpwl, overflow))
|
logger.info("After GP, best solution eval, exact HPWL: %.6E exact Overflow: %.4f" % (hpwl, overflow))
|
||||||
ps.visualize(args, logger)
|
ps.visualize(args, logger)
|
||||||
gp_hpwl = hpwl
|
gp_hpwl = hpwl
|
||||||
gp_time = gp_end_time - gp_start_time
|
gp_time = gp_end_time - gp_start_time
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user