Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drt: Contiguous GC data #6016

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/drt/src/db/dynarray.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once
#include <vector>

template <typename T>
class dynarray
{
public:
dynarray() = default;
dynarray(std::vector<T>&& data) : data(std::move(data)) {}
dynarray(size_t size) : data(size) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: unknown type name 'size_t'; did you mean 'std::size_t'? [clang-diagnostic-error]

Suggested change
dynarray(size_t size) : data(size) {}
dynarray(std::size_t size) : data(size) {}
Additional context

/usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:279: 'std::size_t' declared here

  typedef __SIZE_TYPE__ 	size_t;
                         ^

T& operator[](size_t idx) { return data[idx]; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: unknown type name 'size_t'; did you mean 'std::size_t'? [clang-diagnostic-error]

Suggested change
T& operator[](size_t idx) { return data[idx]; }
T& operator[](std::size_t idx) { return data[idx]; }
Additional context

/usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:279: 'std::size_t' declared here

  typedef __SIZE_TYPE__ 	size_t;
                         ^

const T& operator[](size_t idx) const { return data[idx]; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: unknown type name 'size_t'; did you mean 'std::size_t'? [clang-diagnostic-error]

Suggested change
const T& operator[](size_t idx) const { return data[idx]; }
const T& operator[](std::size_t idx) const { return data[idx]; }
Additional context

/usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:279: 'std::size_t' declared here

  typedef __SIZE_TYPE__ 	size_t;
                         ^

auto begin() { return data.begin(); }
auto begin() const { return data.begin(); }
auto end() { return data.end(); }
auto end() const { return data.end(); }
size_t size() const { return data.size(); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: unknown type name 'size_t'; did you mean 'std::size_t'? [clang-diagnostic-error]

Suggested change
size_t size() const { return data.size(); }
std::size_t size() const { return data.size(); }
Additional context

/usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:279: 'std::size_t' declared here

  typedef __SIZE_TYPE__ 	size_t;
                         ^

void clear() { data.clear(); }
T& front() { return data.front(); }
const T& front() const { return data.front(); }
T& back() { return data.back(); }
const T& back() const { return data.back(); }

private:
std::vector<T> data;
};
89 changes: 49 additions & 40 deletions src/drt/src/db/gcObj/gcNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <memory>

#include "db/dynarray.h"
#include "db/gcObj/gcBlockObject.h"
#include "db/gcObj/gcPin.h"
#include "db/obj/frBlockage.h"
Expand Down Expand Up @@ -74,22 +75,39 @@ class gcNet : public gcBlockObject
routeRectangles_[layerNum].push_back(rect);
}
}
void addPin(const gtl::polygon_90_with_holes_data<frCoord>& shape,
frLayerNum layerNum)
void initPins()
{
auto pin = std::make_unique<gcPin>(shape, layerNum, this);
pin->setId(pins_[layerNum].size());
pins_[layerNum].push_back(std::move(pin));
}
void addPin(const gtl::rectangle_data<frCoord>& rect, frLayerNum layerNum)
{
gtl::polygon_90_with_holes_data<frCoord> shape;
std::vector<frCoord> coords
= {gtl::xl(rect), gtl::yl(rect), gtl::xh(rect), gtl::yh(rect)};
shape.set_compact(coords.begin(), coords.end());
auto pin = std::make_unique<gcPin>(shape, layerNum, this);
pin->setId(pins_[layerNum].size());
pins_[layerNum].push_back(std::move(pin));
for (int i = 0; i < pins_.size(); i++) {
std::vector<gcPin> pins;
// init pin from polygons
gtl::polygon_90_set_data<frCoord> layerPolys;
std::vector<gtl::polygon_90_with_holes_data<frCoord>> polys;
polys.clear();
using gtl::operators::operator+=;
layerPolys += getPolygons(i, false);
layerPolys += getPolygons(i, true);
layerPolys.get(polys);
for (auto& poly : polys) {
pins.emplace_back(poly, i, this);
pins.back().setId(pins.size());
}
// init pin from rectangles
const auto addPin = ([&](const gtl::rectangle_data<frCoord>& rect) {
gtl::polygon_90_with_holes_data<frCoord> shape;
std::vector<frCoord> coords
= {gtl::xl(rect), gtl::yl(rect), gtl::xh(rect), gtl::yh(rect)};
shape.set_compact(coords.begin(), coords.end());
pins.emplace_back(shape, i, this);
pins.back().setId(pins.size());
});
for (auto& rect : getRectangles(i, false)) {
addPin(rect);
}
for (auto& rect : getRectangles(i, true)) {
addPin(rect);
}
pins_[i] = std::move(pins);
}
}
void setOwner(frBlockObject* in) { owner_ = in; }
void clear()
Expand Down Expand Up @@ -143,14 +161,8 @@ class gcNet : public gcBlockObject
}
return routeRectangles_[layerNum];
}
const std::vector<std::vector<std::unique_ptr<gcPin>>>& getPins() const
{
return pins_;
}
const std::vector<std::unique_ptr<gcPin>>& getPins(frLayerNum layerNum) const
{
return pins_[layerNum];
}
std::vector<dynarray<gcPin>>& getPins() { return pins_; }
dynarray<gcPin>& getPins(frLayerNum layerNum) { return pins_[layerNum]; }
bool hasOwner() const { return owner_; }
frBlockObject* getOwner() const { return owner_; }
bool isBlockage() const
Expand Down Expand Up @@ -212,37 +224,34 @@ class gcNet : public gcBlockObject
gcPin* pin,
gcNet* net)
{
std::unique_ptr<gcRect> sp = std::make_unique<gcRect>();
sp->setLayerNum(lNum);
sp->addToNet(net);
sp->addToPin(pin);
sp->setRect(bx);
gcRect sp;
sp.setLayerNum(lNum);
sp.addToNet(net);
sp.addToPin(pin);
sp.setRect(bx);
specialSpacingRects.push_back(std::move(sp));
}
const std::vector<std::unique_ptr<gcRect>>& getSpecialSpcRects() const
{
return specialSpacingRects;
}
std::vector<gcRect>& getSpecialSpcRects() { return specialSpacingRects; }
bool hasPolyCornerAt(frCoord x, frCoord y, frLayerNum ln) const
{
for (auto& pin : pins_[ln]) {
for (auto& corners : pin->getPolygonCorners()) {
for (auto& corners : pin.getPolygonCorners()) {
for (auto& corner : corners) {
if (corner->x() == x && corner->y() == y) {
if (corner.x() == x && corner.y() == y) {
return true;
}
}
}
}
return false;
}
gcCorner* getPolyCornerAt(frCoord x, frCoord y, frLayerNum ln) const
gcCorner* getPolyCornerAt(frCoord x, frCoord y, frLayerNum ln)
{
for (auto& pin : pins_[ln]) {
for (auto& corners : pin->getPolygonCorners()) {
for (auto& corners : pin.getPolygonCorners()) {
for (auto& corner : corners) {
if (corner->x() == x && corner->y() == y) {
return corner.get();
if (corner.x() == x && corner.y() == y) {
return &corner;
}
}
}
Expand All @@ -259,13 +268,13 @@ class gcNet : public gcBlockObject
fixedRectangles_; // only cut layer
std::vector<std::vector<gtl::rectangle_data<frCoord>>>
routeRectangles_; // only cut layer
std::vector<std::vector<std::unique_ptr<gcPin>>> pins_;
std::vector<dynarray<gcPin>> pins_;
frBlockObject* owner_{nullptr};
std::vector<std::vector<Rect>> taperedRects; //(only routing layer)
std::vector<std::vector<Rect>> nonTaperedRects; //(only routing layer)
// A non-tapered rect within a tapered max rectangle still require nondefault
// spacing. This list hold these rectangles
std::vector<std::unique_ptr<gcRect>> specialSpacingRects;
std::vector<gcRect> specialSpacingRects;

void init();
};
Expand Down
38 changes: 20 additions & 18 deletions src/drt/src/db/gcObj/gcPin.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#pragma once

#include "db/dynarray.h"
#include "db/gcObj/gcShape.h"

namespace drt {
Expand All @@ -40,38 +41,39 @@ class gcPin : public gcBlockObject
gcPin(const gtl::polygon_90_with_holes_data<frCoord>& shapeIn,
frLayerNum layerNumIn,
gcNet* netIn)
: polygon_(std::make_unique<gcPolygon>(shapeIn, layerNumIn, this, netIn)),
net_(netIn)
: polygon_(shapeIn, layerNumIn, this, netIn), net_(netIn)
{
}
// setters
void setNet(gcNet* in) { net_ = in; }
void addPolygonEdges(std::vector<std::unique_ptr<gcSegment>>& in)
void addPolygonEdges(std::vector<gcSegment>&& in)
{
polygon_edges_.push_back(std::move(in));
}
void addPolygonCorners(std::vector<std::unique_ptr<gcCorner>>& in)
void addPolygonCorners(std::vector<gcCorner>&& in)
{
polygon_corners_.push_back(std::move(in));
}
void addMaxRectangle(std::unique_ptr<gcRect> in)
{
max_rectangles_.push_back(std::move(in));
}
void addMaxRectangle(const gcRect& in) { max_rectangles_.push_back(in); }

// getters
gcPolygon* getPolygon() const { return polygon_.get(); }
const std::vector<std::vector<std::unique_ptr<gcSegment>>>& getPolygonEdges()
const
gcPolygon* getPolygon() { return &polygon_; }
const gcPolygon* getPolygon() const { return &polygon_; }
std::vector<dynarray<gcSegment>>& getPolygonEdges() { return polygon_edges_; }
const std::vector<dynarray<gcSegment>>& getPolygonEdges() const
{
return polygon_edges_;
}
const std::vector<std::vector<std::unique_ptr<gcCorner>>>& getPolygonCorners()
const
std::vector<dynarray<gcCorner>>& getPolygonCorners()
{
return polygon_corners_;
}
const std::vector<dynarray<gcCorner>>& getPolygonCorners() const
{
return polygon_corners_;
}
const std::vector<std::unique_ptr<gcRect>>& getMaxRectangles() const
std::vector<gcRect>& getMaxRectangles() { return max_rectangles_; }
const std::vector<gcRect>& getMaxRectangles() const
{
return max_rectangles_;
}
Expand All @@ -81,11 +83,11 @@ class gcPin : public gcBlockObject
frBlockObjectEnum typeId() const override { return gccPin; }

private:
std::unique_ptr<gcPolygon> polygon_;
gcPolygon polygon_;
gcNet* net_{nullptr};
// assisting structures
std::vector<std::vector<std::unique_ptr<gcSegment>>> polygon_edges_;
std::vector<std::vector<std::unique_ptr<gcCorner>>> polygon_corners_;
std::vector<std::unique_ptr<gcRect>> max_rectangles_;
std::vector<dynarray<gcSegment>> polygon_edges_;
std::vector<dynarray<gcCorner>> polygon_corners_;
std::vector<gcRect> max_rectangles_;
};
} // namespace drt
28 changes: 14 additions & 14 deletions src/drt/src/dr/FlexDR_maze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2103,27 +2103,27 @@ void FlexDRWorker::modEolCosts_poly(gcPin* shape,
}
for (auto& edges : shape->getPolygonEdges()) {
for (auto& edge : edges) {
if (edge->length() >= eol.eolWidth) {
if (edge.length() >= eol.eolWidth) {
continue;
}
frCoord low, high, line;
bool innerDirIsIncreasing; // x: increases to the east, y: increases to
// the north
if (edge->isVertical()) {
low = std::min(edge->low().y(), edge->high().y());
high = std::max(edge->low().y(), edge->high().y());
line = edge->low().x();
innerDirIsIncreasing = edge->getInnerDir() == frDirEnum::E;
if (edge.isVertical()) {
low = std::min(edge.low().y(), edge.high().y());
high = std::max(edge.low().y(), edge.high().y());
line = edge.low().x();
innerDirIsIncreasing = edge.getInnerDir() == frDirEnum::E;
} else {
low = std::min(edge->low().x(), edge->high().x());
high = std::max(edge->low().x(), edge->high().x());
line = edge->low().y();
innerDirIsIncreasing = edge->getInnerDir() == frDirEnum::N;
low = std::min(edge.low().x(), edge.high().x());
high = std::max(edge.low().x(), edge.high().x());
line = edge.low().y();
innerDirIsIncreasing = edge.getInnerDir() == frDirEnum::N;
}
modEolCost(low,
high,
line,
edge->isVertical(),
edge.isVertical(),
innerDirIsIncreasing,
layer,
modType);
Expand Down Expand Up @@ -2182,12 +2182,12 @@ void FlexDRWorker::cleanUnneededPatches_poly(gcNet* drcNet, drNet* net)
}
for (int i = 0; i < drcNet->getPins(lNum).size(); i++) {
auto& pin = drcNet->getPins(lNum)[i];
if (!gtl::contains(*pin->getPolygon(), pt)) {
if (!gtl::contains(*pin.getPolygon(), pt)) {
continue;
}
frCoord area;
if (areaMap[lNum][i] == -1) {
areaMap[lNum][i] = gtl::area(*pin->getPolygon());
areaMap[lNum][i] = gtl::area(*pin.getPolygon());
}
area = areaMap[lNum][i];
if (area - patch->getOffsetBox().area() >= minArea) {
Expand All @@ -2212,7 +2212,7 @@ void FlexDRWorker::modEolCosts_poly(gcNet* net, ModCostType modType)
continue;
}
for (auto& pin : net->getPins(lNum)) {
modEolCosts_poly(pin.get(), layer, modType);
modEolCosts_poly(&pin, layer, modType);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/drt/src/gc/FlexGC_cut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,8 @@ void FlexGCWorker::Impl::checkMetalWidthViaTable()
continue;
}
for (auto& pin : targetNet_->getPins(i)) {
for (auto& maxrect : pin->getMaxRectangles()) {
checkMetalWidthViaTable_main(maxrect.get());
for (auto& maxrect : pin.getMaxRectangles()) {
checkMetalWidthViaTable_main(&maxrect);
}
}
}
Expand All @@ -682,8 +682,8 @@ void FlexGCWorker::Impl::checkMetalWidthViaTable()
continue;
}
for (auto& pin : net->getPins(i)) {
for (auto& maxrect : pin->getMaxRectangles()) {
checkMetalWidthViaTable_main(maxrect.get());
for (auto& maxrect : pin.getMaxRectangles()) {
checkMetalWidthViaTable_main(&maxrect);
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/drt/src/gc/FlexGC_eol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ void FlexGCWorker::Impl::checkMetalEndOfLine_main(gcPin* pin)
for (auto& edge : edges) {
if (ignoreLongSideEOL_
&& layer->getLayerNum() > 2 /* above the 1st metal layer */) {
switch (edge->getDir()) {
switch (edge.getDir()) {
case frDirEnum::N:
case frDirEnum::S:
if (isVertical) {
Expand All @@ -1317,16 +1317,16 @@ void FlexGCWorker::Impl::checkMetalEndOfLine_main(gcPin* pin)
}

for (auto con : cons) {
checkMetalEndOfLine_eol(edge.get(), con);
checkMetalEndOfLine_eol(&edge, con);
}
for (auto con : lef58Cons) {
checkMetalEndOfLine_eol(edge.get(), con);
checkMetalEndOfLine_eol(&edge, con);
}
for (auto con : keepoutCons) {
checkMetalEOLkeepout_main(edge.get(), con);
checkMetalEOLkeepout_main(&edge, con);
}
for (auto con : extCons) {
checkMetalEndOfLine_ext(edge.get(), con);
checkMetalEndOfLine_ext(&edge, con);
}
}
}
Expand All @@ -1346,7 +1346,7 @@ void FlexGCWorker::Impl::checkMetalEndOfLine()
continue;
}
for (auto& pin : targetNet_->getPins(i)) {
checkMetalEndOfLine_main(pin.get());
checkMetalEndOfLine_main(&pin);
}
}
} else {
Expand All @@ -1362,7 +1362,7 @@ void FlexGCWorker::Impl::checkMetalEndOfLine()
}
for (auto& net : getNets()) {
for (auto& pin : net->getPins(i)) {
checkMetalEndOfLine_main(pin.get());
checkMetalEndOfLine_main(&pin);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/drt/src/gc/FlexGC_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ class FlexGCWorker::Impl
void initDRWorker();
void initNets();
void initNet(gcNet* net);
void initNet_pins_polygon(gcNet* net);
void initNet_pins_polygonEdges(gcNet* net);
void initNet_pins_polygonEdges_getFixedPolygonEdges(
gcNet* net,
Expand Down
Loading
Loading