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 1 commit 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
52 changes: 52 additions & 0 deletions src/drt/src/db/Arena.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2025, The Regents of the University of California
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the University nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

#include <vector>

template <typename T>
struct Arena
{
static const auto BLOCK_SIZE = (std::size_t) 64 * 1024;

Arena() = default;
Arena(const Arena&) = delete;

template <typename... Args>
T* make(Args&&... args)
{
if (data_.empty() || data_.back().size() == data_.back().capacity()) {
data_.push_back({});
data_.back().reserve(BLOCK_SIZE / sizeof(T));
}
data_.back().emplace_back(std::forward<Args>(args)...);
return &data_.back().back();
}

std::vector<std::vector<T>> data_;
};
38 changes: 20 additions & 18 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/Arena.h"
#include "db/gcObj/gcBlockObject.h"
#include "db/gcObj/gcPin.h"
#include "db/obj/frBlockage.h"
Expand Down Expand Up @@ -74,22 +75,25 @@ class gcNet : public gcBlockObject
routeRectangles_[layerNum].push_back(rect);
}
}
void addPin(const gtl::polygon_90_with_holes_data<frCoord>& shape,
void addPin(Arena<gcPin>& pinArena,
const gtl::polygon_90_with_holes_data<frCoord>& shape,
frLayerNum layerNum)
{
auto pin = std::make_unique<gcPin>(shape, layerNum, this);
auto pin = pinArena.make(shape, layerNum, this);
pin->setId(pins_[layerNum].size());
pins_[layerNum].push_back(std::move(pin));
pins_[layerNum].push_back(pin);
}
void addPin(const gtl::rectangle_data<frCoord>& rect, frLayerNum layerNum)
void addPin(Arena<gcPin>& pinArena,
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);
auto pin = pinArena.make(shape, layerNum, this);
pin->setId(pins_[layerNum].size());
pins_[layerNum].push_back(std::move(pin));
pins_[layerNum].push_back(pin);
}
void setOwner(frBlockObject* in) { owner_ = in; }
void clear()
Expand Down Expand Up @@ -143,11 +147,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
const std::vector<std::vector<gcPin*>>& getPins() const { return pins_; }
const std::vector<gcPin*>& getPins(frLayerNum layerNum) const
{
return pins_[layerNum];
}
Expand Down Expand Up @@ -207,19 +208,20 @@ class gcNet : public gcBlockObject
{
return nonTaperedRects[z];
}
void addSpecialSpcRect(const Rect& bx,
void addSpecialSpcRect(Arena<gcRect>& rectArena,
const Rect& bx,
frLayerNum lNum,
gcPin* pin,
gcNet* net)
{
std::unique_ptr<gcRect> sp = std::make_unique<gcRect>();
gcRect* sp = rectArena.make();
sp->setLayerNum(lNum);
sp->addToNet(net);
sp->addToPin(pin);
sp->setRect(bx);
specialSpacingRects.push_back(std::move(sp));
specialSpacingRects.push_back(sp);
}
const std::vector<std::unique_ptr<gcRect>>& getSpecialSpcRects() const
const std::vector<gcRect*>& getSpecialSpcRects() const
{
return specialSpacingRects;
}
Expand All @@ -242,7 +244,7 @@ class gcNet : public gcBlockObject
for (auto& corners : pin->getPolygonCorners()) {
for (auto& corner : corners) {
if (corner->x() == x && corner->y() == y) {
return corner.get();
return corner;
}
}
}
Expand All @@ -259,13 +261,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<std::vector<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
36 changes: 15 additions & 21 deletions src/drt/src/db/gcObj/gcPin.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,42 +36,36 @@ class gcPin : public gcBlockObject
{
public:
// constructors
gcPin() = default;
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));
polygon_edges_.push_back(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));
polygon_corners_.push_back(in);
}
void addMaxRectangle(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_; }
const std::vector<std::vector<gcSegment*>>& getPolygonEdges() const
{
return polygon_edges_;
}
const std::vector<std::vector<std::unique_ptr<gcCorner>>>& getPolygonCorners()
const
const std::vector<std::vector<gcCorner*>>& getPolygonCorners() const
{
return polygon_corners_;
}
const std::vector<std::unique_ptr<gcRect>>& getMaxRectangles() const
const std::vector<gcRect*>& getMaxRectangles() const
{
return max_rectangles_;
}
Expand All @@ -81,11 +75,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<std::vector<gcSegment*>> polygon_edges_;
std::vector<std::vector<gcCorner*>> polygon_corners_;
std::vector<gcRect*> max_rectangles_;
};
} // namespace drt
4 changes: 2 additions & 2 deletions src/drt/src/dr/FlexDR_maze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2207,8 +2207,8 @@ void FlexDRWorker::modEolCosts_poly(gcNet* net, ModCostType modType)
if (layer->getType() != dbTechLayerType::ROUTING) {
continue;
}
for (auto& pin : net->getPins(lNum)) {
modEolCosts_poly(pin.get(), layer, modType);
for (auto pin : net->getPins(lNum)) {
modEolCosts_poly(pin, layer, modType);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/drt/src/gc/FlexGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ FlexGCWorker::FlexGCWorker(frTechObject* techIn,
RouterConfiguration* router_cfg,
FlexDRWorker* drWorkerIn)
: impl_(
std::make_unique<Impl>(techIn, logger, router_cfg, drWorkerIn, this))
std::make_unique<Impl>(techIn, logger, router_cfg, drWorkerIn, this))
{
}

Expand Down Expand Up @@ -200,7 +200,7 @@ void FlexGCWorker::setIgnoreLongSideEOL()
impl_->ignoreLongSideEOL_ = true;
}

