Skip to content

Commit 45845da

Browse files
committed
Revert "Testing only changes, will revert"
This reverts commit 54ddbc6.
1 parent 54ddbc6 commit 45845da

File tree

2 files changed

+3
-112
lines changed

2 files changed

+3
-112
lines changed

src/dpl/include/dpl/Opendp.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ class Opendp
189189
bool checkOverlap(const Node* cell, const DbuRect& rect) const;
190190
static bool isInside(const Rect& cell, const Rect& box);
191191
bool isInside(const Node* cell, const Rect& rect) const;
192-
PixelPt searchNearestSiteOG(const Node* cell, GridX x, GridY y) const;
193192
PixelPt searchNearestSite(const Node* cell, GridX x, GridY y) const;
194193
int calcDist(GridPt p0, GridPt p1) const;
195194
bool canBePlaced(const Node* cell, GridX bin_x, GridY bin_y) const;

src/dpl/src/Place.cpp

Lines changed: 3 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -690,106 +690,10 @@ int Opendp::distChange(const Node* cell, const DbuX x, const DbuY y) const
690690

691691
////////////////////////////////////////////////////////////////
692692

693-
PixelPt Opendp::searchNearestSiteOG(const Node* cell,
694-
const GridX x,
695-
const GridY y) const
696-
{
697-
// Diamond search limits.
698-
GridX x_min = x - max_displacement_x_;
699-
GridX x_max = x + max_displacement_x_;
700-
GridY y_min = y - max_displacement_y_;
701-
GridY y_max = y + max_displacement_y_;
702-
703-
// Restrict search to group boundary.
704-
Group* group = cell->getGroup();
705-
if (group) {
706-
// Map boundary to grid staying inside.
707-
const GridRect grid_boundary = grid_->gridWithin(group->getBBox());
708-
const GridPt min = grid_boundary.closestPtInside({x_min, y_min});
709-
const GridPt max = grid_boundary.closestPtInside({x_max, y_max});
710-
x_min = min.x;
711-
y_min = min.y;
712-
x_max = max.x;
713-
y_max = max.y;
714-
}
715-
716-
// Clip limits to grid bounds.
717-
x_min = max(GridX{0}, x_min);
718-
y_min = max(GridY{0}, y_min);
719-
x_max = min(grid_->getRowSiteCount(), x_max);
720-
y_max = min(grid_->getRowCount(), y_max);
721-
debugPrint(logger_,
722-
DPL,
723-
"place",
724-
1,
725-
"Search Nearest Site {} ({}, {}) bounds ({}-{}, {}-{})",
726-
cell->name(),
727-
x,
728-
y,
729-
x_min,
730-
x_max - 1,
731-
y_min,
732-
y_max - 1);
733-
734-
struct PQ_entry
735-
{
736-
int manhattan_distance;
737-
GridPt p;
738-
bool operator>(const PQ_entry& other) const
739-
{
740-
return manhattan_distance > other.manhattan_distance;
741-
}
742-
bool operator==(const PQ_entry& other) const
743-
{
744-
return manhattan_distance == other.manhattan_distance;
745-
}
746-
};
747-
std::priority_queue<PQ_entry, std::vector<PQ_entry>, std::greater<PQ_entry>>
748-
positionsHeap;
749-
std::unordered_set<GridPt> visited;
750-
GridPt center{x, y};
751-
positionsHeap.push(PQ_entry{0, center});
752-
visited.insert(center);
753-
754-
const vector<GridPt> neighbors = {{GridX(-1), GridY(0)},
755-
{GridX(1), GridY(0)},
756-
{GridX(0), GridY(-1)},
757-
{GridX(0), GridY(1)}};
758-
while (!positionsHeap.empty()) {
759-
const GridPt nearest = positionsHeap.top().p;
760-
positionsHeap.pop();
761-
762-
if (canBePlaced(cell, nearest.x, nearest.y)) {
763-
return PixelPt(
764-
grid_->gridPixel(nearest.x, nearest.y), nearest.x, nearest.y);
765-
}
766-
767-
// Put neighbors in the queue
768-
for (GridPt offset : neighbors) {
769-
GridPt neighbor = {nearest.x + offset.x, nearest.y + offset.y};
770-
// Check if it was already put in the queue
771-
if (visited.count(neighbor) > 0) {
772-
continue;
773-
}
774-
// Check limits
775-
if (neighbor.x < x_min || neighbor.x > x_max || neighbor.y < y_min
776-
|| neighbor.y > y_max) {
777-
continue;
778-
}
779-
780-
visited.insert(neighbor);
781-
positionsHeap.push(PQ_entry{calcDist(center, neighbor), neighbor});
782-
}
783-
}
784-
return PixelPt();
785-
}
786-
787693
PixelPt Opendp::searchNearestSite(const Node* cell,
788694
const GridX x,
789695
const GridY y) const
790696
{
791-
// Ensure same distance as OG algorithm
792-
PixelPt OGPixel = searchNearestSiteOG(cell, x, y);
793697
// Diamond search limits.
794698
GridX x_min = x - max_displacement_x_;
795699
GridX x_max = x + max_displacement_x_;
@@ -857,30 +761,18 @@ PixelPt Opendp::searchNearestSite(const Node* cell,
857761
};
858762

859763
// Add the 4 immediate neighbors of the center.
860-
addIfInBounds({center.x - 1, center.y});
861764
addIfInBounds({center.x + 1, center.y});
862-
addIfInBounds({center.x, center.y - 1});
765+
addIfInBounds({center.x - 1, center.y});
863766
addIfInBounds({center.x, center.y + 1});
767+
addIfInBounds({center.x, center.y - 1});
864768

865769
while (!positionsHeap.empty()) {
866770
const GridPt nearest = positionsHeap.top().p;
867771
positionsHeap.pop();
868772

869773
if (canBePlaced(cell, nearest.x, nearest.y)) {
870-
871-
PixelPt result(
774+
return PixelPt(
872775
grid_->gridPixel(nearest.x, nearest.y), nearest.x, nearest.y);
873-
if (result.x != OGPixel.x || result.y != OGPixel.y){
874-
auto distOG = calcDist(center, {OGPixel.x, OGPixel.y});
875-
auto dist_new = calcDist(center, {result.x, result.y});
876-
logger_->error(DPL,
877-
18,
878-
"Returned a different Pixel originally ({}, {})[dist: {}], now ({}, {})[dist: {}]",
879-
OGPixel.x, OGPixel.y, distOG, result.x, result.y, dist_new);
880-
}
881-
882-
return OGPixel;
883-
884776
}
885777

886778
auto getSign = [](auto const grid_coord, auto center_coord) {

0 commit comments

Comments
 (0)