Skip to content

Commit

Permalink
Merge pull request The-OpenROAD-Project#4180 from The-OpenROAD-Projec…
Browse files Browse the repository at this point in the history
…t-staging/TR-fix-gc-and-patch

TR fix gc and patch
  • Loading branch information
maliberty authored Oct 26, 2023
2 parents 5101759 + 561b99b commit 0074941
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 65 deletions.
3 changes: 3 additions & 0 deletions src/drt/src/dr/FlexDR.h
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,9 @@ class FlexDRWorker
bool isCongested_;
bool save_updates_;

// hellpers
bool isRoutePatchWire(const frPatchWire* pwire) const;
bool isRouteVia(const frVia* via) const;
// init
void init(const frDesign* design);
void initNets(const frDesign* design);
Expand Down
31 changes: 7 additions & 24 deletions src/drt/src/dr/FlexDR_end.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,48 +233,31 @@ void FlexDRWorker::endRemoveNets_pathSeg(frDesign* design,

void FlexDRWorker::endRemoveNets_via(frDesign* design, frVia* via)
{
auto gridBBox = getRouteBox();
auto regionQuery = design->getRegionQuery();
auto net = via->getNet();
Point viaPoint = via->getOrigin();
if (isInitDR()
&& (viaPoint.x() == gridBBox.xMin() || viaPoint.x() == gridBBox.xMax()
|| viaPoint.y() == gridBBox.yMin()
|| viaPoint.y() == gridBBox.yMax())) {
return;
}
if (viaPoint.x() >= gridBBox.xMin() && viaPoint.y() >= gridBBox.yMin()
&& viaPoint.x() <= gridBBox.xMax() && viaPoint.y() <= gridBBox.yMax()) {
if (isRouteVia(via)) {
auto net = via->getNet();
if (save_updates_) {
drUpdate update(drUpdate::REMOVE_FROM_NET);
update.setNet(net);
update.setIndexInOwner(via->getIndexInOwner());
design_->addUpdate(update);
}
auto regionQuery = design->getRegionQuery();
regionQuery->removeDRObj(via); // delete rq
net->removeVia(via);
}
}

void FlexDRWorker::endRemoveNets_patchWire(frDesign* design, frPatchWire* pwire)
{
auto gridBBox = getRouteBox();
auto regionQuery = design->getRegionQuery();
auto net = pwire->getNet();
Point origin = pwire->getOrigin();
if (isInitDR()
&& (origin.x() == gridBBox.xMin() || origin.x() == gridBBox.xMax()
|| origin.y() == gridBBox.yMin() || origin.y() == gridBBox.yMax())) {
return;
}
if (origin.x() >= gridBBox.xMin() && origin.y() >= gridBBox.yMin()
&& origin.x() <= gridBBox.xMax() && origin.y() <= gridBBox.yMax()) {
if (isRoutePatchWire(pwire)) {
auto net = pwire->getNet();
if (save_updates_) {
drUpdate update(drUpdate::REMOVE_FROM_NET);
update.setNet(net);
update.setIndexInOwner(pwire->getIndexInOwner());
design_->addUpdate(update);
}
auto regionQuery = design->getRegionQuery();
regionQuery->removeDRObj(pwire); // delete rq
net->removePatchWire(pwire);
}
Expand All @@ -286,7 +269,7 @@ void FlexDRWorker::endRemoveNets(
map<frNet*, set<pair<Point, frLayerNum>>, frBlockObjectComp>& boundPts)
{
vector<frBlockObject*> result;
design->getRegionQuery()->queryDRObj(getRouteBox(), result);
design->getRegionQuery()->queryDRObj(getExtBox(), result);
for (auto rptr : result) {
if (rptr->typeId() == frcPathSeg) {
auto cptr = static_cast<frPathSeg*>(rptr);
Expand Down
23 changes: 21 additions & 2 deletions src/drt/src/dr/FlexDR_graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ void FlexDRGraphics::startNet(drNet* net)
}
}

void FlexDRGraphics::endNet(drNet* net)
void FlexDRGraphics::midNet(drNet* net)
{
if (!net_) {
return;
Expand All @@ -704,7 +704,7 @@ void FlexDRGraphics::endNet(drNet* net)
point_cnt += pts.size();
}

status("End net: " + net->getFrNet()->getName() + " searched "
status("Mid net: " + net->getFrNet()->getName() + " searched "
+ std::to_string(point_cnt) + " points");

if (settings_->draw) {
Expand All @@ -718,6 +718,25 @@ void FlexDRGraphics::endNet(drNet* net)
for (auto& points : points_by_layer_) {
points.clear();
}
}

void FlexDRGraphics::endNet(drNet* net)
{
if (!net_) {
return;
}
gui_->removeSelected<GridGraphDescriptor::Data>();
assert(net == net_);

status("End net: " + net->getFrNet()->getName() + " After GC");

if (settings_->draw) {
gui_->redraw();
}

if (settings_->allowPause) {
gui_->pause();
}
net_ = nullptr;
}

Expand Down
2 changes: 2 additions & 0 deletions src/drt/src/dr/FlexDR_graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class FlexDRGraphics : public gui::Renderer

void startNet(drNet* net);

void midNet(drNet* net);

void endNet(drNet* net);

void searchNode(const FlexGridGraph* grid_graph,
Expand Down
40 changes: 23 additions & 17 deletions src/drt/src/dr/FlexDR_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ using namespace std;
using namespace fr;
namespace bgi = boost::geometry::index;

bool FlexDRWorker::isRoutePatchWire(const frPatchWire* pwire) const
{
const auto& gridBBox = getRouteBox();
Point origin = pwire->getOrigin();
return isInitDR() ? gridBBox.overlaps(origin) : gridBBox.intersects(origin);
}

bool FlexDRWorker::isRouteVia(const frVia* via) const
{
const auto& gridBBox = getRouteBox();
Point origin = via->getOrigin();
return isInitDR() ? gridBBox.overlaps(origin) : gridBBox.intersects(origin);
}

void FlexDRWorker::initNetObjs_pathSeg(
frPathSeg* pathSeg,
set<frNet*, frBlockObjectComp>& nets,
Expand Down Expand Up @@ -147,8 +161,10 @@ void FlexDRWorker::initNetObjs_via(
{
auto net = via->getNet();
nets.insert(net);
if (getRouteBox().intersects(via->getOrigin())) {
netRouteObjs[net].push_back(make_unique<drVia>(*via));
if (isRouteVia(via)) {
auto uVia = make_unique<drVia>(*via);
unique_ptr<drConnFig> uDRObj(std::move(uVia));
netRouteObjs[net].push_back(std::move(uDRObj));
} else {
netExtObjs[net].push_back(make_unique<drVia>(*via));
}
Expand All @@ -162,8 +178,10 @@ void FlexDRWorker::initNetObjs_patchWire(
{
auto net = pwire->getNet();
nets.insert(net);
if (getRouteBox().intersects(pwire->getOrigin())) {
netRouteObjs[net].push_back(make_unique<drPatchWire>(*pwire));
if (isRoutePatchWire(pwire)) {
auto uPWire = make_unique<drPatchWire>(*pwire);
unique_ptr<drConnFig> uDRObj(std::move(uPWire));
netRouteObjs[net].push_back(std::move(uDRObj));
} else {
netExtObjs[net].push_back(make_unique<drPatchWire>(*pwire));
}
Expand Down Expand Up @@ -255,13 +273,6 @@ static bool segOnBorder(const Rect& routeBox,
}
}

// The origin is strictly inside the routeBox and not on an edge
static bool viaInInterior(const Rect& routeBox, const Point& origin)
{
return routeBox.xMin() < origin.x() && origin.x() < routeBox.xMax()
&& routeBox.yMin() < origin.y() && origin.y() < routeBox.yMax();
}

void FlexDRWorker::initNets_segmentTerms(
const Point& bp,
const frLayerNum lNum,
Expand Down Expand Up @@ -349,12 +360,7 @@ void FlexDRWorker::initNets_initDR(
vExtObjs.push_back(std::move(netRouteObjs[net][i]));
}
} else if (obj->typeId() == drcVia) {
auto via = static_cast<drVia*>(obj.get());
if (viaInInterior(getRouteBox(), via->getOrigin())) {
vRouteObjs.push_back(std::move(netRouteObjs[net][i]));
} else {
vExtObjs.push_back(std::move(netRouteObjs[net][i]));
}
vRouteObjs.push_back(std::move(netRouteObjs[net][i]));
} else if (obj->typeId() == drcPatchWire) {
vRouteObjs.push_back(std::move(netRouteObjs[net][i]));
}
Expand Down
9 changes: 8 additions & 1 deletion src/drt/src/dr/FlexDR_maze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,9 @@ void FlexDRWorker::route_queue_main(queue<RouteQueueEntry>& rerouteQueue)
net->getFrNet()->getName(),
routeBoxStringStream.str());
}
if (graphics_) {
graphics_->midNet(net);
}
mazeNetEnd(net);
net->addNumReroutes();
didRoute = true;
Expand Down Expand Up @@ -1781,6 +1784,7 @@ void FlexDRWorker::route_queue_main(queue<RouteQueueEntry>& rerouteQueue)
workerRegionQuery.add(tmp.get());
net->addRoute(std::move(tmp));
}
gcWorker_->clearPWires();
if (getDRIter() >= beginDebugIter
&& !getGCWorker()->getMarkers().empty()) {
logger_->info(DRT,
Expand Down Expand Up @@ -3143,7 +3147,10 @@ void FlexDRWorker::routeNet_postAstarPatchMinAreaVio(
layerNum = gridGraph_.getLayerNum(currIdx.z());
minAreaConstraint = getTech()->getLayer(layerNum)->getAreaConstraint();
frArea reqArea = (minAreaConstraint) ? minAreaConstraint->getMinArea() : 0;
if (areaMap.find(currIdx) != areaMap.end()) {
if (currArea < reqArea && areaMap.find(currIdx) != areaMap.end()) {
if (!prev_is_wire) {
currArea /= 2;
}
currArea += areaMap.find(currIdx)->second;
}
endViaHalfEncArea = 0;
Expand Down
5 changes: 5 additions & 0 deletions src/drt/src/gc/FlexGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ const std::vector<std::unique_ptr<drPatchWire>>& FlexGCWorker::getPWires() const
return impl_->pwires_;
}

void FlexGCWorker::clearPWires()
{
impl_->pwires_.clear();
}

bool FlexGCWorker::setTargetNet(frBlockObject* in)
{
auto& owner2nets = impl_->owner2nets_;
Expand Down
1 change: 1 addition & 0 deletions src/drt/src/gc/FlexGC.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class FlexGCWorker
void init(const frDesign* design);
int main();
void end();
void clearPWires();
// initialization from FlexPA, initPA0 --> addPAObj --> initPA1
void initPA0(const frDesign* design);
void initPA1();
Expand Down
5 changes: 3 additions & 2 deletions src/drt/src/gc/FlexGC_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class FlexGCWorker::Impl

FlexGCWorkerRegionQuery& getWorkerRegionQuery() { return rq_; }

void modifyMarkers();
// init
gcNet* getNet(frBlockObject* obj);
gcNet* getNet(frNet* net);
Expand Down Expand Up @@ -277,8 +278,8 @@ class FlexGCWorker::Impl
gcRect* rect,
frLef58CornerSpacingConstraint* con);

void checkMetalShape();
void checkMetalShape_main(gcPin* pin);
void checkMetalShape(bool allow_patching = false);
void checkMetalShape_main(gcPin* pin, bool allow_patching);
void checkMetalShape_minWidth(const gtl::rectangle_data<frCoord>& rect,
frLayerNum layerNum,
gcNet* net,
Expand Down
Loading

0 comments on commit 0074941

Please sign in to comment.