std::vector<std::unique_ptr<gcNet>>& FlexGCWorker::getNets()
std::vector<gcNet*>& FlexGCWorker::getNets()
{
return impl_->getNets();
}
Expand Down
3 changes: 2 additions & 1 deletion src/drt/src/gc/FlexGC.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <memory>

#include "db/Arena.h"
#include "frDesign.h"

namespace drt {
Expand Down Expand Up @@ -63,7 +64,7 @@ class FlexGCWorker
void setEnableSurgicalFix(bool in);
void addPAObj(frConnFig* obj, frBlockObject* owner);
// getters
std::vector<std::unique_ptr<gcNet>>& getNets();
std::vector<gcNet*>& getNets();
gcNet* getNet(frNet* net);
frDesign* getDesign() const;
const std::vector<std::unique_ptr<frMarker>>& getMarkers() const;
Expand Down
14 changes: 7 additions & 7 deletions src/drt/src/gc/FlexGC_cut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,9 @@ void FlexGCWorker::Impl::checkMetalWidthViaTable()
if (currLayer->getType() != dbTechLayerType::CUT) {
continue;
}
for (auto& pin : targetNet_->getPins(i)) {
for (auto& maxrect : pin->getMaxRectangles()) {
checkMetalWidthViaTable_main(maxrect.get());
for (auto pin : targetNet_->getPins(i)) {
for (auto maxrect : pin->getMaxRectangles()) {
checkMetalWidthViaTable_main(maxrect);
}
}
}
Expand All @@ -677,15 +677,15 @@ void FlexGCWorker::Impl::checkMetalWidthViaTable()
if (currLayer->getType() != dbTechLayerType::CUT) {
continue;
}
for (auto& net : getNets()) {
for (auto net : getNets()) {
// There is no need to check vias in nets we don't route
auto fr_net = net->getFrNet();
if (fr_net && (fr_net->isSpecial() || fr_net->getType().isSupply())) {
continue;
}
for (auto& pin : net->getPins(i)) {
for (auto& maxrect : pin->getMaxRectangles()) {
checkMetalWidthViaTable_main(maxrect.get());
for (auto pin : net->getPins(i)) {
for (auto maxrect : pin->getMaxRectangles()) {
checkMetalWidthViaTable_main(maxrect);
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/drt/src/gc/FlexGC_eol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ void FlexGCWorker::Impl::checkMetalEndOfLine_main(gcPin* pin)
bool isVertical = layer->isVertical();

for (auto& edges : pin->getPolygonEdges()) {
for (auto& edge : edges) {
for (auto edge : edges) {
if (ignoreLongSideEOL_
&& layer->getLayerNum() > 2 /* above the 1st metal layer */) {
switch (edge->getDir()) {
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 @@ -1345,8 +1345,8 @@ void FlexGCWorker::Impl::checkMetalEndOfLine()
if (currLayer->getType() != dbTechLayerType::ROUTING) {
continue;
}
for (auto& pin : targetNet_->getPins(i)) {
checkMetalEndOfLine_main(pin.get());
for (auto pin : targetNet_->getPins(i)) {
checkMetalEndOfLine_main(pin);
}
}
} else {
Expand All @@ -1360,9 +1360,9 @@ void FlexGCWorker::Impl::checkMetalEndOfLine()
if (currLayer->getType() != dbTechLayerType::ROUTING) {
continue;
}
for (auto& net : getNets()) {
for (auto& pin : net->getPins(i)) {
checkMetalEndOfLine_main(pin.get());
for (auto net : getNets()) {
for (auto pin : net->getPins(i)) {
checkMetalEndOfLine_main(pin);
}
}
}
Expand Down
Loading
Loading