diff --git a/src/drt/src/TritonRoute.cpp b/src/drt/src/TritonRoute.cpp index 45d8298ecd8..5294796f080 100644 --- a/src/drt/src/TritonRoute.cpp +++ b/src/drt/src/TritonRoute.cpp @@ -213,9 +213,10 @@ std::string TritonRoute::runDRWorker(const std::string& workerStr, { bool on = debug_->debugDR; std::unique_ptr graphics_ - = on && FlexDRGraphics::guiActive() ? std::make_unique( - debug_.get(), design_.get(), db_, logger_) - : nullptr; + = on && FlexDRGraphics::guiActive() + ? std::make_unique( + debug_.get(), design_.get(), db_, logger_) + : nullptr; auto worker = FlexDRWorker::load(workerStr, logger_, design_.get(), graphics_.get()); worker->setViaData(viaData); @@ -243,9 +244,10 @@ void TritonRoute::debugSingleWorker(const std::string& dumpDir, ar >> viaData; std::unique_ptr graphics_ - = on && FlexDRGraphics::guiActive() ? std::make_unique( - debug_.get(), design_.get(), db_, logger_) - : nullptr; + = on && FlexDRGraphics::guiActive() + ? std::make_unique( + debug_.get(), design_.get(), db_, logger_) + : nullptr; std::ifstream workerFile(fmt::format("{}/worker.bin", dumpDir), std::ios::binary); std::string workerStr((std::istreambuf_iterator(workerFile)), @@ -744,7 +746,7 @@ void TritonRoute::repairPDNVias() } const RTree> pdnBlockViaTree(block_vias); - std::set> removedBoxes; + boost::container::flat_set> removedBoxes; for (const auto& marker : markers) { odb::Rect queryBox; marker->getBBox().bloat(1, queryBox); @@ -1088,7 +1090,7 @@ void TritonRoute::getDRCMarkers(frList>& markers, workersBatches.back().push_back(std::move(gcWorker)); } } - std::map mapMarkers; + boost::container::flat_map mapMarkers; omp_set_num_threads(MAX_THREADS); for (auto& workers : workersBatches) { #pragma omp parallel for schedule(dynamic) @@ -1180,7 +1182,7 @@ void TritonRoute::stackVias(odb::dbBTerm* bterm, odb::dbTech* tech = db_->getTech(); auto fr_tech = getDesign()->getTech(); - std::map default_vias; + boost::container::flat_map default_vias; for (auto layer : tech->getLayers()) { if (layer->getType() == odb::dbTechLayerType::CUT) { @@ -1271,7 +1273,7 @@ bool TritonRoute::netHasStackedVias(odb::dbNet* net) odb::dbWire* wire = net->getWire(); odb::dbWirePathItr pitr; - std::set via_points; + boost::container::flat_set via_points; for (pitr.begin(wire); pitr.getNextPath(path);) { while (pitr.getNextShape(pshape)) { via_points.insert(path.point); diff --git a/src/drt/src/db/drObj/drMarker.h b/src/drt/src/db/drObj/drMarker.h index 58707832548..b9cc7c5f078 100644 --- a/src/drt/src/db/drObj/drMarker.h +++ b/src/drt/src/db/drObj/drMarker.h @@ -28,6 +28,9 @@ #pragma once +#include +#include + #include "db/drObj/drBlockObject.h" namespace drt { @@ -66,7 +69,10 @@ class drMazeMarker : public drBlockObject // getters frConstraint* getConstraint() const { return constraint_; } drNet* getTrigNet() const { return trigNets_.cbegin()->first; } - const std::map& getTrigNets() const { return trigNets_; } + const boost::container::flat_map& getTrigNets() const + { + return trigNets_; + } int getCnt() const { return cnt_; } // others frBlockObjectEnum typeId() const override { return drcMazeMarker; } @@ -77,7 +83,7 @@ class drMazeMarker : public drBlockObject private: frConstraint* constraint_{nullptr}; - std::map trigNets_; + boost::container::flat_map trigNets_; int cnt_{0}; template diff --git a/src/drt/src/db/grObj/grNet.h b/src/drt/src/db/grObj/grNet.h index aeadf40ac2d..6a40310b831 100644 --- a/src/drt/src/db/grObj/grNet.h +++ b/src/drt/src/db/grObj/grNet.h @@ -28,6 +28,8 @@ #pragma once +#include +#include #include #include "db/grObj/grBlockObject.h" @@ -73,12 +75,13 @@ class grNet : public grBlockObject { return pinGCellNodePairs; } - const std::map, frBlockObjectComp>& - getGCell2PinNodes() const + const boost::container:: + flat_map, frBlockObjectComp>& + getGCell2PinNodes() const { return gcell2PinNodes; } - std::map, frBlockObjectComp>& + boost::container::flat_map, frBlockObjectComp>& getGCell2PinNodes() { return gcell2PinNodes; @@ -93,11 +96,13 @@ class grNet : public grBlockObject { return pinNodePairs; } - const std::map& getGR2FrPinNode() const + const boost::container::flat_map& + getGR2FrPinNode() const { return gr2FrPinNode; } - std::map& getGR2FrPinNode() + boost::container::flat_map& + getGR2FrPinNode() { return gr2FrPinNode; } @@ -146,7 +151,8 @@ class grNet : public grBlockObject pinGCellNodePairs = in; } void setGCell2PinNodes( - const std::map, frBlockObjectComp>& in) + const boost::container:: + flat_map, frBlockObjectComp>& in) { gcell2PinNodes = in; } @@ -155,7 +161,8 @@ class grNet : public grBlockObject { pinNodePairs = in; } - void setGR2FrPinNode(const std::map& in) + void setGR2FrPinNode( + const boost::container::flat_map& in) { gr2FrPinNode = in; } @@ -214,12 +221,13 @@ class grNet : public grBlockObject // pair of with first (0th) element always being root std::vector> pinGCellNodePairs; - std::map, frBlockObjectComp> gcell2PinNodes; + boost::container::flat_map, frBlockObjectComp> + gcell2PinNodes; // unique, first (0th) element always being root std::vector pinGCellNodes; std::vector> pinNodePairs; - std::map gr2FrPinNode; - // std::set fNetTerms; + boost::container::flat_map gr2FrPinNode; + // boost::container::flat_set fNetTerms; std::list> nodes; grNode* root{nullptr}; frNet* fNet{nullptr}; diff --git a/src/drt/src/db/obj/frBlock.h b/src/drt/src/db/obj/frBlock.h index 120e072c7ab..72652247f25 100644 --- a/src/drt/src/db/obj/frBlock.h +++ b/src/drt/src/db/obj/frBlock.h @@ -29,6 +29,8 @@ #pragma once #include +#include +#include #include #include "db/obj/frBTerm.h" @@ -409,16 +411,16 @@ class frBlock : public frBlockObject frString name_; frUInt4 dbUnit_{0}; - std::map name2inst_; + boost::container::flat_map name2inst_; std::vector> insts_; - std::map name2term_; + boost::container::flat_map name2term_; std::vector> terms_; - std::map name2net_; + boost::container::flat_map name2net_; std::vector> nets_; - std::map name2snet_; + boost::container::flat_map name2snet_; std::vector> snets_; std::vector> blockages_; diff --git a/src/drt/src/db/obj/frBlockObject.h b/src/drt/src/db/obj/frBlockObject.h index 5a0fbe7e8f8..0be0467931c 100644 --- a/src/drt/src/db/obj/frBlockObject.h +++ b/src/drt/src/db/obj/frBlockObject.h @@ -66,7 +66,9 @@ struct frBlockObjectComp } }; -using frBlockObjectSet = std::set; +using frBlockObjectSet + = boost::container::flat_set; template -using frBlockObjectMap = std::map; +using frBlockObjectMap + = boost::container::flat_map; } // namespace drt diff --git a/src/drt/src/db/obj/frMarker.h b/src/drt/src/db/obj/frMarker.h index 931410954a7..579d66e4f88 100644 --- a/src/drt/src/db/obj/frMarker.h +++ b/src/drt/src/db/obj/frMarker.h @@ -28,6 +28,8 @@ #pragma once +#include +#include #include #include @@ -82,9 +84,15 @@ class frMarker : public frFig Rect getBBox() const override { return bbox_; } frLayerNum getLayerNum() const { return layerNum_; } - const std::set& getSrcs() const { return srcs_; } + const boost::container::flat_set& getSrcs() const + { + return srcs_; + } - void setSrcs(const std::set& srcs) { srcs_ = srcs; } + void setSrcs(const boost::container::flat_set& srcs) + { + srcs_ = srcs; + } std::vector>>& getAggressors() @@ -120,7 +128,7 @@ class frMarker : public frFig frConstraint* constraint_{nullptr}; Rect bbox_; frLayerNum layerNum_{0}; - std::set srcs_; + boost::container::flat_set srcs_; std::vector>> victims_; // obj, isFixed std::vector>> diff --git a/src/drt/src/db/tech/frConstraint.h b/src/drt/src/db/tech/frConstraint.h index 1e46a16f756..89345377a1d 100644 --- a/src/drt/src/db/tech/frConstraint.h +++ b/src/drt/src/db/tech/frConstraint.h @@ -29,6 +29,8 @@ #pragma once #include +#include +#include #include #include #include @@ -115,7 +117,8 @@ class frLef58CutClassConstraint : public frConstraint } private: - std::map> cutClasses_; + boost::container::flat_map> + cutClasses_; friend class io::Parser; }; @@ -1346,7 +1349,7 @@ class frLef58SpacingTableConstraint : public frSpacingTableConstraint frLef58SpacingTableConstraint( const std::shared_ptr>& parallelRunLengthConstraintIn, - const std::map>& + const boost::container::flat_map>& exceptWithinConstraintIn) : frSpacingTableConstraint(parallelRunLengthConstraintIn), exceptWithinConstraint_(exceptWithinConstraintIn) @@ -1370,7 +1373,8 @@ class frLef58SpacingTableConstraint : public frSpacingTableConstraint frUInt4 getEolWidth() const { return eolWidth_; } // setters void setExceptWithinConstraint( - std::map>& exceptWithinConstraintIn) + boost::container::flat_map>& + exceptWithinConstraintIn) { exceptWithinConstraint_ = exceptWithinConstraintIn; } @@ -1402,7 +1406,8 @@ class frLef58SpacingTableConstraint : public frSpacingTableConstraint } protected: - std::map> exceptWithinConstraint_; + boost::container::flat_map> + exceptWithinConstraint_; bool wrongDirection_{false}; bool sameMask_{false}; bool exceptEol_{false}; diff --git a/src/drt/src/db/tech/frLayer.h b/src/drt/src/db/tech/frLayer.h index bb1d24fe16c..27d7611d959 100644 --- a/src/drt/src/db/tech/frLayer.h +++ b/src/drt/src/db/tech/frLayer.h @@ -134,7 +134,7 @@ class frLayer return secondaryViaDefs_.at(idx); } bool hasVia2ViaMinStepViol() { return hasMinStepViol_; } - std::set getViaDefs() const { return viaDefs_; } + boost::container::flat_set getViaDefs() const { return viaDefs_; } dbTechLayerType getType() const { if (fakeCut_) { @@ -413,7 +413,7 @@ class frLayer } return interLayerCutSpacingSamenetConstraints_; } - const std::map& + const boost::container::flat_map& getInterLayerCutSpacingConstraintMap(bool samenet = false) const { if (!samenet) { @@ -746,17 +746,17 @@ class frLayer void addLef58EnclosureConstraint(frLef58EnclosureConstraint* con) { - auto addToLef58EncConstraints - = [](std::vector< - std::map>>& - lef58EncConstraints, - frLef58EnclosureConstraint* con) { - int cutClassIdx = con->getCutClassIdx(); - if (lef58EncConstraints.size() <= cutClassIdx) { - lef58EncConstraints.resize(cutClassIdx + 1); - } - lef58EncConstraints[cutClassIdx][con->getWidth()].push_back(con); - }; + auto addToLef58EncConstraints = + [](std::vector>>& lef58EncConstraints, + frLef58EnclosureConstraint* con) { + int cutClassIdx = con->getCutClassIdx(); + if (lef58EncConstraints.size() <= cutClassIdx) { + lef58EncConstraints.resize(cutClassIdx + 1); + } + lef58EncConstraints[cutClassIdx][con->getWidth()].push_back(con); + }; if (!con->isAboveOnly()) { addToLef58EncConstraints(con->isEol() ? belowLef58EncEolConstraints_ : belowLef58EncConstraints_, @@ -833,9 +833,9 @@ class frLayer std::vector secondaryViaDefs_; bool hasMinStepViol_{false}; bool unidirectional_{false}; - std::set viaDefs_; + boost::container::flat_set viaDefs_; std::vector cutClasses_; - std::map name2CutClassIdxMap_; + boost::container::flat_map name2CutClassIdxMap_; frCollection constraints_; frCollection @@ -856,9 +856,9 @@ class frLayer // vector.size() == layers.size() std::vector interLayerCutSpacingSamenetConstraints_; // temp storage for inter-layer cut spacing before postProcess - std::map + boost::container::flat_map interLayerCutSpacingConstraintsMap_; - std::map + boost::container::flat_map interLayerCutSpacingSamenetConstraintsMap_; std::vector lef58CutSpacingConstraints_; @@ -901,13 +901,17 @@ class frLayer std::vector twForbiddenSpcConstraints_; std::vector forbiddenSpcConstraints_; - std::vector>> + std::vector>> aboveLef58EncConstraints_; - std::vector>> + std::vector>> belowLef58EncConstraints_; - std::vector>> + std::vector>> aboveLef58EncEolConstraints_; - std::vector>> + std::vector>> belowLef58EncEolConstraints_; // vector of maxspacing constraints std::vector maxSpacingConstraints_; diff --git a/src/drt/src/db/tech/frTechObject.h b/src/drt/src/db/tech/frTechObject.h index ddce61ec645..f1b4c81a1c1 100644 --- a/src/drt/src/db/tech/frTechObject.h +++ b/src/drt/src/db/tech/frTechObject.h @@ -349,16 +349,18 @@ class frTechObject frUInt4 dbUnit_{0}; frUInt4 manufacturingGrid_{0}; - std::map name2layer_; + boost::container::flat_map name2layer_; std::vector> layers_; - std::map name2via_; + boost::container::flat_map name2via_; std::vector> vias_; - std::vector> layer2Name2CutClass_; + std::vector> + layer2Name2CutClass_; std::vector>> layerCutClass_; - std::map name2viaRuleGenerate_; + boost::container::flat_map + name2viaRuleGenerate_; std::vector> viaRuleGenerates_; std::vector> uConstraints_; @@ -421,7 +423,7 @@ class frTechObject bool hasVia2viaMinStep_ = false; bool hasCornerSpacingConstraint_ = false; // unidirectional layers - std::set unidirectional_layers_; + boost::container::flat_set unidirectional_layers_; friend class FlexRP; }; diff --git a/src/drt/src/dr/FlexDR.cpp b/src/drt/src/dr/FlexDR.cpp index 6d1d1d6c522..33d407f82cc 100644 --- a/src/drt/src/dr/FlexDR.cpp +++ b/src/drt/src/dr/FlexDR.cpp @@ -354,14 +354,14 @@ void FlexDR::initGCell2BoundaryPin() auto gCellPatterns = topBlock->getGCellPatterns(); auto& xgp = gCellPatterns.at(0); auto& ygp = gCellPatterns.at(1); - auto tmpVec = std::vector>, - frBlockObjectComp>>((int) ygp.getCount()); - gcell2BoundaryPin_ - = std::vector>, - frBlockObjectComp>>>( - (int) xgp.getCount(), tmpVec); + auto tmpVec = std::vector>, + frBlockObjectComp>>((int) ygp.getCount()); + gcell2BoundaryPin_ = std::vector>, + frBlockObjectComp>>>((int) xgp.getCount(), tmpVec); for (auto& net : topBlock->getNets()) { auto netPtr = net.get(); for (auto& guide : net->getGuides()) { @@ -526,13 +526,19 @@ void FlexDR::removeGCell2BoundaryPin() gcell2BoundaryPin_.shrink_to_fit(); } -std::map>, frBlockObjectComp> +boost::container::flat_map< + frNet*, + boost::container::flat_set>, + frBlockObjectComp> FlexDR::initDR_mergeBoundaryPin(int startX, int startY, int size, const Rect& routeBox) { - std::map>, frBlockObjectComp> + boost::container::flat_map< + frNet*, + boost::container::flat_set>, + frBlockObjectComp> bp; auto gCellPatterns = getDesign()->getTopBlock()->getGCellPatterns(); auto& xgp = gCellPatterns.at(0); @@ -826,9 +832,11 @@ void FlexDR::searchRepair(const SearchRepairArgs& args) getDesign()->getTopBlock()->getNumMarkers()); if (getDesign()->getTopBlock()->getNumMarkers() > 0) { // report violations - std::map> violations; - std::set layers; - const std::map relabel + boost::container::flat_map> + violations; + boost::container::flat_set layers; + const boost::container::flat_map relabel = {{"Lef58SpacingEndOfLine", "EOL"}, {"Lef58CutSpacingTable", "CutSpcTbl"}, {"Lef58EolKeepOut", "eolKeepOut"}}; @@ -1128,7 +1136,7 @@ void FlexDR::reportGuideCoverage() const auto numLayers = getTech()->getLayers().size(); std::vector totalAreaByLayerNum(numLayers, 0); std::vector totalCoveredAreaByLayerNum(numLayers, 0); - std::map> netsCoverage; + boost::container::flat_map> netsCoverage; const auto& nets = getDesign()->getTopBlock()->getNets(); omp_set_num_threads(MAX_THREADS); #pragma omp parallel for schedule(dynamic) @@ -1348,7 +1356,7 @@ std::vector FlexDR::getLonelyVias(frLayer* layer, KDTree tree(via_positions); std::vector visited(via_positions.size()); std::fill(visited.begin(), visited.end(), false); - std::set isolated_via_nodes; + boost::container::flat_set isolated_via_nodes; omp_set_num_threads(ord::OpenRoad::openRoad()->getThreadCount()); #pragma omp parallel for schedule(dynamic) for (int i = 0; i < via_positions.size(); i++) { @@ -1553,8 +1561,8 @@ void FlexDRWorker::serialize(Archive& ar, const unsigned int version) while (sz--) { frBlockObject* obj; serializeBlockObject(ar, obj); - std::set> val; - (ar) & val; + boost::container::flat_set> val; + // (ar) & val; TODO boundaryPin_[(frNet*) obj] = std::move(val); } // owner2nets_ @@ -1569,7 +1577,7 @@ void FlexDRWorker::serialize(Archive& ar, const unsigned int version) for (auto& [net, value] : boundaryPin_) { frBlockObject* obj = (frBlockObject*) net; serializeBlockObject(ar, obj); - (ar) & value; + // (ar) & value; TODO } } } diff --git a/src/drt/src/dr/FlexDR.h b/src/drt/src/dr/FlexDR.h index a49a57e5ca5..bc192d132e8 100644 --- a/src/drt/src/dr/FlexDR.h +++ b/src/drt/src/dr/FlexDR.h @@ -30,6 +30,8 @@ #include +#include +#include #include #include #include @@ -139,9 +141,10 @@ class FlexDR frDesign* design_; Logger* logger_; odb::dbDatabase* db_; - std::vector>, - frBlockObjectComp>>> + std::vector>, + frBlockObjectComp>>> gcell2BoundaryPin_; FlexDRViaData via_data_; @@ -169,7 +172,10 @@ class FlexDR void init_halfViaEncArea(); void removeGCell2BoundaryPin(); - std::map>, frBlockObjectComp> + boost::container::flat_map< + frNet*, + boost::container::flat_set>, + frBlockObjectComp> initDR_mergeBoundaryPin(int startX, int startY, int size, @@ -249,7 +255,8 @@ class FlexDRWorker ripupMode_(RipUpMode::ALL), workerDRCCost_(ROUTESHAPECOST), workerMarkerCost_(MARKERCOST), - historyMarkers_(std::vector>(3)), + historyMarkers_( + std::vector>(3)), gridGraph_(design->getTech(), logger, this), rq_(this) { @@ -270,17 +277,19 @@ class FlexDRWorker void setGCellBox(const Rect& boxIn) { gcellBox_ = boxIn; } void setDRIter(int in) { drIter_ = in; } void setDRIter(int in, - std::map>, - frBlockObjectComp>& bp) + boost::container::flat_map< + frNet*, + boost::container::flat_set>, + frBlockObjectComp>& bp) { drIter_ = in; boundaryPin_ = std::move(bp); } bool isCongested() const { return isCongested_; } - void setBoundaryPins(std::map>, - frBlockObjectComp>& bp) + void setBoundaryPins(boost::container::flat_map< + frNet*, + boost::container::flat_set>, + frBlockObjectComp>& bp) { boundaryPin_ = std::move(bp); } @@ -482,18 +491,21 @@ class FlexDRWorker frUInt4 workerFixedShapeCost_ = 0; float workerMarkerDecay_ = 0; // used in init route as gr boundary pin - std::map>, frBlockObjectComp> + boost::container::flat_map< + frNet*, + boost::container::flat_set>, + frBlockObjectComp> boundaryPin_; int pinCnt_ = 0; int initNumMarkers_ = 0; - std::map apSVia_; - std::set planarHistoryMarkers_; - std::set viaHistoryMarkers_; - std::vector> historyMarkers_; + boost::container::flat_map apSVia_; + boost::container::flat_set planarHistoryMarkers_; + boost::container::flat_set viaHistoryMarkers_; + std::vector> historyMarkers_; // local storage std::vector> nets_; - std::map> owner2nets_; + boost::container::flat_map> owner2nets_; FlexGridGraph gridGraph_; std::vector markers_; std::vector bestMarkers_; @@ -524,54 +536,63 @@ class FlexDRWorker void initRipUpNetsFromMarkers(); void initNetObjs( const frDesign* design, - std::set& nets, - std::map>, - frBlockObjectComp>& netRouteObjs, - std::map>, - frBlockObjectComp>& netExtObjs, - std::map, frBlockObjectComp>& netOrigGuides, - std::map, frBlockObjectComp>& netGuides); - void initNetObjs_pathSeg(frPathSeg* pathSeg, - std::set& nets, - std::map>, - frBlockObjectComp>& netRouteObjs, - std::map>, - frBlockObjectComp>& netExtObjs); - void initNetObjs_via(const frVia* via, - std::set& nets, - std::map>, - frBlockObjectComp>& netRouteObjs, - std::map>, - frBlockObjectComp>& netExtObjs); - void initNetObjs_patchWire(frPatchWire* pwire, - std::set& nets, - std::map>, - frBlockObjectComp>& netRouteObjs, - std::map>, - frBlockObjectComp>& netExtObjs); + boost::container::flat_set& nets, + boost::container::flat_map>, + frBlockObjectComp>& netRouteObjs, + boost::container::flat_map>, + frBlockObjectComp>& netExtObjs, + boost::container::flat_map, + frBlockObjectComp>& netOrigGuides, + boost::container:: + flat_map, frBlockObjectComp>& netGuides); + void initNetObjs_pathSeg( + frPathSeg* pathSeg, + boost::container::flat_set& nets, + boost::container::flat_map>, + frBlockObjectComp>& netRouteObjs, + boost::container::flat_map>, + frBlockObjectComp>& netExtObjs); + void initNetObjs_via( + const frVia* via, + boost::container::flat_set& nets, + boost::container::flat_map>, + frBlockObjectComp>& netRouteObjs, + boost::container::flat_map>, + frBlockObjectComp>& netExtObjs); + void initNetObjs_patchWire( + frPatchWire* pwire, + boost::container::flat_set& nets, + boost::container::flat_map>, + frBlockObjectComp>& netRouteObjs, + boost::container::flat_map>, + frBlockObjectComp>& netExtObjs); void initNets_segmentTerms(const Point& bp, frLayerNum lNum, const frNet* net, frBlockObjectSet& terms); void initNets_initDR( const frDesign* design, - std::set& nets, - std::map>, - frBlockObjectComp>& netRouteObjs, - std::map>, - frBlockObjectComp>& netExtObjs, - std::map, frBlockObjectComp>& netOrigGuides, - std::map, frBlockObjectComp>& netGuides); + boost::container::flat_set& nets, + boost::container::flat_map>, + frBlockObjectComp>& netRouteObjs, + boost::container::flat_map>, + frBlockObjectComp>& netExtObjs, + boost::container::flat_map, + frBlockObjectComp>& netOrigGuides, + boost::container:: + flat_map, frBlockObjectComp>& netGuides); int initNets_initDR_helper_getObjComponent( drConnFig* obj, const std::vector>& connectedComponents, @@ -586,63 +607,76 @@ class FlexDRWorker void initNets_searchRepair( const frDesign* design, - const std::set& nets, - std::map>, - frBlockObjectComp>& netRouteObjs, - std::map>, - frBlockObjectComp>& netExtObjs, - std::map, frBlockObjectComp>& netOrigGuides); + const boost::container::flat_set& nets, + boost::container::flat_map>, + frBlockObjectComp>& netRouteObjs, + boost::container::flat_map>, + frBlockObjectComp>& netExtObjs, + boost::container::flat_map, + frBlockObjectComp>& netOrigGuides); void initNets_searchRepair_pin2epMap( const frDesign* design, const frNet* net, const std::vector>& netRouteObjs, - std::map>, - frBlockObjectComp>& pin2epMap); + boost::container::flat_map< + frBlockObject*, + boost::container::flat_set>, + frBlockObjectComp>& pin2epMap); void initNets_searchRepair_pin2epMap_helper( const frDesign* design, const frNet* net, const Point& bp, frLayerNum lNum, - std::map>, - frBlockObjectComp>& pin2epMap); + boost::container::flat_map< + frBlockObject*, + boost::container::flat_set>, + frBlockObjectComp>& pin2epMap); void initNets_searchRepair_nodeMap( const std::vector>& netRouteObjs, std::vector& netPins, - const std::map>, - frBlockObjectComp>& pin2epMap, - std::map, std::set>& nodeMap); + const boost::container::flat_map< + frBlockObject*, + boost::container::flat_set>, + frBlockObjectComp>& pin2epMap, + boost::container::flat_map, + boost::container::flat_set>& nodeMap); void initNets_searchRepair_nodeMap_routeObjEnd( const std::vector>& netRouteObjs, - std::map, std::set>& nodeMap); + boost::container::flat_map, + boost::container::flat_set>& nodeMap); void initNets_searchRepair_nodeMap_routeObjSplit( const std::vector>& netRouteObjs, - std::map, std::set>& nodeMap); + boost::container::flat_map, + boost::container::flat_set>& nodeMap); void initNets_searchRepair_nodeMap_routeObjSplit_helper( const Point& crossPt, frCoord trackCoord, frCoord splitCoord, frLayerNum lNum, - std::vector< - std::map>>>& + std::vector>>>& mergeHelper, - std::map, std::set>& nodeMap); + boost::container::flat_map, + boost::container::flat_set>& nodeMap); void initNets_searchRepair_nodeMap_pin( const std::vector>& netRouteObjs, std::vector& netPins, - const std::map>, - frBlockObjectComp>& pin2epMap, - std::map, std::set>& nodeMap); + const boost::container::flat_map< + frBlockObject*, + boost::container::flat_set>, + frBlockObjectComp>& pin2epMap, + boost::container::flat_map, + boost::container::flat_set>& nodeMap); void initNets_searchRepair_connComp( frNet* net, - std::map, std::set>& nodeMap, + boost::container::flat_map, + boost::container::flat_set>& nodeMap, std::vector& compIdx); void initNet(const frDesign* design, @@ -670,12 +704,12 @@ class FlexDRWorker frLayerNum currLayerNum, frCoord low, frCoord high, - std::set& trackLocs); + boost::container::flat_set& trackLocs); bool findAPTracks(frLayerNum startLayerNum, frLayerNum endLayerNum, const Rectangle& pinRect, - std::set& xLocs, - std::set& yLocs); + boost::container::flat_set& xLocs, + boost::container::flat_set& yLocs); void initNet_boundary(drNet* net, const std::vector>& extObjs, std::vector> bounds); @@ -684,16 +718,28 @@ class FlexDRWorker void initGridGraph(const frDesign* design); void initTrackCoords( - std::map>& xMap, - std::map>& yMap); + boost::container::flat_map< + frCoord, + boost::container::flat_map>& xMap, + boost::container::flat_map< + frCoord, + boost::container::flat_map>& yMap); void initTrackCoords_route( drNet* net, - std::map>& xMap, - std::map>& yMap); + boost::container::flat_map< + frCoord, + boost::container::flat_map>& xMap, + boost::container::flat_map< + frCoord, + boost::container::flat_map>& yMap); void initTrackCoords_pin( drNet* net, - std::map>& xMap, - std::map>& yMap); + boost::container::flat_map< + frCoord, + boost::container::flat_map>& xMap, + boost::container::flat_map< + frCoord, + boost::container::flat_map>& yMap); void initMazeIdx(); void initMazeIdx_connFig(drConnFig* connFig); void initMazeIdx_ap(drAccessPattern* ap); @@ -748,13 +794,13 @@ class FlexDRWorker void route_queue_init_queue(std::queue& rerouteQueue); void route_queue_update_from_marker( frMarker* marker, - std::set& uniqueVictims, - std::set& uniqueAggressors, + boost::container::flat_set& uniqueVictims, + boost::container::flat_set& uniqueAggressors, std::vector& checks, std::vector& routes, frBlockObject* checkingObj); void getRipUpNetsFromMarker(frMarker* marker, - std::set& nets, + boost::container::flat_set& nets, frCoord bloatDist = 0); void route_queue_update_queue(const std::vector& checks, const std::vector& routes, @@ -884,19 +930,25 @@ class FlexDRWorker void mazeNetInit(drNet* net); void mazeNetEnd(drNet* net); bool routeNet(drNet* net, std::vector& paths); - void routeNet_prep(drNet* net, - std::set& unConnPins, - std::map>& - mazeIdx2unConnPins, - std::set& apMazeIdx, - std::set& realPinAPMazeIdx, - std::map& mazeIdx2TaperBox, - std::list>& pinTaperBoxes); - void routeNet_prepAreaMap(drNet* net, - std::map& areaMap); + void routeNet_prep( + drNet* net, + boost::container::flat_set& unConnPins, + boost::container::flat_map< + FlexMazeIdx, + boost::container::flat_set>& + mazeIdx2unConnPins, + boost::container::flat_set& apMazeIdx, + boost::container::flat_set& realPinAPMazeIdx, + boost::container::flat_map& mazeIdx2TaperBox, + std::list>& pinTaperBoxes); + void routeNet_prepAreaMap( + drNet* net, + boost::container::flat_map& areaMap); void routeNet_setSrc( - std::set& unConnPins, - std::map>& + boost::container::flat_set& unConnPins, + boost::container::flat_map< + FlexMazeIdx, + boost::container::flat_set>& mazeIdx2unConnPins, std::vector& connComps, FlexMazeIdx& ccMazeIdx1, @@ -906,22 +958,26 @@ class FlexDRWorker drPin* routeNet_getNextDst( FlexMazeIdx& ccMazeIdx1, FlexMazeIdx& ccMazeIdx2, - std::map>& + boost::container::flat_map< + FlexMazeIdx, + boost::container::flat_set>& mazeIdx2unConnPins, std::list>& pinTaperBoxes); void routeNet_postAstarUpdate( std::vector& path, std::vector& connComps, - std::set& unConnPins, - std::map>& + boost::container::flat_set& unConnPins, + boost::container::flat_map< + FlexMazeIdx, + boost::container::flat_set>& mazeIdx2unConnPins, bool isFirstConn); void routeNet_postAstarWritePath( drNet* net, std::vector& points, - const std::set& realPinApMazeIdx, - std::map& mazeIdx2Taperbox, - const std::set& apMazeIdx); + const boost::container::flat_set& realPinApMazeIdx, + boost::container::flat_map& mazeIdx2Taperbox, + const boost::container::flat_set& apMazeIdx); bool addApPathSegs(const FlexMazeIdx& apIdx, drNet* net); /** * Updates external figures to connect to access-point if needed. @@ -955,11 +1011,12 @@ class FlexDRWorker frMIdx z, FlexMazeIdx* prev, FlexMazeIdx* next); - bool isInsideTaperBox(frMIdx x, - frMIdx y, - frMIdx startZ, - frMIdx endZ, - std::map& mazeIdx2TaperBox); + bool isInsideTaperBox( + frMIdx x, + frMIdx y, + frMIdx startZ, + frMIdx endZ, + boost::container::flat_map& mazeIdx2TaperBox); bool splitPathSeg(frMIdx& midX, frMIdx& midY, bool& taperFirstPiece, @@ -971,34 +1028,37 @@ class FlexDRWorker frBox3D* srcBox, frBox3D* dstBox, drNet* net); - void processPathSeg(frMIdx startX, - frMIdx startY, - frMIdx endX, - frMIdx endY, - frMIdx z, - const std::set& realApMazeIdx, - drNet* net, - bool vertical, - bool taper, - int i, - std::vector& points, - const std::set& apMazeIdx); + void processPathSeg( + frMIdx startX, + frMIdx startY, + frMIdx endX, + frMIdx endY, + frMIdx z, + const boost::container::flat_set& realApMazeIdx, + drNet* net, + bool vertical, + bool taper, + int i, + std::vector& points, + const boost::container::flat_set& apMazeIdx); bool isInWorkerBorder(frCoord x, frCoord y) const; - void checkPathSegStyle(drPathSeg* ps, - bool isBegin, - frSegStyle& style, - const std::set& apMazeIdx, - const FlexMazeIdx& idx); - void checkViaConnectivityToAP(drVia* via, - bool isBottom, - frNet* net, - const std::set& apMazeIdx, - const FlexMazeIdx& idx); + void checkPathSegStyle( + drPathSeg* ps, + bool isBegin, + frSegStyle& style, + const boost::container::flat_set& apMazeIdx, + const FlexMazeIdx& idx); + void checkViaConnectivityToAP( + drVia* via, + bool isBottom, + frNet* net, + const boost::container::flat_set& apMazeIdx, + const FlexMazeIdx& idx); bool hasAccessPoint(const Point& pt, frLayerNum lNum, frNet* net); void routeNet_postAstarPatchMinAreaVio( drNet* net, const std::vector& path, - const std::map& areaMap); + const boost::container::flat_map& areaMap); void routeNet_postAstarAddPatchMetal(drNet* net, const FlexMazeIdx& bpIdx, const FlexMazeIdx& epIdx, @@ -1023,27 +1083,33 @@ class FlexDRWorker // end void cleanup(); void identifyCongestionLevel(); - void endGetModNets(std::set& modNets); - void endRemoveNets(frDesign* design, - std::set& modNets, - std::map>, - frBlockObjectComp>& boundPts); - void endRemoveNets_pathSeg(frDesign* design, - frPathSeg* pathSeg, - std::set>& boundPts); + void endGetModNets( + boost::container::flat_set& modNets); + void endRemoveNets( + frDesign* design, + boost::container::flat_set& modNets, + boost::container::flat_map< + frNet*, + boost::container::flat_set>, + frBlockObjectComp>& boundPts); + void endRemoveNets_pathSeg( + frDesign* design, + frPathSeg* pathSeg, + boost::container::flat_set>& boundPts); void endRemoveNets_via(frDesign* design, frVia* via); void endRemoveNets_patchWire(frDesign* design, frPatchWire* pwire); void endAddNets(frDesign* design, - std::map>, - frBlockObjectComp>& boundPts); + boost::container::flat_map< + frNet*, + boost::container::flat_set>, + frBlockObjectComp>& boundPts); void endAddNets_pathSeg(frDesign* design, drPathSeg* pathSeg); void endAddNets_via(frDesign* design, drVia* via); void endAddNets_patchWire(frDesign* design, drPatchWire* pwire); - void endAddNets_merge(frDesign* design, - frNet* net, - std::set>& boundPts); + void endAddNets_merge( + frDesign* design, + frNet* net, + boost::container::flat_set>& boundPts); /** * Commits updates made by FlexDRWorker::addApExtFigUpdate to the design. * diff --git a/src/drt/src/dr/FlexDR_conn.cpp b/src/drt/src/dr/FlexDR_conn.cpp index 98c8fe2cb3a..f2be9007626 100644 --- a/src/drt/src/dr/FlexDR_conn.cpp +++ b/src/drt/src/dr/FlexDR_conn.cpp @@ -58,9 +58,10 @@ void FlexDRConnectivityChecker::pin2epMap_helper( const frNet* net, const Point& pt, const frLayerNum lNum, - std::map>, - frBlockObjectComp>& pin2epMap) + boost::container::flat_map< + frBlockObject*, + boost::container::flat_set>, + frBlockObjectComp>& pin2epMap) { auto regionQuery = getRegionQuery(); frRegionQuery::Objects result; @@ -91,12 +92,13 @@ void FlexDRConnectivityChecker::pin2epMap_helper( void FlexDRConnectivityChecker::buildPin2epMap( const frNet* net, const NetRouteObjs& netRouteObjs, - std::map>, - frBlockObjectComp>& pin2epMap) + boost::container::flat_map< + frBlockObject*, + boost::container::flat_set>, + frBlockObjectComp>& pin2epMap) { // to avoid delooping fake planar ep in pin - std::set> extEndPoints; + boost::container::flat_set> extEndPoints; for (auto& connFig : netRouteObjs) { if (connFig->typeId() != frcPathSeg) { continue; @@ -154,7 +156,8 @@ void FlexDRConnectivityChecker::initRouteObjs(const frNet* net, void FlexDRConnectivityChecker::nodeMap_routeObjEnd( const frNet* net, const std::vector& netRouteObjs, - std::map, std::set>& nodeMap) + boost::container::flat_map, + boost::container::flat_set>& nodeMap) { for (int i = 0; i < (int) netRouteObjs.size(); i++) { const auto connFig = netRouteObjs[i]; @@ -180,16 +183,19 @@ void FlexDRConnectivityChecker::nodeMap_routeObjSplit_helper( const frCoord trackCoord, const frCoord splitCoord, const frLayerNum lNum, - const std::vector< - std::map>>>& + const std::vector>>>& mergeHelper, - std::map, std::set>& nodeMap) + boost::container::flat_map, + boost::container::flat_set>& nodeMap) { auto it1 = mergeHelper[lNum].find(trackCoord); if (it1 == mergeHelper[lNum].end()) { return; } - auto& mp = it1->second; // std::map> + auto& mp + = it1->second; // boost::container::flat_map> auto it2 = mp.lower_bound(splitCoord); if (it2 == mp.end()) { return; @@ -204,13 +210,18 @@ void FlexDRConnectivityChecker::nodeMap_routeObjSplit_helper( void FlexDRConnectivityChecker::nodeMap_routeObjSplit( const frNet* net, const std::vector& netRouteObjs, - std::map, std::set>& nodeMap) + boost::container::flat_map, + boost::container::flat_set>& nodeMap) { const int numLayers = getTech()->getLayers().size(); // lNum -> track -> ep -> (bp, segIdx) - std::vector>>> + std::vector>>> horzMergeHelper(numLayers); - std::vector>>> + std::vector>>> vertMergeHelper(numLayers); for (int i = 0; i < (int) netRouteObjs.size(); i++) { const auto connFig = netRouteObjs[i]; @@ -274,10 +285,12 @@ void FlexDRConnectivityChecker::nodeMap_routeObjSplit( void FlexDRConnectivityChecker::nodeMap_pin( const std::vector& netRouteObjs, std::vector& netPins, - const std::map>, - frBlockObjectComp>& pin2epMap, - std::map, std::set>& nodeMap) + const boost::container::flat_map< + frBlockObject*, + boost::container::flat_set>, + frBlockObjectComp>& pin2epMap, + boost::container::flat_map, + boost::container::flat_set>& nodeMap) { int currCnt = (int) netRouteObjs.size(); for (auto& [obj, locS] : pin2epMap) { @@ -293,10 +306,12 @@ void FlexDRConnectivityChecker::buildNodeMap( const frNet* net, const NetRouteObjs& netRouteObjs, std::vector& netPins, - const std::map>, - frBlockObjectComp>& pin2epMap, - std::map, std::set>& nodeMap) + const boost::container::flat_map< + frBlockObject*, + boost::container::flat_set>, + frBlockObjectComp>& pin2epMap, + boost::container::flat_map, + boost::container::flat_set>& nodeMap) { nodeMap_routeObjEnd(net, netRouteObjs, nodeMap); nodeMap_routeObjSplit(net, netRouteObjs, nodeMap); @@ -307,7 +322,8 @@ bool FlexDRConnectivityChecker::astar( const frNet* net, std::vector& adjVisited, std::vector& adjPrevIdx, - const std::map, std::set>& nodeMap, + const boost::container::flat_map, + boost::container::flat_set>& nodeMap, const NetRouteObjs& netRouteObjs, const int nNetRouteObjs, const int nNetObjs) @@ -413,12 +429,15 @@ void FlexDRConnectivityChecker::finish( const std::vector& adjVisited, const int gCnt, const int nCnt, - std::map, std::set>& nodeMap) + boost::container::flat_map, + boost::container::flat_set>& nodeMap) { auto regionQuery = getRegionQuery(); // from obj to pt - std::map>> reverseNodeMap; + boost::container:: + flat_map>> + reverseNodeMap; for (auto& [pr, idxS] : nodeMap) { for (auto& idx : idxS) { reverseNodeMap[idx].insert(pr); @@ -484,7 +503,7 @@ void FlexDRConnectivityChecker::finish( } // must use map because split has to start from right - std::map, int> psSplits; + boost::container::flat_map, int> psSplits; for (auto& [pr, idxS] : nodeMap) { bool hasPin = false; for (auto idx : idxS) { @@ -537,8 +556,8 @@ void FlexDRConnectivityChecker::finish( auto ps1 = static_cast(netRouteObjs[idx1]); const auto [bp1, ep1] = ps1->getPoints(); bool isHorz = (bp1.y() == ep1.y()); - std::set> newPr1; - std::set> newPr2; + boost::container::flat_set> newPr1; + boost::container::flat_set> newPr2; for (auto& [prPt, prLNum] : reverseNodeMap[idx1]) { if (isHorz) { if (prPt.x() <= splitPt.x()) { @@ -655,7 +674,7 @@ void FlexDRConnectivityChecker::finish( } // delete redundant pwires - std::set> validPoints; + boost::container::flat_set> validPoints; frLayerNum lNum; for (auto& connFig : net->getShapes()) { if (connFig->typeId() == frcPathSeg) { @@ -1252,13 +1271,15 @@ void FlexDRConnectivityChecker::check(int iter) vertNewSegSpans); } // net->term/instTerm->pt_layer - std::vector>, - frBlockObjectComp>> + std::vector>, + frBlockObjectComp>> aPin2epMap(batchSize); std::vector> aNetPins(batchSize); - std::vector, std::set>> aNodeMap( - batchSize); + std::vector, + boost::container::flat_set>> + aNodeMap(batchSize); std::vector> aAdjVisited(batchSize); std::vector> aAdjPrevIdx(batchSize); std::vector status(batchSize, false); diff --git a/src/drt/src/dr/FlexDR_conn.h b/src/drt/src/dr/FlexDR_conn.h index cf98bc1b7ce..bbd758958be 100644 --- a/src/drt/src/dr/FlexDR_conn.h +++ b/src/drt/src/dr/FlexDR_conn.h @@ -54,7 +54,7 @@ class FlexDRConnectivityChecker using NetRouteObjs = std::vector; // layer -> track -> indices of NetRouteObjs using PathSegsByLayerAndTrack - = std::vector>>; + = std::vector>>; // The track id matches the map iteration order above using PathSegsByLayerAndTrackId = std::vector>>; struct Span @@ -69,49 +69,61 @@ class FlexDRConnectivityChecker using SpansByLayerAndTrackId = std::vector>>; void initRouteObjs(const frNet* net, NetRouteObjs& netRouteObjs); - void buildPin2epMap(const frNet* net, - const NetRouteObjs& netRouteObjs, - std::map>, - frBlockObjectComp>& pin2epMap); - void pin2epMap_helper(const frNet* net, - const Point& pt, - frLayerNum lNum, - std::map>, - frBlockObjectComp>& pin2epMap); + void buildPin2epMap( + const frNet* net, + const NetRouteObjs& netRouteObjs, + boost::container::flat_map< + frBlockObject*, + boost::container::flat_set>, + frBlockObjectComp>& pin2epMap); + void pin2epMap_helper( + const frNet* net, + const Point& pt, + frLayerNum lNum, + boost::container::flat_map< + frBlockObject*, + boost::container::flat_set>, + frBlockObjectComp>& pin2epMap); void buildNodeMap( const frNet* net, const NetRouteObjs& netRouteObjs, std::vector& netPins, - const std::map>, - frBlockObjectComp>& pin2epMap, - std::map, std::set>& nodeMap); + const boost::container::flat_map< + frBlockObject*, + boost::container::flat_set>, + frBlockObjectComp>& pin2epMap, + boost::container::flat_map, + boost::container::flat_set>& nodeMap); void nodeMap_routeObjEnd( const frNet* net, const std::vector& netRouteObjs, - std::map, std::set>& nodeMap); + boost::container::flat_map, + boost::container::flat_set>& nodeMap); void nodeMap_routeObjSplit( const frNet* net, const std::vector& netRouteObjs, - std::map, std::set>& nodeMap); + boost::container::flat_map, + boost::container::flat_set>& nodeMap); void nodeMap_routeObjSplit_helper( const Point& crossPt, frCoord trackCoord, frCoord splitCoord, frLayerNum lNum, - const std::vector< - std::map>>>& + const std::vector>>>& mergeHelper, - std::map, std::set>& nodeMap); + boost::container::flat_map, + boost::container::flat_set>& nodeMap); void nodeMap_pin( const std::vector& netRouteObjs, std::vector& netPins, - const std::map>, - frBlockObjectComp>& pin2epMap, - std::map, std::set>& nodeMap); + const boost::container::flat_map< + frBlockObject*, + boost::container::flat_set>, + frBlockObjectComp>& pin2epMap, + boost::container::flat_map, + boost::container::flat_set>& nodeMap); void organizePathSegsByLayerAndTrack(const frNet* net, const NetRouteObjs& netRouteObjs, PathSegsByLayerAndTrack& horzPathSegs, @@ -155,21 +167,24 @@ class FlexDRConnectivityChecker frCoord trackCoord, const std::vector& newSegSpans, bool isHorz); - bool astar( - const frNet* net, - std::vector& adjVisited, - std::vector& adjPrevIdx, - const std::map, std::set>& nodeMap, - const NetRouteObjs& netRouteObjs, - int nNetRouteObjs, - int nNetObjs); - void finish(frNet* net, - NetRouteObjs& netRouteObjs, - const std::vector& netPins, - const std::vector& adjVisited, - int gCnt, - int nCnt, - std::map, std::set>& nodeMap); + bool astar(const frNet* net, + std::vector& adjVisited, + std::vector& adjPrevIdx, + const boost::container::flat_map, + boost::container::flat_set>& + nodeMap, + const NetRouteObjs& netRouteObjs, + int nNetRouteObjs, + int nNetObjs); + void finish( + frNet* net, + NetRouteObjs& netRouteObjs, + const std::vector& netPins, + const std::vector& adjVisited, + int gCnt, + int nCnt, + boost::container::flat_map, + boost::container::flat_set>& nodeMap); frRegionQuery* getRegionQuery() const; frTechObject* getTech() const; diff --git a/src/drt/src/dr/FlexDR_end.cpp b/src/drt/src/dr/FlexDR_end.cpp index 61ea3d46ef9..96b430ffe6f 100644 --- a/src/drt/src/dr/FlexDR_end.cpp +++ b/src/drt/src/dr/FlexDR_end.cpp @@ -30,7 +30,8 @@ namespace drt { -void FlexDRWorker::endGetModNets(std::set& modNets) +void FlexDRWorker::endGetModNets( + boost::container::flat_set& modNets) { for (auto& net : nets_) { if (net->isModified()) { @@ -48,7 +49,7 @@ void FlexDRWorker::endGetModNets(std::set& modNets) void FlexDRWorker::endRemoveNets_pathSeg( frDesign* design, frPathSeg* pathSeg, - std::set>& boundPts) + boost::container::flat_set>& boundPts) { auto [begin, end] = pathSeg->getPoints(); auto routeBox = getRouteBox(); @@ -267,9 +268,11 @@ void FlexDRWorker::endRemoveNets_patchWire(frDesign* design, frPatchWire* pwire) void FlexDRWorker::endRemoveNets( frDesign* design, - std::set& modNets, - std::map>, frBlockObjectComp>& - boundPts) + boost::container::flat_set& modNets, + boost::container::flat_map< + frNet*, + boost::container::flat_set>, + frBlockObjectComp>& boundPts) { std::vector result; design->getRegionQuery()->queryDRObj(getExtBox(), result); @@ -355,7 +358,7 @@ void FlexDRWorker::endAddNets_patchWire(frDesign* design, drPatchWire* pwire) void FlexDRWorker::endAddNets_merge( frDesign* design, frNet* net, - std::set>& boundPts) + boost::container::flat_set>& boundPts) { frRegionQuery::Objects result; std::vector drObjs; @@ -595,8 +598,10 @@ void FlexDRWorker::endAddNets_updateExtFigs(drNet* net) } void FlexDRWorker::endAddNets( frDesign* design, - std::map>, frBlockObjectComp>& - boundPts) + boost::container::flat_map< + frNet*, + boost::container::flat_set>, + frBlockObjectComp>& boundPts) { for (auto& net : nets_) { if (!net->isModified()) { @@ -701,10 +706,13 @@ bool FlexDRWorker::end(frDesign* design) return false; } save_updates_ = dist_on_; - std::set modNets; + boost::container::flat_set modNets; endGetModNets(modNets); // get lock - std::map>, frBlockObjectComp> + boost::container::flat_map< + frNet*, + boost::container::flat_set>, + frBlockObjectComp> boundPts; endRemoveNets(design, modNets, boundPts); endAddNets(design, boundPts); // if two subnets have diff isModified() diff --git a/src/drt/src/dr/FlexDR_init.cpp b/src/drt/src/dr/FlexDR_init.cpp index c2080395d59..d83a7ab4141 100644 --- a/src/drt/src/dr/FlexDR_init.cpp +++ b/src/drt/src/dr/FlexDR_init.cpp @@ -51,13 +51,13 @@ bool FlexDRWorker::isRouteVia(const frVia* via) const void FlexDRWorker::initNetObjs_pathSeg( frPathSeg* pathSeg, - std::set& nets, - std::map>, - frBlockObjectComp>& netRouteObjs, - std::map>, - frBlockObjectComp>& netExtObjs) + boost::container::flat_set& nets, + boost::container::flat_map>, + frBlockObjectComp>& netRouteObjs, + boost::container::flat_map>, + frBlockObjectComp>& netExtObjs) { const auto [begin, end] = pathSeg->getPoints(); auto net = pathSeg->getNet(); @@ -159,13 +159,13 @@ void FlexDRWorker::initNetObjs_pathSeg( void FlexDRWorker::initNetObjs_via( const frVia* via, - std::set& nets, - std::map>, - frBlockObjectComp>& netRouteObjs, - std::map>, - frBlockObjectComp>& netExtObjs) + boost::container::flat_set& nets, + boost::container::flat_map>, + frBlockObjectComp>& netRouteObjs, + boost::container::flat_map>, + frBlockObjectComp>& netExtObjs) { auto net = via->getNet(); nets.insert(net); @@ -180,13 +180,13 @@ void FlexDRWorker::initNetObjs_via( void FlexDRWorker::initNetObjs_patchWire( frPatchWire* pwire, - std::set& nets, - std::map>, - frBlockObjectComp>& netRouteObjs, - std::map>, - frBlockObjectComp>& netExtObjs) + boost::container::flat_set& nets, + boost::container::flat_map>, + frBlockObjectComp>& netRouteObjs, + boost::container::flat_map>, + frBlockObjectComp>& netExtObjs) { auto net = pwire->getNet(); nets.insert(net); @@ -206,15 +206,17 @@ void FlexDRWorker::initNetObjs_patchWire( // the same criterion above void FlexDRWorker::initNetObjs( const frDesign* design, - std::set& nets, - std::map>, - frBlockObjectComp>& netRouteObjs, - std::map>, - frBlockObjectComp>& netExtObjs, - std::map, frBlockObjectComp>& netOrigGuides, - std::map, frBlockObjectComp>& netGuides) + boost::container::flat_set& nets, + boost::container::flat_map>, + frBlockObjectComp>& netRouteObjs, + boost::container::flat_map>, + frBlockObjectComp>& netExtObjs, + boost::container::flat_map, frBlockObjectComp>& + netOrigGuides, + boost::container::flat_map, frBlockObjectComp>& + netGuides) { std::vector result; design->getRegionQuery()->queryDRObj(getExtBox(), result); @@ -345,7 +347,7 @@ void FlexDRWorker::initNets_segmentTerms(const Point& bp, namespace { void dfs(const int start, - const std::map>& adj_list, + const boost::container::flat_map>& adj_list, std::vector& visited, std::vector& component) { @@ -497,7 +499,7 @@ void FlexDRWorker::initNets_initDR_helper( } nodes.emplace_back(Node::TERM, i, rect); } - std::map> nodeMap; + boost::container::flat_map> nodeMap; for (int i = 0; i < nodes.size(); i++) { for (int j = i + 1; j < nodes.size(); j++) { if (nodes[i].rect.intersects(nodes[j].rect)) { @@ -648,17 +650,20 @@ void FlexDRWorker::initNets_initDR_helper( // inits nets based on the pins void FlexDRWorker::initNets_initDR( const frDesign* design, - std::set& nets, - std::map>, - frBlockObjectComp>& netRouteObjs, - std::map>, - frBlockObjectComp>& netExtObjs, - std::map, frBlockObjectComp>& netOrigGuides, - std::map, frBlockObjectComp>& netGuides) -{ - std::map netTerms; + boost::container::flat_set& nets, + boost::container::flat_map>, + frBlockObjectComp>& netRouteObjs, + boost::container::flat_map>, + frBlockObjectComp>& netExtObjs, + boost::container::flat_map, frBlockObjectComp>& + netOrigGuides, + boost::container::flat_map, frBlockObjectComp>& + netGuides) +{ + boost::container::flat_map + netTerms; std::vector result; design->getRegionQuery()->queryGRPin(getRouteBox(), result); for (auto obj : result) { @@ -733,9 +738,10 @@ void FlexDRWorker::initNets_searchRepair_pin2epMap_helper( const frNet* net, const Point& bp, const frLayerNum lNum, - std::map>, - frBlockObjectComp>& pin2epMap) + boost::container::flat_map< + frBlockObject*, + boost::container::flat_set>, + frBlockObjectComp>& pin2epMap) { frRegionQuery::Objects result; design->getRegionQuery()->query({bp, bp}, lNum, result); @@ -765,9 +771,10 @@ void FlexDRWorker::initNets_searchRepair_pin2epMap( const frDesign* design, const frNet* net, const std::vector>& netRouteObjs, - std::map>, - frBlockObjectComp>& pin2epMap) + boost::container::flat_map< + frBlockObject*, + boost::container::flat_set>, + frBlockObjectComp>& pin2epMap) { // should not count extObjs in union find for (auto& uPtr : netRouteObjs) { @@ -813,7 +820,8 @@ void FlexDRWorker::initNets_searchRepair_pin2epMap( // maps begin/end points of shapes to their shapes void FlexDRWorker::initNets_searchRepair_nodeMap_routeObjEnd( const std::vector>& netRouteObjs, - std::map, std::set>& nodeMap) + boost::container::flat_map, + boost::container::flat_set>& nodeMap) { for (int i = 0; i < (int) netRouteObjs.size(); i++) { auto connFig = netRouteObjs[i].get(); @@ -847,9 +855,12 @@ void FlexDRWorker::initNets_searchRepair_nodeMap_routeObjSplit_helper( const frCoord trackCoord, const frCoord splitCoord, const frLayerNum lNum, - std::vector>>>& + std::vector>>>& mergeHelper, - std::map, std::set>& nodeMap) + boost::container::flat_map, + boost::container::flat_set>& nodeMap) { auto it1 = mergeHelper[lNum].find(trackCoord); if (it1 == mergeHelper[lNum].end()) { @@ -873,12 +884,17 @@ void FlexDRWorker::initNets_searchRepair_nodeMap_routeObjSplit_helper( // shapes, to their shapes void FlexDRWorker::initNets_searchRepair_nodeMap_routeObjSplit( const std::vector>& netRouteObjs, - std::map, std::set>& nodeMap) + boost::container::flat_map, + boost::container::flat_set>& nodeMap) { const int num_layers = getTech()->getLayers().size(); - std::vector>>> + std::vector>>> horzMergeHelper(num_layers); - std::vector>>> + std::vector>>> vertMergeHelper(num_layers); for (int i = 0; i < (int) netRouteObjs.size(); i++) { auto connFig = netRouteObjs[i].get(); @@ -939,10 +955,12 @@ void FlexDRWorker::initNets_searchRepair_nodeMap_routeObjSplit( void FlexDRWorker::initNets_searchRepair_nodeMap_pin( const std::vector>& netRouteObjs, std::vector& netPins, - const std::map>, - frBlockObjectComp>& pin2epMap, - std::map, std::set>& nodeMap) + const boost::container::flat_map< + frBlockObject*, + boost::container::flat_set>, + frBlockObjectComp>& pin2epMap, + boost::container::flat_map, + boost::container::flat_set>& nodeMap) { int currCnt = (int) netRouteObjs.size(); netPins.reserve(pin2epMap.size()); @@ -960,10 +978,12 @@ void FlexDRWorker::initNets_searchRepair_nodeMap_pin( void FlexDRWorker::initNets_searchRepair_nodeMap( const std::vector>& netRouteObjs, std::vector& netPins, - const std::map>, - frBlockObjectComp>& pin2epMap, - std::map, std::set>& nodeMap) + const boost::container::flat_map< + frBlockObject*, + boost::container::flat_set>, + frBlockObjectComp>& pin2epMap, + boost::container::flat_map, + boost::container::flat_set>& nodeMap) { initNets_searchRepair_nodeMap_routeObjEnd(netRouteObjs, nodeMap); initNets_searchRepair_nodeMap_routeObjSplit(netRouteObjs, nodeMap); @@ -973,7 +993,8 @@ void FlexDRWorker::initNets_searchRepair_nodeMap( // maps routeObjs to sub-nets void FlexDRWorker::initNets_searchRepair_connComp( frNet* net, - std::map, std::set>& nodeMap, + boost::container::flat_map, + boost::container::flat_set>& nodeMap, std::vector& compIdx) { const int nCnt = (int) compIdx.size(); // total node cnt @@ -1033,14 +1054,15 @@ void FlexDRWorker::initNets_searchRepair_connComp( void FlexDRWorker::initNets_searchRepair( const frDesign* design, - const std::set& nets, - std::map>, - frBlockObjectComp>& netRouteObjs, - std::map>, - frBlockObjectComp>& netExtObjs, - std::map, frBlockObjectComp>& netOrigGuides) + const boost::container::flat_set& nets, + boost::container::flat_map>, + frBlockObjectComp>& netRouteObjs, + boost::container::flat_map>, + frBlockObjectComp>& netExtObjs, + boost::container::flat_map, frBlockObjectComp>& + netOrigGuides) { for (auto net : nets) { if (isInitDR() && getRipupMode() == RipUpMode::INCR @@ -1049,14 +1071,17 @@ void FlexDRWorker::initNets_searchRepair( } // build big graph; // node number : routeObj, pins - std::map>, - frBlockObjectComp> + boost::container::flat_map< + frBlockObject*, + boost::container::flat_set>, + frBlockObjectComp> pin2epMap; initNets_searchRepair_pin2epMap(design, net, netRouteObjs[net], pin2epMap); std::vector netPins; - std::map, std::set> nodeMap; + boost::container::flat_map, + boost::container::flat_set> + nodeMap; initNets_searchRepair_nodeMap( netRouteObjs[net], netPins, pin2epMap, nodeMap); @@ -1116,8 +1141,8 @@ void FlexDRWorker::initNets_searchRepair( bool FlexDRWorker::findAPTracks(const frLayerNum startLayerNum, const frLayerNum endLayerNum, const Rectangle& pinRect, - std::set& xLocs, - std::set& yLocs) + boost::container::flat_set& xLocs, + boost::container::flat_set& yLocs) { const int inc = (startLayerNum < endLayerNum ? 2 : -2); @@ -1164,7 +1189,7 @@ void FlexDRWorker::initNet_termGenAp(const frDesign* design, drPin* dPin) for (auto& uPinFig : pin->getFigs()) { auto pinFig = uPinFig.get(); // horizontal tracks == yLocs - std::set xLocs, yLocs; + boost::container::flat_set xLocs, yLocs; if (pinFig->typeId() == frcRect) { auto rpinRect = static_cast(pinFig); const frLayerNum currLayerNum = rpinRect->getLayerNum(); @@ -1253,7 +1278,7 @@ void FlexDRWorker::initNet_termGenAp(const frDesign* design, drPin* dPin) for (auto& uPinFig : pin->getFigs()) { auto pinFig = uPinFig.get(); // horizontal tracks == yLocs - std::set xLocs, yLocs; + boost::container::flat_set xLocs, yLocs; if (pinFig->typeId() == frcRect) { auto rpinRect = static_cast(pinFig); frLayerNum currLayerNum = rpinRect->getLayerNum(); @@ -1385,7 +1410,7 @@ void FlexDRWorker::initNet_termGenAp(const frDesign* design, drPin* dPin) for (auto& uPinFig : pin->getFigs()) { auto pinFig = uPinFig.get(); // horizontal tracks == yLocs - std::set xLocs, yLocs; + boost::container::flat_set xLocs, yLocs; if (pinFig->typeId() == frcRect) { auto rpinRect = static_cast(pinFig); frLayerNum currLayerNum = rpinRect->getLayerNum(); @@ -1531,7 +1556,7 @@ void FlexDRWorker::initNet_termGenAp(const frDesign* design, drPin* dPin) for (auto& uPinFig : pin->getFigs()) { auto pinFig = uPinFig.get(); // horizontal tracks == yLocs - std::set xLocs, yLocs; + boost::container::flat_set xLocs, yLocs; if (pinFig->typeId() == frcRect) { auto rpinRect = static_cast(pinFig); frLayerNum currLayerNum = rpinRect->getLayerNum(); @@ -1609,7 +1634,7 @@ void FlexDRWorker::getTrackLocs(const bool isHorzTracks, const frLayerNum currLayerNum, const frCoord low, const frCoord high, - std::set& trackLocs) + boost::container::flat_set& trackLocs) { // Consecutive metal layers always have opposite routing directions (H & V) for (auto& tp : design_->getTopBlock()->getTrackPatterns(currLayerNum)) { @@ -1745,7 +1770,7 @@ void FlexDRWorker::initNet_boundary( { const auto gridBBox = getRouteBox(); // location to area - std::map, frCoord> extBounds; + boost::container::flat_map, frCoord> extBounds; frCoord currArea = 0; bool initFromExtObjs = isInitDR() ? (getRipupMode() == RipUpMode::INCR && dNet->getFrNet()->hasInitialRouting()) @@ -1992,7 +2017,7 @@ void FlexDRWorker::initNets_boundaryArea() void FlexDRWorker::initRipUpNetsFromMarkers() { - std::set ripUpNets; + boost::container::flat_set ripUpNets; for (auto& marker : markers_) { const auto bloatDist = getTech()->getLayer(marker.getLayerNum())->getWidth() * 2; @@ -2009,13 +2034,19 @@ void FlexDRWorker::initRipUpNetsFromMarkers() void FlexDRWorker::initNets(const frDesign* design) { - std::set nets; - std::map>, frBlockObjectComp> + boost::container::flat_set nets; + boost::container::flat_map>, + frBlockObjectComp> netRouteObjs; - std::map>, frBlockObjectComp> + boost::container::flat_map>, + frBlockObjectComp> netExtObjs; - std::map, frBlockObjectComp> netOrigGuides; - std::map, frBlockObjectComp> netGuides; + boost::container::flat_map, frBlockObjectComp> + netOrigGuides; + boost::container::flat_map, frBlockObjectComp> + netGuides; // get lock initNetObjs(design, nets, netRouteObjs, netExtObjs, netOrigGuides, netGuides); // release lock @@ -2048,8 +2079,12 @@ void FlexDRWorker::initNets(const frDesign* design) void FlexDRWorker::initTrackCoords_route( drNet* net, - std::map>& xMap, - std::map>& yMap) + boost::container::flat_map< + frCoord, + boost::container::flat_map>& xMap, + boost::container::flat_map< + frCoord, + boost::container::flat_map>& yMap) { // add for routes std::vector allObjs; @@ -2157,8 +2192,12 @@ void FlexDRWorker::initTrackCoords_route( void FlexDRWorker::initTrackCoords_pin( drNet* net, - std::map>& xMap, - std::map>& yMap) + boost::container::flat_map< + frCoord, + boost::container::flat_map>& xMap, + boost::container::flat_map< + frCoord, + boost::container::flat_map>& yMap) { // add for aps for (auto& pin : net->getPins()) { @@ -2191,8 +2230,12 @@ void FlexDRWorker::initTrackCoords_pin( } void FlexDRWorker::initTrackCoords( - std::map>& xMap, - std::map>& yMap) + boost::container::flat_map< + frCoord, + boost::container::flat_map>& xMap, + boost::container::flat_map< + frCoord, + boost::container::flat_map>& yMap) { // add boundary points // lNum = -10 to indicate routeBox and extBox frCoord @@ -2216,8 +2259,12 @@ void FlexDRWorker::initTrackCoords( void FlexDRWorker::initGridGraph(const frDesign* design) { // get all track coords based on existing objs and aps - std::map> xMap; - std::map> yMap; + boost::container:: + flat_map> + xMap; + boost::container:: + flat_map> + yMap; initTrackCoords(xMap, yMap); gridGraph_.setCost(workerDRCCost_, workerMarkerCost_, workerFixedShapeCost_); gridGraph_.init(design, @@ -2514,8 +2561,9 @@ void FlexDRWorker::initMazeCost_ap() void FlexDRWorker::initMazeCost_marker_route_queue_addHistoryCost( const frMarker& marker) { - std::set vioNets; // for self-violation, only add cost for one side - // (experiment with self cut spacing) + boost::container::flat_set + vioNets; // for self-violation, only add cost for one side + // (experiment with self cut spacing) const Rect mBox = marker.getBBox(); const auto lNum = marker.getLayerNum(); @@ -2709,25 +2757,22 @@ void FlexDRWorker::route_queue_resetRipup() void FlexDRWorker::route_queue_markerCostDecay() { - for (auto it = planarHistoryMarkers_.begin(); - it != planarHistoryMarkers_.end();) { - auto currIt = it; - const auto& mi = *currIt; - ++it; - if (gridGraph_.decayMarkerCostPlanar( + boost::container::flat_set planarHistoryMarkers; + for (auto& mi : planarHistoryMarkers_) { + if (!gridGraph_.decayMarkerCostPlanar( mi.x(), mi.y(), mi.z(), workerMarkerDecay_)) { - planarHistoryMarkers_.erase(currIt); + planarHistoryMarkers.insert(mi); } } - for (auto it = viaHistoryMarkers_.begin(); it != viaHistoryMarkers_.end();) { - auto currIt = it; - const auto& mi = *currIt; - ++it; - if (gridGraph_.decayMarkerCostVia( + std::swap(planarHistoryMarkers_, planarHistoryMarkers); + boost::container::flat_set viaHistoryMarkers; + for (auto& mi : viaHistoryMarkers_) { + if (!gridGraph_.decayMarkerCostVia( mi.x(), mi.y(), mi.z(), workerMarkerDecay_)) { - viaHistoryMarkers_.erase(currIt); + viaHistoryMarkers.insert(mi); } } + std::swap(viaHistoryMarkers_, viaHistoryMarkers); } void FlexDRWorker::route_queue_addMarkerCost( @@ -2750,8 +2795,8 @@ void FlexDRWorker::route_queue_addMarkerCost() void FlexDRWorker::route_queue_init_queue( std::queue& rerouteQueue) { - std::set uniqueVictims; - std::set uniqueAggressors; + boost::container::flat_set uniqueVictims; + boost::container::flat_set uniqueAggressors; std::vector checks; std::vector routes; @@ -2787,7 +2832,7 @@ void FlexDRWorker::route_queue_init_queue( } } int currId = ripupNets.size(); - std::set addedNets; + boost::container::flat_set addedNets; for (auto& marker : markers_) { for (auto net : ripupNets) { if (marker.getSrcs().find(net->getFrNet()) != marker.getSrcs().end()) { @@ -2862,8 +2907,8 @@ void FlexDRWorker::route_queue_update_queue( //*****************************************************************************************// void FlexDRWorker::route_queue_update_from_marker( frMarker* marker, - std::set& uniqueVictims, - std::set& uniqueAggressors, + boost::container::flat_set& uniqueVictims, + boost::container::flat_set& uniqueAggressors, std::vector& checks, std::vector& routes, frBlockObject* checkingObj) @@ -2893,8 +2938,8 @@ void FlexDRWorker::route_queue_update_from_marker( std::vector uniqueAggressorOwners; // to maintain order auto& markerAggressors = marker->getAggressors(); - std::set movableAggressorNets; - std::set movableAggressorOwners; + boost::container::flat_set movableAggressorNets; + boost::container::flat_set movableAggressorOwners; for (auto& aggressorPair : markerAggressors) { auto& aggressor = aggressorPair.first; @@ -2938,7 +2983,7 @@ void FlexDRWorker::route_queue_update_from_marker( } if (hasRerouteNet) { - std::set checkDRCOwners; + boost::container::flat_set checkDRCOwners; for (auto& src : marker->getSrcs()) { if (movableAggressorOwners.find(src) == movableAggressorOwners.end()) { if (src) { @@ -2956,7 +3001,7 @@ void FlexDRWorker::route_queue_update_from_marker( } } } else { - std::set owners, otherOwners, routeOwners; + boost::container::flat_set owners, otherOwners, routeOwners; auto& srcs = marker->getSrcs(); for (auto& src : srcs) { if (src) { @@ -2990,7 +3035,7 @@ void FlexDRWorker::route_queue_update_from_marker( } } if (hasRerouteNet) { - std::set checkDRCOwners; + boost::container::flat_set checkDRCOwners; for (auto& src : marker->getSrcs()) { if (routeOwners.find(src) == routeOwners.end()) { if (src) { @@ -3048,9 +3093,10 @@ void FlexDRWorker::route_queue_update_from_marker( } } -void FlexDRWorker::getRipUpNetsFromMarker(frMarker* marker, - std::set& nets, - const frCoord bloatDist) +void FlexDRWorker::getRipUpNetsFromMarker( + frMarker* marker, + boost::container::flat_set& nets, + const frCoord bloatDist) { // if shapes don't overlap routeBox, ignore violation if (!getRouteBox().intersects(marker->getBBox())) { @@ -3097,8 +3143,8 @@ void FlexDRWorker::route_queue_update_queue( std::queue& rerouteQueue, frBlockObject* checkingObj) { - std::set uniqueVictims; - std::set uniqueAggressors; + boost::container::flat_set uniqueVictims; + boost::container::flat_set uniqueAggressors; std::vector checks; std::vector routes; if (checkingObj != nullptr @@ -3145,7 +3191,8 @@ void FlexDRWorker::initMazeCost_fixedObj(const frDesign* design) { frRegionQuery::Objects result; frMIdx zIdx = 0; - std::map> frNet2Terms; + boost::container::flat_map> + frNet2Terms; for (auto layerNum = getTech()->getBottomLayerNum(); layerNum <= getTech()->getTopLayerNum(); ++layerNum) { @@ -3263,10 +3310,14 @@ void FlexDRWorker::initMazeCost_fixedObj(const frDesign* design) // assign terms to each subnet for (auto& [net, objs] : frNet2Terms) { + std::set terms; + for (auto obj : objs) { + terms.insert(obj); // TODO + } for (auto dNet : owner2nets_[net]) { - dNet->setFrNetTerms(objs); + dNet->setFrNetTerms(terms); } - initMazeCost_terms(objs, true); + initMazeCost_terms(terms, true); } } diff --git a/src/drt/src/dr/FlexDR_maze.cpp b/src/drt/src/dr/FlexDR_maze.cpp index be7300525e5..de39d2bbf4e 100644 --- a/src/drt/src/dr/FlexDR_maze.cpp +++ b/src/drt/src/dr/FlexDR_maze.cpp @@ -1886,7 +1886,8 @@ void FlexDRWorker::identifyCongestionLevel() void FlexDRWorker::route_queue_main(std::queue& rerouteQueue) { int gc_version = 1; - std::map> obj_gc_version; + boost::container::flat_map> + obj_gc_version; auto& workerRegionQuery = getWorkerRegionQuery(); while (!rerouteQueue.empty()) { auto& entry = rerouteQueue.front(); @@ -2219,12 +2220,14 @@ void FlexDRWorker::modEolCosts_poly(gcNet* net, ModCostType modType) void FlexDRWorker::routeNet_prep( drNet* net, - std::set& unConnPins, - std::map>& + boost::container::flat_set& unConnPins, + boost::container::flat_map< + FlexMazeIdx, + boost::container::flat_set>& mazeIdx2unConnPins, - std::set& apMazeIdx, - std::set& realPinAPMazeIdx, - std::map& mazeIdx2TaperBox, + boost::container::flat_set& apMazeIdx, + boost::container::flat_set& realPinAPMazeIdx, + boost::container::flat_map& mazeIdx2TaperBox, std::list>& pinTaperBoxes) { frBox3D* tbx = nullptr; @@ -2288,8 +2291,10 @@ void FlexDRWorker::routeNet_prep( } void FlexDRWorker::routeNet_setSrc( - std::set& unConnPins, - std::map>& + boost::container::flat_set& unConnPins, + boost::container::flat_map< + FlexMazeIdx, + boost::container::flat_set>& mazeIdx2unConnPins, std::vector& connComps, FlexMazeIdx& ccMazeIdx1, @@ -2387,7 +2392,9 @@ void FlexDRWorker::routeNet_setSrc( drPin* FlexDRWorker::routeNet_getNextDst( FlexMazeIdx& ccMazeIdx1, FlexMazeIdx& ccMazeIdx2, - std::map>& + boost::container::flat_map< + FlexMazeIdx, + boost::container::flat_set>& mazeIdx2unConnPins, std::list>& pinTaperBoxes) { @@ -2436,13 +2443,15 @@ void FlexDRWorker::mazePinInit() void FlexDRWorker::routeNet_postAstarUpdate( std::vector& path, std::vector& connComps, - std::set& unConnPins, - std::map>& + boost::container::flat_set& unConnPins, + boost::container::flat_map< + FlexMazeIdx, + boost::container::flat_set>& mazeIdx2unConnPins, bool isFirstConn) { // first point is dst - std::set localConnComps; + boost::container::flat_set localConnComps; if (!path.empty()) { auto mi = path[0]; std::vector tmpPins; @@ -2536,9 +2545,9 @@ void FlexDRWorker::routeNet_postAstarUpdate( void FlexDRWorker::routeNet_postAstarWritePath( drNet* net, std::vector& points, - const std::set& realPinApMazeIdx, - std::map& mazeIdx2TaperBox, - const std::set& apMazeIdx) + const boost::container::flat_set& realPinApMazeIdx, + boost::container::flat_map& mazeIdx2TaperBox, + const boost::container::flat_set& apMazeIdx) { if (points.empty()) { return; @@ -2873,18 +2882,19 @@ bool FlexDRWorker::splitPathSeg(frMIdx& midX, } return false; } -void FlexDRWorker::processPathSeg(frMIdx startX, - frMIdx startY, - frMIdx endX, - frMIdx endY, - frMIdx z, - const std::set& realApMazeIdx, - drNet* net, - bool segIsVertical, - bool taper, - int i, - std::vector& points, - const std::set& apMazeIdx) +void FlexDRWorker::processPathSeg( + frMIdx startX, + frMIdx startY, + frMIdx endX, + frMIdx endY, + frMIdx z, + const boost::container::flat_set& realApMazeIdx, + drNet* net, + bool segIsVertical, + bool taper, + int i, + std::vector& points, + const boost::container::flat_set& apMazeIdx) { Point startLoc, endLoc; frLayerNum currLayerNum = gridGraph_.getLayerNum(z); @@ -2971,11 +2981,12 @@ bool FlexDRWorker::isInWorkerBorder(frCoord x, frCoord y) const } // checks whether the path segment is connected to an access point and update // connectivity info (stored in frSegStyle) -void FlexDRWorker::checkPathSegStyle(drPathSeg* ps, - bool isBegin, - frSegStyle& style, - const std::set& apMazeIdx, - const FlexMazeIdx& idx) +void FlexDRWorker::checkPathSegStyle( + drPathSeg* ps, + bool isBegin, + frSegStyle& style, + const boost::container::flat_set& apMazeIdx, + const FlexMazeIdx& idx) { const Point& pt = (isBegin ? ps->getBeginPoint() : ps->getEndPoint()); if (apMazeIdx.find(idx) == apMazeIdx.end() @@ -3028,7 +3039,7 @@ void FlexDRWorker::checkViaConnectivityToAP( drVia* via, bool isBottom, frNet* net, - const std::set& apMazeIdx, + const boost::container::flat_set& apMazeIdx, const FlexMazeIdx& idx) { if (apMazeIdx.find(idx) == apMazeIdx.end() @@ -3154,7 +3165,7 @@ bool FlexDRWorker::isInsideTaperBox( frMIdx y, frMIdx startZ, frMIdx endZ, - std::map& mazeIdx2TaperBox) + boost::container::flat_map& mazeIdx2TaperBox) { FlexMazeIdx idx(x, y, startZ); auto it = mazeIdx2TaperBox.find(idx); @@ -3202,8 +3213,9 @@ void FlexDRWorker::routeNet_AddCutSpcCost(std::vector& path) } } -void FlexDRWorker::routeNet_prepAreaMap(drNet* net, - std::map& areaMap) +void FlexDRWorker::routeNet_prepAreaMap( + drNet* net, + boost::container::flat_map& areaMap) { for (auto& pin : net->getPins()) { for (auto& ap : pin->getAccessPatterns()) { @@ -3228,14 +3240,17 @@ bool FlexDRWorker::routeNet(drNet* net, std::vector& paths) if (graphics_) { graphics_->show(true); } - std::set unConnPins; - std::map> mazeIdx2unConnPins; - std::map + boost::container::flat_set unConnPins; + boost::container::flat_map< + FlexMazeIdx, + boost::container::flat_set> + mazeIdx2unConnPins; + boost::container::flat_map mazeIdx2TaperBox; // access points -> taper box: used to efficiently know // what points are in what taper boxes std::list> pinTaperBoxes; - std::set apMazeIdx; - std::set realPinAPMazeIdx; + boost::container::flat_set apMazeIdx; + boost::container::flat_set realPinAPMazeIdx; routeNet_prep(net, unConnPins, mazeIdx2unConnPins, @@ -3244,7 +3259,7 @@ bool FlexDRWorker::routeNet(drNet* net, std::vector& paths) mazeIdx2TaperBox, pinTaperBoxes); // prep for area map - std::map areaMap; + boost::container::flat_map areaMap; if (ENABLE_BOUNDARY_MAR_FIX) { routeNet_prepAreaMap(net, areaMap); } @@ -3314,7 +3329,7 @@ bool FlexDRWorker::routeNet(drNet* net, std::vector& paths) void FlexDRWorker::routeNet_postAstarPatchMinAreaVio( drNet* net, const std::vector& path, - const std::map& areaMap) + const boost::container::flat_map& areaMap) { if (path.empty()) { return; diff --git a/src/drt/src/dr/FlexGridGraph.cpp b/src/drt/src/dr/FlexGridGraph.cpp index d6853c76fcd..5bebde2c900 100644 --- a/src/drt/src/dr/FlexGridGraph.cpp +++ b/src/drt/src/dr/FlexGridGraph.cpp @@ -53,9 +53,13 @@ bool FlexGridGraph::isAccessPointLocation(frLayerNum layer_num, return layer_maze_locs.find(Point(x_coord, y_coord)) != layer_maze_locs.end(); } void FlexGridGraph::initGrids( - const std::map>& xMap, - const std::map>& yMap, - const std::map& zMap, + const boost::container::flat_map< + frCoord, + boost::container::flat_map>& xMap, + const boost::container::flat_map< + frCoord, + boost::container::flat_map>& yMap, + const boost::container::flat_map& zMap, bool followGuide) { // initialize coord vectors @@ -176,8 +180,9 @@ bool FlexGridGraph::isWorkerBorder(frMIdx v, bool isVert) } bool FlexGridGraph::hasAlignedUpDefTrack( frLayerNum layerNum, - const std::map& xSubMap, - const std::map& ySubMap) const + const boost::container::flat_map& xSubMap, + const boost::container::flat_map& ySubMap) + const { for (frLayerNum lNum = layerNum + 2; lNum < (int) getTech()->getLayers().size(); @@ -200,9 +205,13 @@ bool FlexGridGraph::hasAlignedUpDefTrack( void FlexGridGraph::initEdges( const frDesign* design, - std::map>& xMap, - std::map>& yMap, - const std::map& zMap, + boost::container::flat_map< + frCoord, + boost::container::flat_map>& xMap, + boost::container::flat_map< + frCoord, + boost::container::flat_map>& yMap, + const boost::container::flat_map& zMap, const Rect& bbox, bool initDR) { @@ -393,8 +402,12 @@ void FlexGridGraph::init( const frDesign* design, const Rect& routeBBox, const Rect& extBBox, - std::map>& xMap, - std::map>& yMap, + boost::container::flat_map< + frCoord, + boost::container::flat_map>& xMap, + boost::container::flat_map< + frCoord, + boost::container::flat_map>& yMap, bool initDR, bool followGuide) { @@ -402,7 +415,7 @@ void FlexGridGraph::init( halfViaEncArea_ = &via_data->halfViaEncArea; // get tracks intersecting with the Maze bbox - std::map zMap; + boost::container::flat_map zMap; initTracks(design, xMap, yMap, zMap, extBBox); initGrids(xMap, yMap, zMap, followGuide); // buildGridGraph initEdges( @@ -414,11 +427,16 @@ void FlexGridGraph::init( // get all tracks intersecting with the Maze bbox, left/bottom are inclusive void FlexGridGraph::initTracks( const frDesign* design, - std::map>& + boost::container::flat_map< + frCoord, + boost::container::flat_map>& horLoc2TrackPatterns, - std::map>& + boost::container::flat_map< + frCoord, + boost::container::flat_map>& vertLoc2TrackPatterns, - std::map& layerNum2PreRouteDir, + boost::container::flat_map& + layerNum2PreRouteDir, const Rect& bbox) { for (auto& layer : getTech()->getLayers()) { diff --git a/src/drt/src/dr/FlexGridGraph.h b/src/drt/src/dr/FlexGridGraph.h index 7a29c928cf4..d91c47c2828 100644 --- a/src/drt/src/dr/FlexGridGraph.h +++ b/src/drt/src/dr/FlexGridGraph.h @@ -923,8 +923,12 @@ class FlexGridGraph void init(const frDesign* design, const Rect& routeBBox, const Rect& extBBox, - std::map>& xMap, - std::map>& yMap, + boost::container::flat_map< + frCoord, + boost::container::flat_map>& xMap, + boost::container::flat_map< + frCoord, + boost::container::flat_map>& yMap, bool initDR, bool followGuide); void print() const; @@ -932,13 +936,14 @@ class FlexGridGraph void resetPrevNodeDir(); void resetSrc(); void resetDst(); - bool search(std::vector& connComps, - drPin* nextPin, - std::vector& path, - FlexMazeIdx& ccMazeIdx1, - FlexMazeIdx& ccMazeIdx2, - const Point& centerPt, - std::map& mazeIdx2TaperBox); + bool search( + std::vector& connComps, + drPin* nextPin, + std::vector& path, + FlexMazeIdx& ccMazeIdx1, + FlexMazeIdx& ccMazeIdx2, + const Point& centerPt, + boost::container::flat_map& mazeIdx2TaperBox); void setCost(frUInt4 drcCostIn, frUInt4 markerCostIn, frUInt4 FixedShapeCostIn) @@ -1098,7 +1103,7 @@ class FlexGridGraph = nullptr; // taper box for the current dest pin in the search // locations of access points. The vector is indexed by layer number. - frVector> ap_locs_; + frVector> ap_locs_; FlexGridGraph() = default; @@ -1262,23 +1267,37 @@ class FlexGridGraph } // internal init utility void initTracks(const frDesign* design, - std::map>& + boost::container::flat_map< + frCoord, + boost::container::flat_map>& horLoc2TrackPatterns, - std::map>& + boost::container::flat_map< + frCoord, + boost::container::flat_map>& vertLoc2TrackPatterns, - std::map& layerNum2PreRouteDir, + boost::container::flat_map& + layerNum2PreRouteDir, const Rect& bbox); void initGrids( - const std::map>& xMap, - const std::map>& yMap, - const std::map& zMap, + const boost::container::flat_map< + frCoord, + boost::container::flat_map>& xMap, + const boost::container::flat_map< + frCoord, + boost::container::flat_map>& yMap, + const boost::container::flat_map& zMap, bool followGuide); - void initEdges(const frDesign* design, - std::map>& xMap, - std::map>& yMap, - const std::map& zMap, - const Rect& bbox, - bool initDR); + void initEdges( + const frDesign* design, + boost::container::flat_map< + frCoord, + boost::container::flat_map>& xMap, + boost::container::flat_map< + frCoord, + boost::container::flat_map>& yMap, + const boost::container::flat_map& zMap, + const Rect& bbox, + bool initDR); frCost getEstCost(const FlexMazeIdx& src, const FlexMazeIdx& dstMazeIdx1, const FlexMazeIdx& dstMazeIdx2, @@ -1305,8 +1324,9 @@ class FlexGridGraph const Point& centerPt); bool hasAlignedUpDefTrack( frLayerNum layerNum, - const std::map& xSubMap, - const std::map& ySubMap) const; + const boost::container::flat_map& xSubMap, + const boost::container::flat_map& ySubMap) + const; private: bool outOfDieVia(frMIdx x, frMIdx y, frMIdx z, const Rect& dieBox); diff --git a/src/drt/src/dr/FlexGridGraph_maze.cpp b/src/drt/src/dr/FlexGridGraph_maze.cpp index 19ccbc24129..d3574d56937 100644 --- a/src/drt/src/dr/FlexGridGraph_maze.cpp +++ b/src/drt/src/dr/FlexGridGraph_maze.cpp @@ -653,13 +653,14 @@ void FlexGridGraph::traceBackPath(const FlexWavefrontGrid& currGrid, } } -bool FlexGridGraph::search(std::vector& connComps, - drPin* nextPin, - std::vector& path, - FlexMazeIdx& ccMazeIdx1, - FlexMazeIdx& ccMazeIdx2, - const Point& centerPt, - std::map& mazeIdx2TaperBox) +bool FlexGridGraph::search( + std::vector& connComps, + drPin* nextPin, + std::vector& path, + FlexMazeIdx& ccMazeIdx1, + FlexMazeIdx& ccMazeIdx2, + const Point& centerPt, + boost::container::flat_map& mazeIdx2TaperBox) { if (drWorker_->getDRIter() >= debugMazeIter) { std::cout << "INIT search: target pin " << nextPin->getName() diff --git a/src/drt/src/frDesign.h b/src/drt/src/frDesign.h index b4b2aeca607..b5133030cdf 100644 --- a/src/drt/src/frDesign.h +++ b/src/drt/src/frDesign.h @@ -124,7 +124,7 @@ class frDesign private: std::unique_ptr topBlock_; - std::map name2master_; + boost::container::flat_map name2master_; std::vector> masters_; std::unique_ptr tech_; std::unique_ptr rq_; diff --git a/src/drt/src/frRegionQuery.cpp b/src/drt/src/frRegionQuery.cpp index a019694a22b..92426130267 100644 --- a/src/drt/src/frRegionQuery.cpp +++ b/src/drt/src/frRegionQuery.cpp @@ -67,8 +67,9 @@ struct frRegionQuery::Impl Impl() = default; void init(); - void initOrigGuide( - std::map, frBlockObjectComp>& tmpGuides); + void initOrigGuide(boost::container::flat_map, + frBlockObjectComp>& tmpGuides); void initGuide(); void initRPin(); void initGRPin(std::vector>& in); @@ -817,13 +818,15 @@ void frRegionQuery::Impl::init() } void frRegionQuery::initOrigGuide( - std::map, frBlockObjectComp>& tmpGuides) + boost::container::flat_map, frBlockObjectComp>& + tmpGuides) { impl_->initOrigGuide(tmpGuides); } void frRegionQuery::Impl::initOrigGuide( - std::map, frBlockObjectComp>& tmpGuides) + boost::container::flat_map, frBlockObjectComp>& + tmpGuides) { const frLayerNum numLayers = design_->getTech()->getLayers().size(); origGuides_.clear(); diff --git a/src/drt/src/frRegionQuery.h b/src/drt/src/frRegionQuery.h index 661708d9f07..1d187711f91 100644 --- a/src/drt/src/frRegionQuery.h +++ b/src/drt/src/frRegionQuery.h @@ -122,8 +122,9 @@ class frRegionQuery // init void init(); void initGuide(); - void initOrigGuide( - std::map, frBlockObjectComp>& tmpGuides); + void initOrigGuide(boost::container::flat_map, + frBlockObjectComp>& tmpGuides); void initGRPin(std::vector>& in); void initRPin(); void initDRObj(); diff --git a/src/drt/src/gc/FlexGC.cpp b/src/drt/src/gc/FlexGC.cpp index a8157babbf8..02d64112bee 100644 --- a/src/drt/src/gc/FlexGC.cpp +++ b/src/drt/src/gc/FlexGC.cpp @@ -171,7 +171,8 @@ void FlexGCWorker::addTargetObj(frBlockObject* in) impl_->targetObjs_.insert(in); } -void FlexGCWorker::setTargetObjs(const std::set& targetObjs) +void FlexGCWorker::setTargetObjs( + const boost::container::flat_set& targetObjs) { impl_->targetObjs_ = targetObjs; } diff --git a/src/drt/src/gc/FlexGC.h b/src/drt/src/gc/FlexGC.h index f563da212b0..ecbd1b49a45 100644 --- a/src/drt/src/gc/FlexGC.h +++ b/src/drt/src/gc/FlexGC.h @@ -28,6 +28,8 @@ #pragma once +#include +#include #include #include "frDesign.h" @@ -54,7 +56,8 @@ class FlexGCWorker gcNet* getTargetNet(); void resetTargetNet(); void addTargetObj(frBlockObject* in); - void setTargetObjs(const std::set& targetObjs); + void setTargetObjs( + const boost::container::flat_set& targetObjs); void setIgnoreDB(); void setIgnoreMinArea(); void setIgnoreLongSideEOL(); @@ -89,7 +92,7 @@ struct MarkerId Rect box; frLayerNum lNum; frConstraint* con; - std::set srcs; + boost::container::flat_set srcs; bool operator<(const MarkerId& rhs) const { return std::tie(box, lNum, con, srcs) diff --git a/src/drt/src/gc/FlexGC_impl.h b/src/drt/src/gc/FlexGC_impl.h index af046f56e67..17acabff162 100644 --- a/src/drt/src/gc/FlexGC_impl.h +++ b/src/drt/src/gc/FlexGC_impl.h @@ -142,11 +142,12 @@ class FlexGCWorker::Impl Rect extBox_; Rect drcBox_; - std::map owner2nets_; // no order is assumed + boost::container::flat_map + owner2nets_; // no order is assumed std::vector> nets_; std::vector> markers_; - std::map mapMarkers_; + boost::container::flat_map mapMarkers_; std::vector> pwires_; FlexGCWorkerRegionQuery rq_; @@ -161,7 +162,7 @@ class FlexGCWorker::Impl frLayerNum maxLayerNum_; // for pin prep - std::set targetObjs_; + boost::container::flat_set targetObjs_; bool ignoreDB_; bool ignoreMinArea_; bool ignoreLongSideEOL_; @@ -189,31 +190,36 @@ class FlexGCWorker::Impl void initNet_pins_polygonEdges(gcNet* net); void initNet_pins_polygonEdges_getFixedPolygonEdges( gcNet* net, - std::vector>>& fixedPolygonEdges); + std::vector>>& + fixedPolygonEdges); void initNet_pins_polygonEdges_helper_outer( gcNet* net, gcPin* pin, gcPolygon* poly, frLayerNum i, - const std::vector>>& fixedPolygonEdges); + const std::vector>>& + fixedPolygonEdges); void initNet_pins_polygonEdges_helper_inner( gcNet* net, gcPin* pin, const gtl::polygon_90_data& hole_poly, frLayerNum i, - const std::vector>>& fixedPolygonEdges); + const std::vector>>& + fixedPolygonEdges); void initNet_pins_polygonCorners(gcNet* net); void initNet_pins_polygonCorners_helper(gcNet* net, gcPin* pin); void initNet_pins_maxRectangles(gcNet* net); void initNet_pins_maxRectangles_getFixedMaxRectangles( gcNet* net, - std::vector>>& fixedMaxRectangles); + std::vector>>& + fixedMaxRectangles); void initNet_pins_maxRectangles_helper( gcNet* net, gcPin* pin, const gtl::rectangle_data& rect, frLayerNum i, - const std::vector>>& fixedMaxRectangles); + const std::vector>>& + fixedMaxRectangles); void initRegionQuery(); diff --git a/src/drt/src/gc/FlexGC_init.cpp b/src/drt/src/gc/FlexGC_init.cpp index 1a98afeb86f..be0ec0f6010 100644 --- a/src/drt/src/gc/FlexGC_init.cpp +++ b/src/drt/src/gc/FlexGC_init.cpp @@ -422,7 +422,7 @@ void FlexGCWorker::Impl::initDRWorker() void FlexGCWorker::Impl::initNetsFromDesign(const frDesign* design) { std::vector result; - std::map> pwires; + boost::container::flat_map> pwires; design->getRegionQuery()->queryDRObj(getExtBox(), result); for (auto rptr : result) { if (rptr->typeId() == frcPathSeg) { @@ -486,7 +486,8 @@ void FlexGCWorker::Impl::initNet_pins_polygon(gcNet* net) void FlexGCWorker::Impl::initNet_pins_polygonEdges_getFixedPolygonEdges( gcNet* net, - std::vector>>& fixedPolygonEdges) + std::vector>>& + fixedPolygonEdges) { int numLayers = getTech()->getLayers().size(); std::vector> polys; @@ -552,7 +553,8 @@ void FlexGCWorker::Impl::initNet_pins_polygonEdges_helper_outer( gcPin* pin, gcPolygon* poly, frLayerNum i, - const std::vector>>& fixedPolygonEdges) + const std::vector>>& + fixedPolygonEdges) { Point bp, ep, firstPt; gtl::point_data bp1, ep1, firstPt1; @@ -626,7 +628,8 @@ void FlexGCWorker::Impl::initNet_pins_polygonEdges_helper_inner( gcPin* pin, const gtl::polygon_90_data& hole_poly, frLayerNum i, - const std::vector>>& fixedPolygonEdges) + const std::vector>>& + fixedPolygonEdges) { Point bp, ep, firstPt; gtl::point_data bp1, ep1, firstPt1; @@ -698,7 +701,8 @@ void FlexGCWorker::Impl::initNet_pins_polygonEdges_helper_inner( void FlexGCWorker::Impl::initNet_pins_polygonEdges(gcNet* net) { int numLayers = getTech()->getLayers().size(); - std::vector>> fixedPolygonEdges(numLayers); + std::vector>> + fixedPolygonEdges(numLayers); // get all fixed polygon edges initNet_pins_polygonEdges_getFixedPolygonEdges(net, fixedPolygonEdges); @@ -820,7 +824,8 @@ void FlexGCWorker::Impl::initNet_pins_polygonCorners(gcNet* net) void FlexGCWorker::Impl::initNet_pins_maxRectangles_getFixedMaxRectangles( gcNet* net, - std::vector>>& fixedMaxRectangles) + std::vector>>& + fixedMaxRectangles) { int numLayers = getTech()->getLayers().size(); std::vector> rects; @@ -846,7 +851,8 @@ void FlexGCWorker::Impl::initNet_pins_maxRectangles_helper( gcPin* pin, const gtl::rectangle_data& rect, frLayerNum i, - const std::vector>>& fixedMaxRectangles) + const std::vector>>& + fixedMaxRectangles) { auto rectangle = std::make_unique(); rectangle->setRect(rect); @@ -884,7 +890,8 @@ void FlexGCWorker::Impl::initNet_pins_maxRectangles_helper( void FlexGCWorker::Impl::initNet_pins_maxRectangles(gcNet* net) { int numLayers = getTech()->getLayers().size(); - std::vector>> fixedMaxRectangles(numLayers); + std::vector>> + fixedMaxRectangles(numLayers); // get all fixed max rectangles initNet_pins_maxRectangles_getFixedMaxRectangles(net, fixedMaxRectangles); @@ -961,7 +968,7 @@ void FlexGCWorker::Impl::updateGCWorker() } // get all frNets, must be sorted by id - std::set fnets; + boost::container::flat_set fnets; for (auto dnet : modifiedDRNets_) { fnets.insert(dnet->getFrNet()); } diff --git a/src/drt/src/gc/FlexGC_main.cpp b/src/drt/src/gc/FlexGC_main.cpp index cf407726c5b..80b5fc5f76c 100644 --- a/src/drt/src/gc/FlexGC_main.cpp +++ b/src/drt/src/gc/FlexGC_main.cpp @@ -3705,7 +3705,7 @@ void FlexGCWorker::Impl::patchMetalShape_minStep() continue; } workerRegionQuery.query(markerBBox, lNum, results); - std::map> vias; + boost::container::flat_map> vias; for (auto& connFig : results) { if (connFig->typeId() != drcVia) { continue; diff --git a/src/drt/src/gr/FlexGR.cpp b/src/drt/src/gr/FlexGR.cpp index e81ac292e7a..b659e2161e7 100644 --- a/src/drt/src/gr/FlexGR.cpp +++ b/src/drt/src/gr/FlexGR.cpp @@ -1561,9 +1561,9 @@ void FlexGR::initGR_genTopology_net(frNet* net) } std::vector nodes(net->getNodes().size(), nullptr); // 0 is source - std::map> + boost::container::flat_map> pin2Nodes; // vector order needs to align with map below - std::map> pin2RPins; + boost::container::flat_map> pin2RPins; unsigned sinkIdx = 1; auto& netNodes = net->getNodes(); @@ -1641,9 +1641,11 @@ void FlexGR::initGR_genTopology_net(frNet* net) } } - // std::map, std::vector > gcellIdx2Nodes; + // boost::container::flat_map, std::vector > + // gcellIdx2Nodes; auto& gcellIdx2Nodes = net2GCellIdx2Nodes_[net]; - // std::map > gcellNode2RPinNodes; + // boost::container::flat_map > + // gcellNode2RPinNodes; auto& gcellNode2RPinNodes = net2GCellNode2RPinNodes_[net]; // prep for 2D topology generation in case two nodes are more than one rpin in @@ -2317,13 +2319,15 @@ void FlexGR::layerAssign_node_commit( currNode->setLayerNum((layerNum + 1) * 2); // tech layer num, not grid layer num - std::set nodeLayerNums; - std::map> layerNum2Children; + boost::container::flat_set nodeLayerNums; + boost::container::flat_map> + layerNum2Children; // sub nodes are created at same loc as currNode but differnt layerNum // since we move from 2d to 3d - std::map layerNum2SubNode; + boost::container::flat_map layerNum2SubNode; - std::map> layerNum2RPinNodes; + boost::container::flat_map> + layerNum2RPinNodes; nodeLayerNums.insert(currNode->getLayerNum()); for (auto& child : children) { diff --git a/src/drt/src/gr/FlexGR.h b/src/drt/src/gr/FlexGR.h index d32179ba48f..753f4c7434c 100644 --- a/src/drt/src/gr/FlexGR.h +++ b/src/drt/src/gr/FlexGR.h @@ -28,6 +28,8 @@ #pragma once +#include +#include #include #include #include @@ -85,15 +87,20 @@ class FlexGR std::unique_ptr cmap2D_; Logger* logger_; stt::SteinerTreeBuilder* stt_builder_; - std::map, std::vector>, - frBlockObjectComp> + boost::container::flat_map< + frNet*, + boost::container::flat_map, std::vector>, + frBlockObjectComp> net2GCellIdx2Nodes_; - std::map, frBlockObjectComp> net2GCellNodes_; - std::map, frBlockObjectComp> net2SteinerNodes_; - std::map, frBlockObjectComp>, - frBlockObjectComp> + boost::container::flat_map, frBlockObjectComp> + net2GCellNodes_; + boost::container::flat_map, frBlockObjectComp> + net2SteinerNodes_; + boost::container::flat_map, + frBlockObjectComp>, + frBlockObjectComp> net2GCellNode2RPinNodes_; std::vector trackPitches_; std::vector line2ViaPitches_; @@ -226,14 +233,18 @@ class FlexGR void genSTTopology_build_tree_mergeSeg( std::vector& pinNodes, std::vector& isU, - std::map>& horzIntvs, - std::map>& vertIntvs); + boost::container::flat_map>& + horzIntvs, + boost::container::flat_map>& + vertIntvs); void genSTTopology_build_tree_splitSeg( std::vector& pinNodes, - std::map& pinGCell2Nodes, - std::map>& horzIntvs, - std::map>& vertIntvs, - std::map& steinerGCell2Nodes, + boost::container::flat_map& pinGCell2Nodes, + boost::container::flat_map>& + horzIntvs, + boost::container::flat_map>& + vertIntvs, + boost::container::flat_map& steinerGCell2Nodes, std::vector& steinerNodes); // utility void writeToGuide(); @@ -358,7 +369,8 @@ class FlexGRWorker // local storage std::vector> nets_; - std::map, frBlockObjectComp> owner2nets_; + boost::container::flat_map, frBlockObjectComp> + owner2nets_; FlexGRGridGraph gridGraph_; FlexGRWorkerRegionQuery rq_; @@ -377,19 +389,23 @@ class FlexGRWorker void init(); void initNets(); void initNets_roots( - std::set& nets, - std::map, frBlockObjectComp>& netRoots); + boost::container::flat_set& nets, + boost::container:: + flat_map, frBlockObjectComp>& netRoots); void initNetObjs_roots_pathSeg( grPathSeg* pathSeg, - std::set& nets, - std::map, frBlockObjectComp>& netRoots); + boost::container::flat_set& nets, + boost::container:: + flat_map, frBlockObjectComp>& netRoots); void initNetObjs_roots_via( grVia* via, - std::set& nets, - std::map, frBlockObjectComp>& netRoots); + boost::container::flat_set& nets, + boost::container:: + flat_map, frBlockObjectComp>& netRoots); void initNets_searchRepair( - std::set& nets, - std::map, frBlockObjectComp>& netRoots); + boost::container::flat_set& nets, + boost::container:: + flat_map, frBlockObjectComp>& netRoots); void initNet(frNet* net, const std::vector& netRoots); void initNet_initNodes(grNet* net, frNode* fRoot); void initNet_initRoot(grNet* net); @@ -405,7 +421,8 @@ class FlexGRWorker void initNets_printNets(); void initNets_printNet(grNet* net); void initNets_printFNets( - std::map, frBlockObjectComp>& netRoots); + boost::container:: + flat_map, frBlockObjectComp>& netRoots); void initNets_printFNet(frNode* root); // route @@ -421,32 +438,38 @@ class FlexGRWorker void modCong_pathSeg(grPathSeg* pathSeg, bool isAdd); void mazeNetInit_removeNetNodes(grNet* net); bool routeNet(grNet* net); - void routeNet_prep(grNet* net, - std::set& unConnPinGCellNodes, - std::map& mazeIdx2unConnPinGCellNode, - std::map& mazeIdx2endPointNode); - void routeNet_setSrc( + void routeNet_prep( grNet* net, - std::set& unConnPinGCellNodes, - std::map& mazeIdx2unConnPinGCellNode, - std::vector& connComps, - FlexMazeIdx& ccMazeIdx1, - FlexMazeIdx& ccMazeIdx2, - Point& centerPt); - grNode* routeNet_getNextDst( - FlexMazeIdx& ccMazeIdx1, - FlexMazeIdx& ccMazeIdx2, - std::map& mazeIdx2unConnPinGCellNode); + boost::container::flat_set& + unConnPinGCellNodes, + boost::container::flat_map& + mazeIdx2unConnPinGCellNode, + boost::container::flat_map& mazeIdx2endPointNode); + void routeNet_setSrc(grNet* net, + boost::container::flat_set& + unConnPinGCellNodes, + boost::container::flat_map& + mazeIdx2unConnPinGCellNode, + std::vector& connComps, + FlexMazeIdx& ccMazeIdx1, + FlexMazeIdx& ccMazeIdx2, + Point& centerPt); + grNode* routeNet_getNextDst(FlexMazeIdx& ccMazeIdx1, + FlexMazeIdx& ccMazeIdx2, + boost::container::flat_map& + mazeIdx2unConnPinGCellNode); grNode* routeNet_postAstarUpdate( std::vector& path, std::vector& connComps, - std::set& unConnPinGCellNodes, - std::map& mazeIdx2unConnPinGCellNode); + boost::container::flat_set& + unConnPinGCellNodes, + boost::container::flat_map& + mazeIdx2unConnPinGCellNode); void routeNet_postAstarWritePath( grNet* net, std::vector& points, grNode* leaf, - std::map& mazeIdx2endPointNode); + boost::container::flat_map& mazeIdx2endPointNode); grNode* routeNet_postAstarWritePath_splitPathSeg(grNode* child, grNode* parent, const Point& breakPt); @@ -454,15 +477,20 @@ class FlexGRWorker void route_decayHistCost(); // end - void endGetModNets(std::set& modNets); - void endRemoveNets(const std::set& modNets); - void endRemoveNets_objs(const std::set& modNets); + void endGetModNets( + boost::container::flat_set& modNets); + void endRemoveNets( + const boost::container::flat_set& modNets); + void endRemoveNets_objs( + const boost::container::flat_set& modNets); void endRemoveNets_pathSeg(grPathSeg* pathSeg); void endRemoveNets_via(grVia* via); - void endRemoveNets_nodes(const std::set& modNets); + void endRemoveNets_nodes( + const boost::container::flat_set& modNets); void endRemoveNets_nodes_net(grNet* net, frNet* fnet); void endRemoveNets_node(frNode* node); - void endAddNets(std::set& modNets); + void endAddNets( + boost::container::flat_set& modNets); void endAddNets_stitchRouteBound(grNet* net); void endAddNets_stitchRouteBound_node(grNode* node); void endAddNets_addNet(grNet* net, frNet* fnet); diff --git a/src/drt/src/gr/FlexGRCMap.cpp b/src/drt/src/gr/FlexGRCMap.cpp index a858190c9dc..3b81b4c8fa4 100644 --- a/src/drt/src/gr/FlexGRCMap.cpp +++ b/src/drt/src/gr/FlexGRCMap.cpp @@ -190,7 +190,7 @@ void FlexGRCMap::init() // update demand for fixed objects (only for pref routing direction) cmapLayerIdx = 0; - std::set trackLocs; + boost::container::flat_set trackLocs; std::vector> queryResult; auto regionQuery = design_->getRegionQuery(); unsigned numBlkTracks = 0; @@ -328,11 +328,11 @@ void FlexGRCMap::init() unsigned FlexGRCMap::getNumBlkTracks( bool isHorz, frLayerNum lNum, - const std::set& trackLocs, + const boost::container::flat_set& trackLocs, const std::vector>& results, const frCoord bloatDist = 0) { - std::set openTrackLocs = trackLocs; + boost::container::flat_set openTrackLocs = trackLocs; frCoord low, high; frCoord actBloatDist; auto layer = getDesign()->getTech()->getLayer(lNum); @@ -414,7 +414,7 @@ unsigned FlexGRCMap::getNumPins( const std::vector>& results) { unsigned numPins = 0; - std::set pins; + boost::container::flat_set pins; for (auto& [box, obj] : results) { if (obj->typeId() == frcInstTerm) { auto instTerm = static_cast(obj); @@ -437,7 +437,7 @@ void FlexGRCMap::getTrackLocs( bool isHorz, frCoord low, frCoord high, - std::set& trackLocs) + boost::container::flat_set& trackLocs) { for (auto& tp : tps) { bool skip = true; diff --git a/src/drt/src/gr/FlexGRCMap.h b/src/drt/src/gr/FlexGRCMap.h index 919c6e4d157..9ffbe8dfc07 100644 --- a/src/drt/src/gr/FlexGRCMap.h +++ b/src/drt/src/gr/FlexGRCMap.h @@ -66,7 +66,10 @@ class FlexGRCMap frLayerNum getNumLayers() { return numLayers_; } - std::map getZMap() { return zMap_; } + boost::container::flat_map getZMap() + { + return zMap_; + } unsigned getSupply(unsigned x, unsigned y, @@ -524,7 +527,7 @@ class FlexGRCMap // [15-8] cong history // [3] block E [2] block N [1] overflow E; [0] overflow N std::vector bits_; - std::map zMap_; + boost::container::flat_map zMap_; std::vector layerTrackPitches_; std::vector layerLine2ViaPitches_; std::vector layerPitches_; @@ -644,14 +647,14 @@ class FlexGRCMap unsigned getNumBlkTracks( bool isHorz, frLayerNum lNum, - const std::set& trackLocs, + const boost::container::flat_set& trackLocs, const std::vector>& results, frCoord bloatDist); void getTrackLocs(const std::vector>& tps, bool isHorz, frCoord low, frCoord high, - std::set& trackLocs); + boost::container::flat_set& trackLocs); unsigned getNumPins( const std::vector>& results); frCoord calcBloatDist(frBlockObject* obj, diff --git a/src/drt/src/gr/FlexGRGridGraph.cpp b/src/drt/src/gr/FlexGRGridGraph.cpp index 5634a4898b2..675583d74a4 100644 --- a/src/drt/src/gr/FlexGRGridGraph.cpp +++ b/src/drt/src/gr/FlexGRGridGraph.cpp @@ -47,7 +47,7 @@ void FlexGRGridGraph::init() void FlexGRGridGraph::initCoords() { - std::map zMap; + boost::container::flat_map zMap; Point gcellIdxLL = getGRWorker()->getRouteGCellIdxLL(); Point gcellIdxUR = getGRWorker()->getRouteGCellIdxUR(); // xCoords diff --git a/src/drt/src/gr/FlexGR_end.cpp b/src/drt/src/gr/FlexGR_end.cpp index cf42bb8185e..38f8b1e73b9 100644 --- a/src/drt/src/gr/FlexGR_end.cpp +++ b/src/drt/src/gr/FlexGR_end.cpp @@ -33,7 +33,7 @@ namespace drt { void FlexGRWorker::end() { - std::set modNets; + boost::container::flat_set modNets; endGetModNets(modNets); endRemoveNets(modNets); endAddNets(modNets); @@ -44,7 +44,8 @@ void FlexGRWorker::end() cleanup(); } -void FlexGRWorker::endGetModNets(std::set& modNets) +void FlexGRWorker::endGetModNets( + boost::container::flat_set& modNets) { for (auto& net : nets_) { if (net->isModified()) { @@ -60,14 +61,14 @@ void FlexGRWorker::endGetModNets(std::set& modNets) } void FlexGRWorker::endRemoveNets( - const std::set& modNets) + const boost::container::flat_set& modNets) { endRemoveNets_objs(modNets); endRemoveNets_nodes(modNets); } void FlexGRWorker::endRemoveNets_objs( - const std::set& modNets) + const boost::container::flat_set& modNets) { // remove pathSeg and via (all nets based) std::vector result; @@ -115,7 +116,7 @@ void FlexGRWorker::endRemoveNets_via(grVia* via) } void FlexGRWorker::endRemoveNets_nodes( - const std::set& modNets) + const boost::container::flat_set& modNets) { for (auto fnet : modNets) { for (auto net : owner2nets_[fnet]) { @@ -165,7 +166,8 @@ void FlexGRWorker::endRemoveNets_nodes_net(grNet* net, frNet* fnet) } } -void FlexGRWorker::endAddNets(std::set& modNets) +void FlexGRWorker::endAddNets( + boost::container::flat_set& modNets) { for (auto fnet : modNets) { for (auto net : owner2nets_[fnet]) { diff --git a/src/drt/src/gr/FlexGR_init.cpp b/src/drt/src/gr/FlexGR_init.cpp index ba9ef23e0b3..b6b8e064168 100644 --- a/src/drt/src/gr/FlexGR_init.cpp +++ b/src/drt/src/gr/FlexGR_init.cpp @@ -454,8 +454,9 @@ void FlexGRWorker::init() void FlexGRWorker::initNets() { - std::set nets; - std::map, frBlockObjectComp> netRoots; + boost::container::flat_set nets; + boost::container::flat_map, frBlockObjectComp> + netRoots; initNets_roots(nets, netRoots); initNets_searchRepair(nets, netRoots); @@ -464,8 +465,9 @@ void FlexGRWorker::initNets() // get all roots of subnets void FlexGRWorker::initNets_roots( - std::set& nets, - std::map, frBlockObjectComp>& netRoots) + boost::container::flat_set& nets, + boost::container::flat_map, frBlockObjectComp>& + netRoots) { std::vector result; getRegionQuery()->queryGRObj(routeBox_, result); @@ -496,8 +498,9 @@ void FlexGRWorker::initNets_roots( // root (i.e., outgoing edge) void FlexGRWorker::initNetObjs_roots_pathSeg( grPathSeg* pathSeg, - std::set& nets, - std::map, frBlockObjectComp>& netRoots) + boost::container::flat_set& nets, + boost::container::flat_map, frBlockObjectComp>& + netRoots) { auto net = pathSeg->getNet(); nets.insert(net); @@ -522,8 +525,9 @@ void FlexGRWorker::initNetObjs_roots_pathSeg( // grandparent is a subnet root void FlexGRWorker::initNetObjs_roots_via( grVia* via, - std::set& nets, - std::map, frBlockObjectComp>& netRoots) + boost::container::flat_set& nets, + boost::container::flat_map, frBlockObjectComp>& + netRoots) { auto net = via->getNet(); nets.insert(net); @@ -536,8 +540,9 @@ void FlexGRWorker::initNetObjs_roots_via( } void FlexGRWorker::initNets_searchRepair( - std::set& nets, - std::map, frBlockObjectComp>& netRoots) + boost::container::flat_set& nets, + boost::container::flat_map, frBlockObjectComp>& + netRoots) { for (auto net : nets) { initNet(net, netRoots[net]); @@ -546,7 +551,7 @@ void FlexGRWorker::initNets_searchRepair( void FlexGRWorker::initNet(frNet* net, const std::vector& netRoots) { - std::set uniqueRoots; + boost::container::flat_set uniqueRoots; for (auto fRoot : netRoots) { if (uniqueRoots.find(fRoot) != uniqueRoots.end()) { continue; @@ -573,9 +578,10 @@ void FlexGRWorker::initNet(frNet* net, const std::vector& netRoots) void FlexGRWorker::initNet_initNodes(grNet* net, frNode* fRoot) { // map from loc to gcell node - // std::map, grNode*> loc2GCellNode; + // boost::container::flat_map, grNode*> + // loc2GCellNode; std::vector> pinNodePairs; - std::map gr2FrPinNode; + boost::container::flat_map gr2FrPinNode; // parent grNode to children frNode std::deque> nodeQ; nodeQ.emplace_back(nullptr, fRoot); @@ -815,9 +821,10 @@ void FlexGRWorker::initNet_updateCMap(grNet* net, bool isAdd) void FlexGRWorker::initNet_initPinGCellNodes(grNet* net) { std::vector> pinGCellNodePairs; - std::map, frBlockObjectComp> gcell2PinNodes; + boost::container::flat_map, frBlockObjectComp> + gcell2PinNodes; std::vector pinGCellNodes; - std::map midx2PinGCellNode; + boost::container::flat_map midx2PinGCellNode; grNode* rootGCellNode = nullptr; std::deque nodeQ; @@ -1047,7 +1054,8 @@ void FlexGRWorker::initNets_printNet(grNet* net) } void FlexGRWorker::initNets_printFNets( - std::map, frBlockObjectComp>& netRoots) + boost::container::flat_map, frBlockObjectComp>& + netRoots) { std::cout << std::endl << "printing frNets\n"; for (auto& [net, roots] : netRoots) { diff --git a/src/drt/src/gr/FlexGR_maze.cpp b/src/drt/src/gr/FlexGR_maze.cpp index adba80981bb..8347685f99c 100644 --- a/src/drt/src/gr/FlexGR_maze.cpp +++ b/src/drt/src/gr/FlexGR_maze.cpp @@ -236,7 +236,7 @@ void FlexGRWorker::mazeNetInit(grNet* net) void FlexGRWorker::mazeNetInit_addHistCost(grNet* net) { // add history cost for all gcells that this net previously visited - std::set pts; + boost::container::flat_set pts; for (auto& uptr : net->getRouteConnFigs()) { if (uptr->typeId() == grcPathSeg) { auto cptr = static_cast(uptr.get()); @@ -275,7 +275,7 @@ void FlexGRWorker::mazeNetInit_addHistCost(grNet* net) void FlexGRWorker::mazeNetInit_decayHistCost(grNet* net) { // decay history cost for all gcells that this net previously visited - std::set pts; + boost::container::flat_set pts; for (auto& uptr : net->getRouteConnFigs()) { if (uptr->typeId() == grcPathSeg) { auto cptr = static_cast(uptr.get()); @@ -363,7 +363,7 @@ void FlexGRWorker::mazeNetInit_removeNetNodes(grNet* net) { // remove non-terminal gcell nodes std::deque nodeQ; - std::set terminalNodes; + boost::container::flat_set terminalNodes; grNode* root = nullptr; for (auto& [pinNode, gcellNode] : net->getPinGCellNodePairs()) { @@ -427,9 +427,9 @@ bool FlexGRWorker::routeNet(grNet* net) return true; } - std::set unConnPinGCellNodes; - std::map mazeIdx2unConnPinGCellNode; - std::map mazeIdx2endPointNode; + boost::container::flat_set unConnPinGCellNodes; + boost::container::flat_map mazeIdx2unConnPinGCellNode; + boost::container::flat_map mazeIdx2endPointNode; routeNet_prep(net, unConnPinGCellNodes, mazeIdx2unConnPinGCellNode, @@ -475,9 +475,10 @@ bool FlexGRWorker::routeNet(grNet* net) void FlexGRWorker::routeNet_prep( grNet* net, - std::set& unConnPinGCellNodes, - std::map& mazeIdx2unConnPinGCellNode, - std::map& mazeIdx2endPointNode) + boost::container::flat_set& unConnPinGCellNodes, + boost::container::flat_map& + mazeIdx2unConnPinGCellNode, + boost::container::flat_map& mazeIdx2endPointNode) { for (auto pinGCellNode : net->getPinGCellNodes()) { auto loc = pinGCellNode->getLoc(); @@ -550,8 +551,9 @@ void FlexGRWorker::routeNet_printNet(grNet* net) // current set subnet root to be src with the absence of reroot void FlexGRWorker::routeNet_setSrc( grNet* net, - std::set& unConnPinGCellNodes, - std::map& mazeIdx2unConnPinGCellNode, + boost::container::flat_set& unConnPinGCellNodes, + boost::container::flat_map& + mazeIdx2unConnPinGCellNode, std::vector& connComps, FlexMazeIdx& ccMazeIdx1, FlexMazeIdx& ccMazeIdx2, @@ -599,7 +601,8 @@ void FlexGRWorker::routeNet_setSrc( grNode* FlexGRWorker::routeNet_getNextDst( FlexMazeIdx& ccMazeIdx1, FlexMazeIdx& ccMazeIdx2, - std::map& mazeIdx2unConnPinGCellNode) + boost::container::flat_map& + mazeIdx2unConnPinGCellNode) { Point pt; Point ll, ur; @@ -647,10 +650,11 @@ grNode* FlexGRWorker::routeNet_getNextDst( grNode* FlexGRWorker::routeNet_postAstarUpdate( std::vector& path, std::vector& connComps, - std::set& unConnPinGCellNodes, - std::map& mazeIdx2unConnPinGCellNode) + boost::container::flat_set& unConnPinGCellNodes, + boost::container::flat_map& + mazeIdx2unConnPinGCellNode) { - std::set localConnComps; + boost::container::flat_set localConnComps; grNode* leaf = nullptr; if (!path.empty()) { auto mi = path[0]; @@ -719,7 +723,7 @@ void FlexGRWorker::routeNet_postAstarWritePath( grNet* net, std::vector& points, grNode* leaf, - std::map& mazeIdx2endPointNode) + boost::container::flat_map& mazeIdx2endPointNode) { if (points.empty()) { } diff --git a/src/drt/src/gr/FlexGR_topo.cpp b/src/drt/src/gr/FlexGR_topo.cpp index 8b25bd38eea..8c3ccafa7a1 100644 --- a/src/drt/src/gr/FlexGR_topo.cpp +++ b/src/drt/src/gr/FlexGR_topo.cpp @@ -54,8 +54,11 @@ void FlexGR::genSTTopology_FLUTE(std::vector& pinGCellNodes, stt_builder_->setAlpha(0); auto fluteTree = stt_builder_->makeSteinerTree(xs, ys, 0); - std::map pinGCell2Nodes, steinerGCell2Nodes; - std::map, frBlockObjectComp> + boost::container::flat_map pinGCell2Nodes, steinerGCell2Nodes; + boost::container::flat_map< + frNode*, + boost::container::flat_set, + frBlockObjectComp> adjacencyList; for (auto pinNode : pinGCellNodes) { @@ -128,7 +131,7 @@ void FlexGR::genSTTopology_FLUTE(std::vector& pinGCellNodes, } // build tree - std::set visitedNodes; + boost::container::flat_set visitedNodes; std::deque nodeQueue; nodeQueue.push_front(root); @@ -340,9 +343,13 @@ unsigned FlexGR::genSTTopology_HVW_levelOvlp(frNode* currNode, unsigned comb) { unsigned overlap = 0; - std::map>> + boost::container::flat_map< + frCoord, + boost::icl::interval_map>> horzIntvMaps; // denoted by children node index - std::map>> + boost::container::flat_map< + frCoord, + boost::icl::interval_map>> vertIntvMaps; std::pair horzIntv, vertIntv; @@ -353,7 +360,7 @@ unsigned FlexGR::genSTTopology_HVW_levelOvlp(frNode* currNode, if (parent) { genSTTopology_HVW_levelOvlp_helper( parent, currNode, isCurrU, horzIntv, vertIntv, turnLoc); - std::set currNodeSet; + boost::container::flat_set currNodeSet; currNodeSet.insert(currNode); if (horzIntv.first != horzIntv.second) { horzIntvMaps[turnLoc.y()] += std::make_pair( @@ -373,7 +380,7 @@ unsigned FlexGR::genSTTopology_HVW_levelOvlp(frNode* currNode, bool isCurrU = (comb >> combIdx) & 1; genSTTopology_HVW_levelOvlp_helper( currNode, child, isCurrU, horzIntv, vertIntv, turnLoc); - std::set childSet; + boost::container::flat_set childSet; childSet.insert(child); if (horzIntv.first != horzIntv.second) { horzIntvMaps[turnLoc.y()] += std::make_pair( @@ -495,8 +502,9 @@ void FlexGR::genSTTopology_build_tree(std::vector& pinNodes, std::vector& isU, std::vector& steinerNodes) { - std::map> horzIntvs, vertIntvs; - std::map pinGCell2Nodes, steinerGCell2Nodes; + boost::container::flat_map> + horzIntvs, vertIntvs; + boost::container::flat_map pinGCell2Nodes, steinerGCell2Nodes; genSTTopology_build_tree_mergeSeg(pinNodes, isU, horzIntvs, vertIntvs); @@ -530,8 +538,10 @@ void FlexGR::genSTTopology_build_tree(std::vector& pinNodes, void FlexGR::genSTTopology_build_tree_mergeSeg( std::vector& pinNodes, std::vector& isU, - std::map>& horzIntvs, - std::map>& vertIntvs) + boost::container::flat_map>& + horzIntvs, + boost::container::flat_map>& + vertIntvs) { Point turnLoc; std::pair horzIntv, vertIntv; @@ -555,21 +565,29 @@ void FlexGR::genSTTopology_build_tree_mergeSeg( void FlexGR::genSTTopology_build_tree_splitSeg( std::vector& pinNodes, - std::map& pinGCell2Nodes, - std::map>& horzIntvs, - std::map>& vertIntvs, - std::map& steinerGCell2Nodes, + boost::container::flat_map& pinGCell2Nodes, + boost::container::flat_map>& + horzIntvs, + boost::container::flat_map>& + vertIntvs, + boost::container::flat_map& steinerGCell2Nodes, std::vector& steinerNodes) { - std::map>> horzSegs, vertSegs; - std::map, frBlockObjectComp> + boost::container:: + flat_map>> + horzSegs, vertSegs; + boost::container::flat_map< + frNode*, + boost::container::flat_set, + frBlockObjectComp> adjacencyList; auto root = pinNodes[0]; auto net = root->getNet(); // horz first dimension is y coord, second dimension is x coord - std::map> horzPinHelper, vertPinHelper; + boost::container::flat_map> + horzPinHelper, vertPinHelper; // init for (const auto& [loc, node] : pinGCell2Nodes) { horzPinHelper[loc.y()].insert(loc.x()); @@ -579,7 +597,7 @@ void FlexGR::genSTTopology_build_tree_splitSeg( // trackIdx == y coord for (auto& [trackIdx, currIntvs] : horzIntvs) { for (auto& intv : currIntvs) { - std::set lineIdx; + boost::container::flat_set lineIdx; auto beginIdx = intv.lower(); auto endIdx = intv.upper(); // split by vertSeg @@ -621,7 +639,7 @@ void FlexGR::genSTTopology_build_tree_splitSeg( // trackIdx == x coord for (auto& [trackIdx, currIntvs] : vertIntvs) { for (auto& intv : currIntvs) { - std::set lineIdx; + boost::container::flat_set lineIdx; auto beginIdx = intv.lower(); auto endIdx = intv.upper(); // split by horzSeg @@ -791,7 +809,7 @@ void FlexGR::genSTTopology_build_tree_splitSeg( node->reset(); } - std::set visitedNodes; + boost::container::flat_set visitedNodes; std::deque nodeQueue; nodeQueue.push_front(root); diff --git a/src/drt/src/io/GuideProcessor.cpp b/src/drt/src/io/GuideProcessor.cpp index c318b710923..7ccbda07632 100644 --- a/src/drt/src/io/GuideProcessor.cpp +++ b/src/drt/src/io/GuideProcessor.cpp @@ -116,7 +116,7 @@ bool isPinCoveredByGuides(const frBlockObject* pin, */ void findIntersectingGuides(const int x, const int y, - std::set& out_guides, + boost::container::flat_set& out_guides, const std::vector& guides, frDesign* design) { @@ -139,10 +139,11 @@ void findIntersectingGuides(const int x, * intersecting guides with all gcells the pin touches * @return The chosen pinShape's gcell index */ -Point3D findBestPinLocation(frDesign* design, - frBlockObject* pin, - const std::vector& guides, - std::set& candidate_guides_indices) +Point3D findBestPinLocation( + frDesign* design, + frBlockObject* pin, + const std::vector& guides, + boost::container::flat_set& candidate_guides_indices) { Rect pin_bbox = getPinBBox(pin); // adjusting pin bounding box as pins tangent to gcell aren't considered as @@ -205,10 +206,11 @@ Point3D findBestPinLocation(frDesign* design, * @param best_pin_loc_coords The gcell center point of the chosen pin shape * */ -int findClosestGuide(const Point3D& best_pin_loc_coords, - const std::vector& guides, - const std::set& candidate_guides_indices, - const frCoord layer_change_penalty) +int findClosestGuide( + const Point3D& best_pin_loc_coords, + const std::vector& guides, + const boost::container::flat_set& candidate_guides_indices, + const frCoord layer_change_penalty) { int closest_guide_idx = -1; int dist = 0; @@ -692,7 +694,7 @@ void GuideProcessor::buildGCellPatterns_helper(frCoord& GCELLGRIDX, void GuideProcessor::buildGCellPatterns_getWidth(frCoord& GCELLGRIDX, frCoord& GCELLGRIDY) { - std::map guideGridXMap, guideGridYMap; + boost::container::flat_map guideGridXMap, guideGridYMap; // get GCell size information loop for (auto& [netName, rects] : tmp_guides_) { for (auto& rect : rects) { @@ -748,7 +750,7 @@ void GuideProcessor::buildGCellPatterns_getOffset(frCoord GCELLGRIDX, frCoord& GCELLOFFSETX, frCoord& GCELLOFFSETY) { - std::map guideOffsetXMap, guideOffsetYMap; + boost::container::flat_map guideOffsetXMap, guideOffsetYMap; // get GCell offset information loop for (auto& [netName, rects] : tmp_guides_) { for (auto& rect : rects) { @@ -934,7 +936,7 @@ void GuideProcessor::patchGuides(frNet* net, "Pin {} not in any guide. Attempting to patch guides to cover " "(at least part of) the pin.", name); - std::set candidate_guides_indices; + boost::container::flat_set candidate_guides_indices; const Point3D best_pin_loc_idx = findBestPinLocation(getDesign(), pin, guides, candidate_guides_indices); // The x/y/z coordinates of best_pin_loc_idx @@ -990,15 +992,16 @@ namespace split { * @param split_indices The returned set of indices where there exists pins. */ void splitByPins( - const std::vector>>& - pin_helper, + const std::vector>>& pin_helper, const frLayerNum layer_num, const bool is_horizontal, const frCoord track_idx, const frCoord begin_idx, const frCoord end_idx, - frBlockObjectMap>& pin_gcell_map, - std::set& split_indices) + frBlockObjectMap>& pin_gcell_map, + boost::container::flat_set& split_indices) { const auto& layer_pins = pin_helper.at(layer_num); const auto& track_it = layer_pins.find(track_idx); @@ -1046,12 +1049,13 @@ void splitByPins( * @param split_indices A set to store the indices where intersections are * found. */ -void splitByLayerIntersection(const frLayerNum layer_num, - const TrackIntervalsByLayer& intvs, - const frCoord track_idx, - const frCoord begin_idx, - const frCoord end_idx, - std::set& split_indices) +void splitByLayerIntersection( + const frLayerNum layer_num, + const TrackIntervalsByLayer& intvs, + const frCoord track_idx, + const frCoord begin_idx, + const frCoord end_idx, + boost::container::flat_set& split_indices) { if (layer_num < 0 || layer_num >= intvs.size()) { return; @@ -1107,13 +1111,15 @@ void addSplitRect(const frCoord track_idx, void GuideProcessor::genGuides_split( std::vector& rects, const TrackIntervalsByLayer& intvs, - const std::map& gcell_pin_map, - frBlockObjectMap>& pin_gcell_map, + const boost::container::flat_map& gcell_pin_map, + frBlockObjectMap>& pin_gcell_map, bool first_iter) const { rects.clear(); // layer_num->track_idx->routing_dir_track_idx->set of pins - std::vector>> + std::vector>> pin_helper(getTech()->getLayers().size()); for (const auto& [point, pins] : gcell_pin_map) { if (getTech()->getLayer(point.z())->getDir() @@ -1132,7 +1138,7 @@ void GuideProcessor::genGuides_split( for (const auto& intv : curr_intvs) { auto begin_idx = intv.lower(); auto end_idx = intv.upper(); - std::set split_indices; + boost::container::flat_set split_indices; // hardcode layerNum <= VIA_ACCESS_LAYERNUM not used for GR if (first_iter && layer_num <= VIA_ACCESS_LAYERNUM) { // split by pin @@ -1210,7 +1216,7 @@ void GuideProcessor::genGuides_split( } void GuideProcessor::mapPinShapesToGCells( - std::map& gcell_pin_map, + boost::container::flat_map& gcell_pin_map, frBlockObject* term) const { const auto pin_shapes = getPinShapes(term); @@ -1231,7 +1237,7 @@ void GuideProcessor::mapPinShapesToGCells( void GuideProcessor::initGCellPinMap( const frNet* net, - std::map& gcell_pin_map) const + boost::container::flat_map& gcell_pin_map) const { for (auto instTerm : net->getInstTerms()) { if (DBPROCESSNODE == "GF14_13M_3Mx_2Cx_4Kx_2Hx_2Gx_LB" @@ -1250,7 +1256,7 @@ void GuideProcessor::initGCellPinMap( } bool GuideProcessor::mapITermAccessPointsToGCells( - std::map& gcell_pin_map, + boost::container::flat_map& gcell_pin_map, frInstTerm* inst_term) const { const size_t num_pins = inst_term->getTerm()->getPins().size(); @@ -1274,7 +1280,7 @@ bool GuideProcessor::mapITermAccessPointsToGCells( } bool GuideProcessor::mapBTermAccessPointsToGCells( - std::map& gcell_pin_map, + boost::container::flat_map& gcell_pin_map, frBTerm* term) const { int pins_covered = 0; @@ -1298,7 +1304,7 @@ bool GuideProcessor::mapBTermAccessPointsToGCells( void GuideProcessor::initPinGCellMap( frNet* net, - frBlockObjectMap>& pin_gcell_map) + frBlockObjectMap>& pin_gcell_map) { for (auto& instTerm : net->getInstTerms()) { pin_gcell_map[instTerm]; @@ -1367,8 +1373,8 @@ void GuideProcessor::genGuides(frNet* net, std::vector& rects) } genGuides_prep(rects, intvs); - std::map gcell_pin_map; - frBlockObjectMap> pin_gcell_map; + boost::container::flat_map gcell_pin_map; + frBlockObjectMap> pin_gcell_map; initGCellPinMap(net, gcell_pin_map); initPinGCellMap(net, pin_gcell_map); @@ -1439,7 +1445,7 @@ GuidePathFinder::GuidePathFinder( frNet* net, const bool force_feed_through, const std::vector& rects, - const frBlockObjectMap>& pin_gcell_map) + const frBlockObjectMap>& pin_gcell_map) : design_(design), logger_(logger), net_(net), @@ -1454,7 +1460,7 @@ GuidePathFinder::GuidePathFinder( void GuidePathFinder::buildNodeMap( const std::vector& rects, - const frBlockObjectMap>& pin_gcell_map) + const frBlockObjectMap>& pin_gcell_map) { node_map_.clear(); for (int i = 0; i < (int) rects.size(); i++) { @@ -1476,7 +1482,7 @@ void GuidePathFinder::buildNodeMap( std::vector> GuidePathFinder::getPinToGCellList( const std::vector& rects, - const frBlockObjectMap>& pin_gcell_map, + const frBlockObjectMap>& pin_gcell_map, const std::vector& pins) const { std::vector> pin_to_gcell(getPinCount()); @@ -1551,7 +1557,7 @@ void GuidePathFinder::updateNodeMap( void GuidePathFinder::commitPathToGuides( std::vector& rects, - const frBlockObjectMap>& pin_gcell_map, + const frBlockObjectMap>& pin_gcell_map, std::vector>& gr_pins) { std::vector pins; diff --git a/src/drt/src/io/GuideProcessor.h b/src/drt/src/io/GuideProcessor.h index 05054068f6e..eadbca2a369 100644 --- a/src/drt/src/io/GuideProcessor.h +++ b/src/drt/src/io/GuideProcessor.h @@ -40,7 +40,8 @@ namespace drt::io { -using TrackIntervals = std::map>; +using TrackIntervals + = boost::container::flat_map>; using TrackIntervalsByLayer = std::vector; class GuideProcessor @@ -49,7 +50,7 @@ class GuideProcessor GuideProcessor(frDesign* designIn, odb::dbDatabase* dbIn, utl::Logger* loggerIn) - : design_(designIn), logger_(loggerIn), db_(dbIn){}; + : design_(designIn), logger_(loggerIn), db_(dbIn) {}; /** * @brief Reads guides from odb and fill the tmp_guides_ list of unprocessed * guides @@ -167,11 +168,13 @@ class GuideProcessor * @param first_iter True if this the first iteration. * */ - void genGuides_split(std::vector& rects, - const TrackIntervalsByLayer& intvs, - const std::map& gcell_pin_map, - frBlockObjectMap>& pin_gcell_map, - bool first_iter) const; + void genGuides_split( + std::vector& rects, + const TrackIntervalsByLayer& intvs, + const boost::container::flat_map& + gcell_pin_map, + frBlockObjectMap>& pin_gcell_map, + bool first_iter) const; /** * Initializes a map of gcell location to set of pins * @@ -182,9 +185,9 @@ class GuideProcessor * considered by this function. * @param gcell_pin_map A map to be populated by the result of this function. */ - void initGCellPinMap( - const frNet* net, - std::map& gcell_pin_map) const; + void initGCellPinMap(const frNet* net, + boost::container::flat_map& + gcell_pin_map) const; /** * Populates gcell_pin_map with the values associated with the passed term * based on pin shapes. @@ -196,8 +199,9 @@ class GuideProcessor * @param gcell_pin_map The map to be populated with the results. * @param term The current pin we are processing. */ - void mapPinShapesToGCells(std::map& gcell_pin_map, - frBlockObject* term) const; + void mapPinShapesToGCells( + boost::container::flat_map& gcell_pin_map, + frBlockObject* term) const; /** * Populates gcell_pin_map with the values associated with the passed ITerm * based on preferred access points. @@ -211,7 +215,7 @@ class GuideProcessor * @returns True if all pins' preferred access points are considered. */ bool mapITermAccessPointsToGCells( - std::map& gcell_pin_map, + boost::container::flat_map& gcell_pin_map, frInstTerm* inst_term) const; /** * Populates gcell_pin_map with the values associated with the passed BTerm @@ -222,17 +226,19 @@ class GuideProcessor * @returns True if all pins' preferred access points are considered. */ bool mapBTermAccessPointsToGCells( - std::map& gcell_pin_map, + boost::container::flat_map& gcell_pin_map, frBTerm* term) const; - void initPinGCellMap(frNet* net, - frBlockObjectMap>& pin_gcell_map); + void initPinGCellMap( + frNet* net, + frBlockObjectMap>& pin_gcell_map); // write guide void saveGuidesUpdates(); frDesign* design_; Logger* logger_; odb::dbDatabase* db_; - std::map, frBlockObjectComp> tmp_guides_; + boost::container::flat_map, frBlockObjectComp> + tmp_guides_; std::vector> tmpGRPins_; }; @@ -259,7 +265,8 @@ class GuidePathFinder frNet* net, bool force_feed_through, const std::vector& rects, - const frBlockObjectMap>& pin_gcell_map); + const frBlockObjectMap>& + pin_gcell_map); int getNodeCount() const { return node_count_; } int getGuideCount() const { return guide_count_; } int getPinCount() const { return node_count_ - guide_count_; } @@ -294,7 +301,8 @@ class GuidePathFinder */ void commitPathToGuides( std::vector& rects, - const frBlockObjectMap>& pin_gcell_map, + const frBlockObjectMap>& + pin_gcell_map, std::vector>& gr_pins); private: @@ -321,7 +329,8 @@ class GuidePathFinder * @param pin_gcell_map A map of pins and their corresponding GCell indices. */ void buildNodeMap(const std::vector& rects, - const frBlockObjectMap>& pin_gcell_map); + const frBlockObjectMap>& + pin_gcell_map); /** * @brief Constructs the adjacency list for the graph of guides and pins. * @@ -379,7 +388,8 @@ class GuidePathFinder */ std::vector> getPinToGCellList( const std::vector& rects, - const frBlockObjectMap>& pin_gcell_map, + const frBlockObjectMap>& + pin_gcell_map, const std::vector& pins) const; /** * @brief Updates the node map with pins and guides. @@ -413,7 +423,8 @@ class GuidePathFinder Logger* logger_{nullptr}; frNet* net_{nullptr}; bool force_feed_through_{false}; - std::map> node_map_; + boost::container::flat_map> + node_map_; int guide_count_{0}; int node_count_{0}; bool allow_warnings_{false}; diff --git a/src/drt/src/io/io.cpp b/src/drt/src/io/io.cpp index b33de5f8da2..4c9a62fa39c 100644 --- a/src/drt/src/io/io.cpp +++ b/src/drt/src/io/io.cpp @@ -337,7 +337,9 @@ void io::Parser::setVias(odb::dbBlock* block) utl::DRT, 337, "Duplicated via definition for {}", via->getName()); } } else { - std::map> lNum2Int; + boost::container::flat_map> + lNum2Int; for (auto box : via->getBoxes()) { if (tech_->name2layer_.find(box->getTechLayer()->getName()) == tech_->name2layer_.end()) { @@ -1181,7 +1183,7 @@ void io::Parser::setBTerms_addPinFig_helper(frBPin* pinIn, void io::Parser::setAccessPoints(odb::dbDatabase* db) { - std::map ap_map; + boost::container::flat_map ap_map; for (auto& master : design_->getMasters()) { auto db_master = db->findMaster(master->getName().c_str()); for (auto& term : master->getTerms()) { @@ -1229,7 +1231,7 @@ void io::Parser::setAccessPoints(odb::dbDatabase* db) } auto db_aps = db_term->getPrefAccessPoints(); - std::map db_aps_map; + boost::container::flat_map db_aps_map; for (auto db_ap : db_aps) { if (ap_map.find(db_ap) == ap_map.end()) { logger_->error(DRT, @@ -1389,7 +1391,7 @@ void io::Parser::setRoutingLayerProperties(odb::dbTechLayer* layer, std::string colName("PARALLELRUNLENGTH"); frCollection rowVals, colVals; frCollection> tblVals; - std::map> ewVals; + boost::container::flat_map> ewVals; std::map> _ewVals; rule->getTable(rowVals, colVals, tblVals, _ewVals); for (auto& [key, value] : _ewVals) { @@ -2753,7 +2755,7 @@ void io::Parser::setTechViaRules(odb::dbTech* db_tech) if (count != 3) { logger_->error(DRT, 128, "Unsupported viarule {}.", rule->getName()); } - std::map lNum2Int; + boost::container::flat_map lNum2Int; for (int i = 0; i < count; i++) { auto layerRule = rule->getViaLayerRule(i); std::string layerName = layerRule->getLayer()->getName(); @@ -2865,7 +2867,7 @@ void io::Parser::setTechViaRules(odb::dbTech* db_tech) void io::Parser::setTechVias(odb::dbTech* db_tech) { for (auto via : db_tech->getVias()) { - std::map lNum2Int; + boost::container::flat_map lNum2Int; bool has_unknown_layer = false; for (auto box : via->getBoxes()) { std::string layerName = box->getTechLayer()->getName(); @@ -3098,7 +3100,8 @@ void io::Writer::splitVia_helper( frCoord x, frCoord y, std::vector>>>>& + boost::container::flat_map>>>>& mergedPathSegs) { if (layerNum >= 0 && layerNum < (int) (getTech()->getLayers().size()) @@ -3138,11 +3141,14 @@ void io::Writer::mergeSplitConnFigs( // std::cout <, - std::map, bool>>>> + boost::container::flat_map< + std::tuple, + boost::container::flat_map< + frCoord, + std::vector, bool>>>> pathSegMergeMap; - std::map, std::shared_ptr> + boost::container::flat_map, + std::shared_ptr> viaMergeMap; for (auto& connFig : connFigs) { if (connFig->typeId() == frcPathSeg) { @@ -3174,11 +3180,14 @@ void io::Writer::mergeSplitConnFigs( } // merge pathSeg - std::map>> tmp1; - std::vector>>> tmp2( - 2, tmp1); - std::vector< - std::vector>>>> + boost::container::flat_map>> + tmp1; + std::vector>>> + tmp2(2, tmp1); + std::vector>>>> mergedPathSegs(getTech()->getLayers().size(), tmp2); for (auto& it1 : pathSegMergeMap) { @@ -3237,10 +3246,10 @@ void io::Writer::mergeSplitConnFigs( } // split pathseg from via - // mergedPathSegs[layerNum][isHorizontal] is a std::map > > - // map < std::tuple, std::shared_ptr > - // viaMergeMap; + // mergedPathSegs[layerNum][isHorizontal] is a + // boost::container::flat_map + // > > map < std::tuple, std::shared_ptr + // > viaMergeMap; for (auto& it1 : viaMergeMap) { auto x = std::get<0>(it1.first); auto y = std::get<1>(it1.first); @@ -3622,7 +3631,7 @@ void io::Writer::updateDbAccessPoints(odb::dbBlock* block, odb::dbTech* db_tech) odb::dbAccessPoint::destroy(ap); } auto db = block->getDb(); - std::map aps_map; + boost::container::flat_map aps_map; for (auto& master : getDesign()->getMasters()) { auto db_master = db->findMaster(master->getName().c_str()); if (db_master == nullptr) { diff --git a/src/drt/src/io/io.h b/src/drt/src/io/io.h index 8e02ce79f2f..dbed0e4b0f6 100644 --- a/src/drt/src/io/io.h +++ b/src/drt/src/io/io.h @@ -28,6 +28,8 @@ #pragma once +#include +#include #include #include #include @@ -157,13 +159,17 @@ class Parser // temporary variables int readLayerCnt_; odb::dbTechLayer* masterSliceLayer_; - std::map, frBlockObjectComp> tmpGuides_; + boost::container::flat_map, frBlockObjectComp> + tmpGuides_; std::vector> tmpGRPins_; - std::map, - std::set>>, - frBlockObjectComp> + boost::container::flat_map< + frMaster*, + boost::container::flat_map< + dbOrientType, + boost::container::flat_map< + std::vector, + boost::container::flat_set>>, + frBlockObjectComp> trackOffsetMap_; std::vector prefTrackPatterns_; }; @@ -196,7 +202,8 @@ class Writer frCoord x, frCoord y, std::vector>>>>& + boost::container::flat_map>>>>& mergedPathSegs); void updateDbConn(odb::dbBlock* block, odb::dbTech* db_tech, bool snapshot); void writeViaDefToODB(odb::dbBlock* block, @@ -210,7 +217,7 @@ class Writer drt::TritonRoute* router_; Logger* logger_; - std::map>> + boost::container::flat_map>> connFigs_; // all connFigs ready to def std::vector viaDefs_; }; diff --git a/src/drt/src/io/io_parser_helper.cpp b/src/drt/src/io/io_parser_helper.cpp index 2c7d229ab43..65c5b2096e4 100644 --- a/src/drt/src/io/io_parser_helper.cpp +++ b/src/drt/src/io/io_parser_helper.cpp @@ -102,9 +102,12 @@ void io::Parser::initDefaultVias() continue; } // Check whether viaDefs set is empty - std::set viaDefs = layer->getViaDefs(); + boost::container::flat_set viaDefs = layer->getViaDefs(); if (!viaDefs.empty()) { - std::map> cuts2ViaDefs; + boost::container::flat_map< + int, + boost::container::flat_map> + cuts2ViaDefs; for (auto& viaDef : viaDefs) { int cutNum = int(viaDef->getCutFigs().size()); viaRawPriorityTuple priority; @@ -273,9 +276,12 @@ void io::Parser::initSecondaryVias() if (!has_default_viadef || !has_max_spacing_constraints) { continue; } - std::set viadefs = layer->getViaDefs(); + boost::container::flat_set viadefs = layer->getViaDefs(); if (!viadefs.empty()) { - std::map> cuts_to_viadefs; + boost::container::flat_map< + int, + boost::container::flat_map> + cuts_to_viadefs; for (auto& viadef : viadefs) { int cut_num = int(viadef->getCutFigs().size()); viaRawPriorityTuple priority; @@ -715,7 +721,7 @@ inline void getTrackLocs(bool isHorzTracks, frBlock* block, frCoord low, frCoord high, - std::set& trackLocs) + boost::container::flat_set& trackLocs) { for (auto& tp : block->getTrackPatterns(layer->getLayerNum())) { if (tp->isHorizontal() != isHorzTracks) { @@ -764,7 +770,7 @@ void io::Parser::checkFig(frPinFig* uFig, return; } auto layer = tech_->getLayer(shape->getLayerNum()); - std::set horzTracks, vertTracks; + boost::container::flat_set horzTracks, vertTracks; getTrackLocs(true, layer, design_->getTopBlock(), @@ -822,7 +828,7 @@ void io::Parser::checkFig(frPinFig* uFig, poly.set(points.begin(), points.end()); gtl::get_max_rectangles(rects, poly); for (const auto& rect : rects) { - std::set horzTracks, vertTracks; + boost::container::flat_set horzTracks, vertTracks; getTrackLocs(true, layer, design_->getTopBlock(), diff --git a/src/drt/src/io/io_pin.cpp b/src/drt/src/io/io_pin.cpp index f330ec9310a..dc0d0832edb 100644 --- a/src/drt/src/io/io_pin.cpp +++ b/src/drt/src/io/io_pin.cpp @@ -53,8 +53,9 @@ void io::Parser::instAnalysis() } int numLayers = design_->getTech()->getLayers().size(); - std::map, frBlockObjectComp> - masterPinLayerRange; + boost::container:: + flat_map, frBlockObjectComp> + masterPinLayerRange; for (auto& uMaster : design_->getMasters()) { auto master = uMaster.get(); frLayerNum minLayerNum = numLayers; diff --git a/src/drt/src/pa/FlexPA.h b/src/drt/src/pa/FlexPA.h index fc49e7afd6d..dbd6bfe7c16 100644 --- a/src/drt/src/pa/FlexPA.h +++ b/src/drt/src/pa/FlexPA.h @@ -100,11 +100,16 @@ class FlexPA UniqueInsts unique_insts_; using UniqueMTerm = std::pair; - std::map skip_unique_inst_term_; + boost::container::flat_map skip_unique_inst_term_; // helper structures - std::vector> track_coords_; - std::map>> + std::vector> + track_coords_; + boost::container::flat_map< + frLayerNum, + boost::container::flat_map< + int, + boost::container::flat_map>> layer_num_to_via_defs_; frCollection target_insts_; @@ -183,7 +188,7 @@ class FlexPA template void genAPsFromPinShapes( std::vector>& aps, - std::set>& apset, + boost::container::flat_set>& apset, T* pin, frInstTerm* inst_term, const std::vector>& pin_shapes, @@ -204,7 +209,7 @@ class FlexPA */ void genAPsFromLayerShapes( std::vector>& aps, - std::set>& apset, + boost::container::flat_set>& apset, frInstTerm* inst_term, const gtl::polygon_90_set_data& layer_shapes, frLayerNum layer_num, @@ -228,15 +233,16 @@ class FlexPA * @param upper_type highest access cost considered * @param is_macro_cell_pin TODO: not sure */ - void genAPsFromRect(std::vector>& aps, - std::set>& apset, - const gtl::rectangle_data& rect, - frLayerNum layer_num, - bool allow_planar, - bool allow_via, - frAccessPointEnum lower_type, - frAccessPointEnum upper_type, - bool is_macro_cell_pin); + void genAPsFromRect( + std::vector>& aps, + boost::container::flat_set>& apset, + const gtl::rectangle_data& rect, + frLayerNum layer_num, + bool allow_planar, + bool allow_via, + frAccessPointEnum lower_type, + frAccessPointEnum upper_type, + bool is_macro_cell_pin); /** * @brief Generates an OnGrid access point (on or half track) @@ -248,11 +254,13 @@ class FlexPA * @param use_nearby_grid if the associated cost should be NearbyGrid or the * track cost */ - void genAPOnTrack(std::map& coords, - const std::map& track_coords, - frCoord low, - frCoord high, - bool use_nearby_grid = false); + void genAPOnTrack( + boost::container::flat_map& coords, + const boost::container::flat_map& + track_coords, + frCoord low, + frCoord high, + bool use_nearby_grid = false); /** * @brief If there are less than 3 OnGrid coords between low and high @@ -263,10 +271,11 @@ class FlexPA * @param low lower range of coordinates considered * @param high higher range of coordinates considered */ - void genAPCentered(std::map& coords, - frLayerNum layer_num, - frCoord low, - frCoord high); + void genAPCentered( + boost::container::flat_map& coords, + frLayerNum layer_num, + frCoord low, + frCoord high); /** * @brief Generates an Enclosed Boundary access point @@ -275,21 +284,22 @@ class FlexPA * @param rect pin rectangle to which via is bounded * @param layer_num number of the layer */ - void genAPEnclosedBoundary(std::map& coords, - const gtl::rectangle_data& rect, - frLayerNum layer_num, - bool is_curr_layer_horz); + void genAPEnclosedBoundary( + boost::container::flat_map& coords, + const gtl::rectangle_data& rect, + frLayerNum layer_num, + bool is_curr_layer_horz); void gen_initializeAccessPoints( std::vector>& aps, - std::set>& apset, + boost::container::flat_set>& apset, const gtl::rectangle_data& rect, frLayerNum layer_num, bool allow_planar, bool allow_via, bool is_layer1_horz, - const std::map& x_coords, - const std::map& y_coords, + const boost::container::flat_map& x_coords, + const boost::container::flat_map& y_coords, frAccessPointEnum lower_type, frAccessPointEnum upper_type); @@ -308,16 +318,17 @@ class FlexPA * @param low_cost lowest access cost considered * @param high_cost highest access cost considered */ - void gen_createAccessPoint(std::vector>& aps, - std::set>& apset, - const gtl::rectangle_data& maxrect, - frCoord x, - frCoord y, - frLayerNum layer_num, - bool allow_planar, - bool allow_via, - frAccessPointEnum low_cost, - frAccessPointEnum high_cost); + void gen_createAccessPoint( + std::vector>& aps, + boost::container::flat_set>& apset, + const gtl::rectangle_data& maxrect, + frCoord x, + frCoord y, + frLayerNum layer_num, + bool allow_planar, + bool allow_via, + frAccessPointEnum low_cost, + frAccessPointEnum high_cost); /** * @brief Sets the allowed accesses of the access points of a given pin. @@ -480,7 +491,7 @@ class FlexPA template bool initPinAccessCostBounded( std::vector>& aps, - std::set>& apset, + boost::container::flat_set>& apset, std::vector>& pin_shapes, T* pin, frInstTerm* inst_term, @@ -498,18 +509,19 @@ class FlexPA int genPatterns_helper( const std::vector>& pins, - std::set>& inst_access_patterns, - std::set>& used_access_points, - std::set>& viol_access_points, + boost::container::flat_set>& inst_access_patterns, + boost::container::flat_set>& used_access_points, + boost::container::flat_set>& viol_access_points, int curr_unique_inst_idx, int max_access_point_size); - void genPatternsInit(std::vector& nodes, - const std::vector>& pins, - std::set>& inst_access_patterns, - std::set>& used_access_points, - std::set>& viol_access_points, - int max_access_point_size); + void genPatternsInit( + std::vector& nodes, + const std::vector>& pins, + boost::container::flat_set>& inst_access_patterns, + boost::container::flat_set>& used_access_points, + boost::container::flat_set>& viol_access_points, + int max_access_point_size); void genPatterns_reset( std::vector& nodes, @@ -520,28 +532,29 @@ class FlexPA std::vector& nodes, const std::vector>& pins, std::vector& vio_edges, - const std::set>& used_access_points, - const std::set>& viol_access_points, + const boost::container::flat_set>& used_access_points, + const boost::container::flat_set>& viol_access_points, int curr_unique_inst_idx, int max_access_point_size); - int getEdgeCost(int prev_node_idx, - int curr_node_idx, - const std::vector& nodes, - const std::vector>& pins, - std::vector& vio_edges, - const std::set>& used_access_points, - const std::set>& viol_access_points, - int curr_unique_inst_idx, - int max_access_point_size); + int getEdgeCost( + int prev_node_idx, + int curr_node_idx, + const std::vector& nodes, + const std::vector>& pins, + std::vector& vio_edges, + const boost::container::flat_set>& used_access_points, + const boost::container::flat_set>& viol_access_points, + int curr_unique_inst_idx, + int max_access_point_size); bool genPatterns_commit( const std::vector& nodes, const std::vector>& pins, bool& is_valid, - std::set>& inst_access_patterns, - std::set>& used_access_points, - std::set>& viol_access_points, + boost::container::flat_set>& inst_access_patterns, + boost::container::flat_set>& used_access_points, + boost::container::flat_set>& viol_access_points, int curr_unique_inst_idx, int max_access_point_size); @@ -565,10 +578,10 @@ class FlexPA int idx_2_dim); bool genPatterns_gc( - const std::set& target_objs, + const boost::container::flat_set& target_objs, const std::vector>& objs, PatternType pattern_type, - std::set* owners = nullptr); + boost::container::flat_set* owners = nullptr); void getInsts(std::vector& insts); diff --git a/src/drt/src/pa/FlexPA_graphics.cpp b/src/drt/src/pa/FlexPA_graphics.cpp index 4bb93fee102..5d3a71d7774 100644 --- a/src/drt/src/pa/FlexPA_graphics.cpp +++ b/src/drt/src/pa/FlexPA_graphics.cpp @@ -164,9 +164,10 @@ void FlexPAGraphics::drawLayer(odb::dbTechLayer* layer, gui::Painter& painter) } } -void FlexPAGraphics::startPin(frMPin* pin, - frInstTerm* inst_term, - std::set* inst_class) +void FlexPAGraphics::startPin( + frMPin* pin, + frInstTerm* inst_term, + boost::container::flat_set* inst_class) { pin_ = nullptr; @@ -193,9 +194,10 @@ void FlexPAGraphics::startPin(frMPin* pin, gui_->pause(); } -void FlexPAGraphics::startPin(frBPin* pin, - frInstTerm* inst_term, - std::set* inst_class) +void FlexPAGraphics::startPin( + frBPin* pin, + frInstTerm* inst_term, + boost::container::flat_set* inst_class) { pin_ = nullptr; diff --git a/src/drt/src/pa/FlexPA_graphics.h b/src/drt/src/pa/FlexPA_graphics.h index 53e924b88a3..595df3ac5c4 100644 --- a/src/drt/src/pa/FlexPA_graphics.h +++ b/src/drt/src/pa/FlexPA_graphics.h @@ -66,13 +66,15 @@ class FlexPAGraphics : public gui::Renderer odb::dbDatabase* db, Logger* logger); - void startPin(frBPin* pin, - frInstTerm* inst_term, - std::set* inst_class); - - void startPin(frMPin* pin, - frInstTerm* inst_term, - std::set* inst_class); + void startPin( + frBPin* pin, + frInstTerm* inst_term, + boost::container::flat_set* inst_class); + + void startPin( + frMPin* pin, + frInstTerm* inst_term, + boost::container::flat_set* inst_class); void setAPs(const std::vector>& aps, frAccessPointEnum lower_type, diff --git a/src/drt/src/pa/FlexPA_prep.cpp b/src/drt/src/pa/FlexPA_prep.cpp index 362cebd9a79..fcb28d22b66 100644 --- a/src/drt/src/pa/FlexPA_prep.cpp +++ b/src/drt/src/pa/FlexPA_prep.cpp @@ -131,12 +131,12 @@ FlexPA::mergePinShapes(T* pin, frInstTerm* inst_term, const bool is_shrink) * This function doesn't seem to be getting the best access point. * it iterates through every track contained between low and high * and takes the first one (closest to low) not the best one (lowest cost). - * note that std::map.insert() will not override and entry. + * note that boost::container::flat_map.insert() will not override and entry. * it should prioritize OnGrid access points */ void FlexPA::genAPOnTrack( - std::map& coords, - const std::map& track_coords, + boost::container::flat_map& coords, + const boost::container::flat_map& track_coords, const frCoord low, const frCoord high, const bool use_nearby_grid) @@ -163,10 +163,11 @@ void FlexPA::genAPOnTrack( * If false it created and access points in the middle point between [low, high] */ -void FlexPA::genAPCentered(std::map& coords, - const frLayerNum layer_num, - const frCoord low, - const frCoord high) +void FlexPA::genAPCentered( + boost::container::flat_map& coords, + const frLayerNum layer_num, + const frCoord low, + const frCoord high) { // if touching two tracks, then no center?? int candidates_on_grid = 0; @@ -200,10 +201,11 @@ void FlexPA::genAPCentered(std::map& coords, * This is the worst access point adressed in the paper */ -void FlexPA::genAPEnclosedBoundary(std::map& coords, - const gtl::rectangle_data& rect, - const frLayerNum layer_num, - const bool is_curr_layer_horz) +void FlexPA::genAPEnclosedBoundary( + boost::container::flat_map& coords, + const gtl::rectangle_data& rect, + const frLayerNum layer_num, + const bool is_curr_layer_horz) { const auto rect_width = gtl::delta(rect, gtl::HORIZONTAL); const auto rect_height = gtl::delta(rect, gtl::VERTICAL); @@ -246,7 +248,7 @@ void FlexPA::genAPEnclosedBoundary(std::map& coords, // Responsible for checking if an AP is valid and configuring it void FlexPA::gen_createAccessPoint( std::vector>& aps, - std::set>& apset, + boost::container::flat_set>& apset, const gtl::rectangle_data& maxrect, const frCoord x, const frCoord y, @@ -353,14 +355,14 @@ void FlexPA::gen_createAccessPoint( void FlexPA::gen_initializeAccessPoints( std::vector>& aps, - std::set>& apset, + boost::container::flat_set>& apset, const gtl::rectangle_data& rect, const frLayerNum layer_num, const bool allow_planar, const bool allow_via, const bool is_layer1_horz, - const std::map& x_coords, - const std::map& y_coords, + const boost::container::flat_map& x_coords, + const boost::container::flat_map& y_coords, const frAccessPointEnum lower_type, const frAccessPointEnum upper_type) { @@ -436,15 +438,16 @@ bool FlexPA::enclosesOnTrackPlanarAccess( * @details Generates all necessary access points from a rectangle shape * In this case a rectangle is one of the pin shapes of the pin */ -void FlexPA::genAPsFromRect(std::vector>& aps, - std::set>& apset, - const gtl::rectangle_data& rect, - const frLayerNum layer_num, - const bool allow_planar, - const bool allow_via, - frAccessPointEnum lower_type, - const frAccessPointEnum upper_type, - const bool is_macro_cell_pin) +void FlexPA::genAPsFromRect( + std::vector>& aps, + boost::container::flat_set>& apset, + const gtl::rectangle_data& rect, + const frLayerNum layer_num, + const bool allow_planar, + const bool allow_via, + frAccessPointEnum lower_type, + const frAccessPointEnum upper_type, + const bool is_macro_cell_pin) { auto layer = getDesign()->getTech()->getLayer(layer_num); const auto min_width_layer1 = layer->getMinWidth(); @@ -467,8 +470,8 @@ void FlexPA::genAPsFromRect(std::vector>& aps, auto& layer2_track_coords = track_coords_[second_layer_num]; const bool is_layer1_horz = (layer->getDir() == dbTechLayerDir::HORIZONTAL); - std::map x_coords; - std::map y_coords; + boost::container::flat_map x_coords; + boost::container::flat_map y_coords; int hwidth = layer->getWidth() / 2; bool use_center_line = false; if (is_macro_cell_pin) { @@ -586,7 +589,7 @@ void FlexPA::genAPsFromRect(std::vector>& aps, void FlexPA::genAPsFromLayerShapes( std::vector>& aps, - std::set>& apset, + boost::container::flat_set>& apset, frInstTerm* inst_term, const gtl::polygon_90_set_data& layer_shapes, const frLayerNum layer_num, @@ -657,7 +660,7 @@ void FlexPA::genAPsFromLayerShapes( template void FlexPA::genAPsFromPinShapes( std::vector>& aps, - std::set>& apset, + boost::container::flat_set>& apset, T* pin, frInstTerm* inst_term, const std::vector>& pin_shapes, @@ -964,7 +967,8 @@ void FlexPA::check_addViaAccess( } } - std::set> valid_via_defs; + boost::container::flat_set> + valid_via_defs; for (auto& [idx, via_def] : via_defs) { auto via = std::make_unique(via_def); via->setOrigin(begin_point); @@ -1260,7 +1264,7 @@ void FlexPA::updatePinStats( template bool FlexPA::initPinAccessCostBounded( std::vector>& aps, - std::set>& apset, + boost::container::flat_set>& apset, std::vector>& pin_shapes, T* pin, frInstTerm* inst_term, @@ -1363,7 +1367,7 @@ int FlexPA::initPinAccess(T* pin, frInstTerm* inst_term) // aps are after xform // before checkPoints, ap->hasAccess(dir) indicates whether to check drc std::vector> aps; - std::set> apset; + boost::container::flat_set> apset; bool is_std_cell_pin = false; bool is_macro_cell_pin = false; if (inst_term) { @@ -1381,7 +1385,8 @@ int FlexPA::initPinAccess(T* pin, frInstTerm* inst_term) } if (graphics_) { - std::set* inst_class = nullptr; + boost::container::flat_set* inst_class + = nullptr; if (inst_term) { inst_class = unique_insts_.getClass(inst_term->getInst()); } @@ -2132,7 +2137,7 @@ void FlexPA::addAccessPatternObj( void FlexPA::getInsts(std::vector& insts) { - std::set target_frinsts; + boost::container::flat_set target_frinsts; for (auto inst : target_insts_) { target_frinsts.insert(design_->getTopBlock()->findInst(inst->getName())); } @@ -2265,9 +2270,9 @@ int FlexPA::genPatterns( } // moved for mt - std::set> inst_access_patterns; - std::set> used_access_points; - std::set> viol_access_points; + boost::container::flat_set> inst_access_patterns; + boost::container::flat_set> used_access_points; + boost::container::flat_set> viol_access_points; int num_valid_pattern = 0; num_valid_pattern += FlexPA::genPatterns_helper(pins, @@ -2294,9 +2299,9 @@ int FlexPA::genPatterns( int FlexPA::genPatterns_helper( const std::vector>& pins, - std::set>& inst_access_patterns, - std::set>& used_access_points, - std::set>& viol_access_points, + boost::container::flat_set>& inst_access_patterns, + boost::container::flat_set>& used_access_points, + boost::container::flat_set>& viol_access_points, const int curr_unique_inst_idx, const int max_access_point_size) { @@ -2346,9 +2351,9 @@ int FlexPA::genPatterns_helper( void FlexPA::genPatternsInit( std::vector& nodes, const std::vector>& pins, - std::set>& inst_access_patterns, - std::set>& used_access_points, - std::set>& viol_access_points, + boost::container::flat_set>& inst_access_patterns, + boost::container::flat_set>& used_access_points, + boost::container::flat_set>& viol_access_points, int max_access_point_size) { // clear temp storage and flag @@ -2396,10 +2401,10 @@ void FlexPA::genPatterns_reset( } bool FlexPA::genPatterns_gc( - const std::set& target_objs, + const boost::container::flat_set& target_objs, const std::vector>& objs, const PatternType pattern_type, - std::set* owners) + boost::container::flat_set* owners) { if (objs.empty()) { if (VERBOSE > 1) { @@ -2459,8 +2464,8 @@ void FlexPA::genPatterns_perform( std::vector& nodes, const std::vector>& pins, std::vector& vio_edges, - const std::set>& used_access_points, - const std::set>& viol_access_points, + const boost::container::flat_set>& used_access_points, + const boost::container::flat_set>& viol_access_points, const int curr_unique_inst_idx, const int max_access_point_size) { @@ -2507,8 +2512,8 @@ int FlexPA::getEdgeCost( const std::vector& nodes, const std::vector>& pins, std::vector& vio_edges, - const std::set>& used_access_points, - const std::set>& viol_access_points, + const boost::container::flat_set>& used_access_points, + const boost::container::flat_set>& viol_access_points, const int curr_unique_inst_idx, const int max_access_point_size) { @@ -2631,9 +2636,9 @@ bool FlexPA::genPatterns_commit( const std::vector& nodes, const std::vector>& pins, bool& is_valid, - std::set>& inst_access_patterns, - std::set>& used_access_points, - std::set>& viol_access_points, + boost::container::flat_set>& inst_access_patterns, + boost::container::flat_set>& used_access_points, + boost::container::flat_set>& viol_access_points, const int curr_unique_inst_idx, const int max_access_point_size) { @@ -2666,7 +2671,7 @@ bool FlexPA::genPatterns_commit( inst_access_patterns.insert(access_pattern); // create new access pattern and push to uniqueInstances auto pin_access_pattern = std::make_unique(); - std::map pin_to_access_pattern; + boost::container::flat_map pin_to_access_pattern; // check DRC for the whole pattern std::vector> objs; std::vector> temp_vias; @@ -2738,7 +2743,7 @@ bool FlexPA::genPatterns_commit( pin_access_pattern->setBoundaryAP(true, leftAP); pin_access_pattern->setBoundaryAP(false, rightAP); - std::set owners; + boost::container::flat_set owners; if (target_obj != nullptr && genPatterns_gc({target_obj}, objs, Commit, &owners)) { pin_access_pattern->updateCost(); diff --git a/src/drt/src/pa/FlexPA_unique.cpp b/src/drt/src/pa/FlexPA_unique.cpp index f99961a4efb..8db0eb2eb1b 100644 --- a/src/drt/src/pa/FlexPA_unique.cpp +++ b/src/drt/src/pa/FlexPA_unique.cpp @@ -61,7 +61,7 @@ std::vector UniqueInsts::getPrefTrackPatterns() UniqueInsts::MasterLayerRange UniqueInsts::initMasterToPinLayerRange() { MasterLayerRange master_to_pin_layer_range; - std::set masters; + boost::container::flat_set masters; for (odb::dbInst* inst : target_insts_) { masters.insert(inst->getMaster()->getName()); } @@ -136,7 +136,7 @@ void UniqueInsts::computeUnique( const MasterLayerRange& master_to_pin_layer_range, const std::vector& pref_track_patterns) { - std::set target_frinsts; + boost::container::flat_set target_frinsts; for (auto inst : target_insts_) { target_frinsts.insert(design_->getTopBlock()->findInst(inst->getName())); } @@ -294,7 +294,8 @@ void UniqueInsts::report() const logger_->report("#unique instances = {}", unique_.size()); } -std::set* UniqueInsts::getClass(frInst* inst) const +boost::container::flat_set* UniqueInsts::getClass( + frInst* inst) const { return inst_to_class_.at(inst); } diff --git a/src/drt/src/pa/FlexPA_unique.h b/src/drt/src/pa/FlexPA_unique.h index af48c05b3cb..e2b7091ba0e 100644 --- a/src/drt/src/pa/FlexPA_unique.h +++ b/src/drt/src/pa/FlexPA_unique.h @@ -27,6 +27,9 @@ #pragma once +#include +#include + #include "frDesign.h" namespace drt { @@ -44,7 +47,7 @@ namespace drt { class UniqueInsts { public: - using InstSet = std::set; + using InstSet = boost::container::flat_set; // if target_insts is non-empty then analysis is limited to // those instances. UniqueInsts(frDesign* design, @@ -73,7 +76,8 @@ class UniqueInsts private: using LayerRange = std::pair; - using MasterLayerRange = std::map; + using MasterLayerRange + = boost::container::flat_map; frDesign* getDesign() const { return design_; } frTechObject* getTech() const { return design_->getTech(); } @@ -154,17 +158,21 @@ class UniqueInsts // All the unique instances std::vector unique_; // Mapp all instances to their representative unique instance - std::map inst_to_unique_; + boost::container::flat_map + inst_to_unique_; // Maps all instances to the set of instances with the same unique inst std::unordered_map inst_to_class_; // Maps a unique instance to its pin access index - std::map unique_to_pa_idx_; + boost::container::flat_map unique_to_pa_idx_; // Maps a unique instance to its index in unique_ - std::map unique_to_idx_; + boost::container::flat_map unique_to_idx_; // master orient track-offset to instances - std::map, InstSet>>, - frBlockObjectComp> + boost::container::flat_map< + frMaster*, + boost::container::flat_map< + dbOrientType, + boost::container::flat_map, InstSet>>, + frBlockObjectComp> master_orient_trackoffset_to_insts_; }; diff --git a/src/drt/src/serialization.h b/src/drt/src/serialization.h index 2e40193149b..7f638dc84c6 100644 --- a/src/drt/src/serialization.h +++ b/src/drt/src/serialization.h @@ -442,7 +442,7 @@ void registerTypes(Archive& ar) ar.template register_type(); ar.template register_type(); - ar.template register_type(); + // ar.template register_type(); TODO ar.template register_type(); ar.template register_type(); diff --git a/src/drt/src/ta/FlexTA.h b/src/drt/src/ta/FlexTA.h index ecc07c6f052..0ede57fb96b 100644 --- a/src/drt/src/ta/FlexTA.h +++ b/src/drt/src/ta/FlexTA.h @@ -28,6 +28,8 @@ #pragma once +#include +#include #include #include @@ -75,9 +77,10 @@ class FlexTAWorkerRegionQuery void add(taPinFig* fig); void remove(taPinFig* fig); - void query(const Rect& box, - frLayerNum layerNum, - std::set& result) const; + void query( + const Rect& box, + frLayerNum layerNum, + boost::container::flat_set& result) const; void addCost(const Rect& box, frLayerNum layerNum, @@ -127,7 +130,7 @@ class FlexTAWorker numAssigned_(0), totCost_(0), maxRetry_(1), - hardIroutesMode(false){}; + hardIroutesMode(false) {}; // setters void setRouteBox(const Rect& boxIn) { routeBox_ = boxIn; } void setExtBox(const Rect& boxIn) { extBox_ = boxIn; } @@ -206,7 +209,7 @@ class FlexTAWorker std::vector> iroutes_; // unsorted iroutes std::vector> extIroutes_; std::vector> trackLocs_; - std::set + boost::container::flat_set reassignIroutes_; // iroutes to be assigned in sorted order int numAssigned_; int totCost_; @@ -234,25 +237,27 @@ class FlexTAWorker void initIroute_helper(frGuide* guide, frCoord& maxBegin, frCoord& minEnd, - std::set& downViaCoordSet, - std::set& upViaCoordSet, + boost::container::flat_set& downViaCoordSet, + boost::container::flat_set& upViaCoordSet, int& nextIrouteDir, frCoord& pinCoord); - void initIroute_helper_generic(frGuide* guide, - frCoord& minBegin, - frCoord& maxEnd, - std::set& downViaCoordSet, - std::set& upViaCoordSet, - int& nextIrouteDir, - frCoord& pinCoord); + void initIroute_helper_generic( + frGuide* guide, + frCoord& minBegin, + frCoord& maxEnd, + boost::container::flat_set& downViaCoordSet, + boost::container::flat_set& upViaCoordSet, + int& nextIrouteDir, + frCoord& pinCoord); void initIroute_helper_generic_helper(frGuide* guide, frCoord& pinCoord); - bool initIroute_helper_pin(frGuide* guide, - frCoord& maxBegin, - frCoord& minEnd, - std::set& downViaCoordSet, - std::set& upViaCoordSet, - int& nextIrouteDir, - frCoord& pinCoord); + bool initIroute_helper_pin( + frGuide* guide, + frCoord& maxBegin, + frCoord& minEnd, + boost::container::flat_set& downViaCoordSet, + boost::container::flat_set& upViaCoordSet, + int& nextIrouteDir, + frCoord& pinCoord); void initCosts(); void sortIroutes(); @@ -262,37 +267,42 @@ class FlexTAWorker frCoord& dx, frCoord& dy); void addCost(taPinFig* fig, - std::set* pinS = nullptr); + boost::container::flat_set* pinS + = nullptr); void subCost(taPinFig* fig, - std::set* pinS = nullptr); + boost::container::flat_set* pinS + = nullptr); void modCost(taPinFig* fig, bool isAddCost, - std::set* pinS = nullptr); - void modMinSpacingCostPlanar(const Rect& box, - frLayerNum lNum, - taPinFig* fig, - bool isAddCost, - std::set* pinS - = nullptr); - void modMinSpacingCostVia(const Rect& box, - frLayerNum lNum, - taPinFig* fig, - bool isAddCost, - bool isUpperVia, - bool isCurrPs, - std::set* pinS - = nullptr); - void modCutSpacingCost(const Rect& box, - frLayerNum lNum, - taPinFig* fig, - bool isAddCost, - std::set* pinS = nullptr); + boost::container::flat_set* pinS + = nullptr); + void modMinSpacingCostPlanar( + const Rect& box, + frLayerNum lNum, + taPinFig* fig, + bool isAddCost, + boost::container::flat_set* pinS = nullptr); + void modMinSpacingCostVia( + const Rect& box, + frLayerNum lNum, + taPinFig* fig, + bool isAddCost, + bool isUpperVia, + bool isCurrPs, + boost::container::flat_set* pinS = nullptr); + void modCutSpacingCost( + const Rect& box, + frLayerNum lNum, + taPinFig* fig, + bool isAddCost, + boost::container::flat_set* pinS = nullptr); // initTA void assign(); void assignIroute(taPin* iroute); - void assignIroute_init(taPin* iroute, - std::set* pinS); + void assignIroute_init( + taPin* iroute, + boost::container::flat_set* pinS); void assignIroute_availTracks(taPin* iroute, frLayerNum& lNum, int& idx1, @@ -318,10 +328,12 @@ class FlexTAWorker frUInt4 assignIroute_getDRCCost_helper(taPin* iroute, Rect& box, frLayerNum lNum); - void assignIroute_updateIroute(taPin* iroute, - frCoord bestTrackLoc, - std::set* pinS); - void assignIroute_updateOthers(std::set& pinS); + void assignIroute_updateIroute( + taPin* iroute, + frCoord bestTrackLoc, + boost::container::flat_set* pinS); + void assignIroute_updateOthers( + boost::container::flat_set& pinS); // end void end(); diff --git a/src/drt/src/ta/FlexTA_assign.cpp b/src/drt/src/ta/FlexTA_assign.cpp index a0c89ee7f46..10c8a99ecaf 100644 --- a/src/drt/src/ta/FlexTA_assign.cpp +++ b/src/drt/src/ta/FlexTA_assign.cpp @@ -52,7 +52,7 @@ void FlexTAWorker::modMinSpacingCostPlanar( frLayerNum lNum, taPinFig* fig, bool isAddCost, - std::set* pinS) + boost::container::flat_set* pinS) { // obj1 = curr obj frCoord width1 = box.minDXDY(); @@ -138,7 +138,7 @@ void FlexTAWorker::modMinSpacingCostVia( bool isAddCost, bool isUpperVia, bool isCurrPs, - std::set* pinS) + boost::container::flat_set* pinS) { // obj1 = curr obj frCoord width1 = box.minDXDY(); @@ -315,11 +315,12 @@ void FlexTAWorker::modMinSpacingCostVia( } } -void FlexTAWorker::modCutSpacingCost(const Rect& box, - frLayerNum lNum, - taPinFig* fig, - bool isAddCost, - std::set* pinS) +void FlexTAWorker::modCutSpacingCost( + const Rect& box, + frLayerNum lNum, + taPinFig* fig, + bool isAddCost, + boost::container::flat_set* pinS) { if (!getDesign()->getTech()->getLayer(lNum)->hasCutSpacing()) { return; @@ -516,21 +517,24 @@ void FlexTAWorker::modCutSpacingCost(const Rect& box, } } -void FlexTAWorker::addCost(taPinFig* fig, - std::set* pinS) +void FlexTAWorker::addCost( + taPinFig* fig, + boost::container::flat_set* pinS) { modCost(fig, true, pinS); } -void FlexTAWorker::subCost(taPinFig* fig, - std::set* pinS) +void FlexTAWorker::subCost( + taPinFig* fig, + boost::container::flat_set* pinS) { modCost(fig, false, pinS); } -void FlexTAWorker::modCost(taPinFig* fig, - bool isAddCost, - std::set* pinS) +void FlexTAWorker::modCost( + taPinFig* fig, + bool isAddCost, + boost::container::flat_set* pinS) { if (fig->typeId() == tacPathSeg) { auto obj = static_cast(fig); @@ -905,7 +909,7 @@ frUInt4 FlexTAWorker::assignIroute_getAlignCost(taPin* iroute, frCoord trackLoc) auto lNum = obj->getLayerNum(); pitch = getDesign()->getTech()->getLayer(lNum)->getPitch(); auto& workerRegionQuery = getWorkerRegionQuery(); - std::set result; + boost::container::flat_set result; Rect box; if (isH) { box.init(bp.x(), trackLoc, ep.x(), trackLoc); @@ -1122,7 +1126,7 @@ int FlexTAWorker::assignIroute_bestTrack(taPin* iroute, void FlexTAWorker::assignIroute_updateIroute( taPin* iroute, frCoord bestTrackLoc, - std::set* pinS) + boost::container::flat_set* pinS) { auto& workerRegionQuery = getWorkerRegionQuery(); bool isH = (getDir() == dbTechLayerDir::HORIZONTAL); @@ -1163,8 +1167,9 @@ void FlexTAWorker::assignIroute_updateIroute( iroute->addNumAssigned(); } -void FlexTAWorker::assignIroute_init(taPin* iroute, - std::set* pinS) +void FlexTAWorker::assignIroute_init( + taPin* iroute, + boost::container::flat_set* pinS) { auto& workerRegionQuery = getWorkerRegionQuery(); // subCost @@ -1178,7 +1183,7 @@ void FlexTAWorker::assignIroute_init(taPin* iroute, } void FlexTAWorker::assignIroute_updateOthers( - std::set& pinS) + boost::container::flat_set& pinS) { bool isH = (getDir() == dbTechLayerDir::HORIZONTAL); if (isInitTA()) { @@ -1222,7 +1227,7 @@ void FlexTAWorker::assignIroute_updateOthers( void FlexTAWorker::assignIroute(taPin* iroute) { - std::set pinS; + boost::container::flat_set pinS; assignIroute_init(iroute, &pinS); frLayerNum lNum; int idx1, idx2; diff --git a/src/drt/src/ta/FlexTA_init.cpp b/src/drt/src/ta/FlexTA_init.cpp index 53646c7cef3..34103667045 100644 --- a/src/drt/src/ta/FlexTA_init.cpp +++ b/src/drt/src/ta/FlexTA_init.cpp @@ -35,7 +35,7 @@ void FlexTAWorker::initTracks() trackLocs_.clear(); const int numLayers = getDesign()->getTech()->getLayers().size(); trackLocs_.resize(numLayers); - std::vector> trackCoordSets(numLayers); + std::vector> trackCoordSets(numLayers); // uPtr for tp for (int lNum = 0; lNum < (int) numLayers; lNum++) { auto layer = getDesign()->getTech()->getLayer(lNum); @@ -81,13 +81,14 @@ void FlexTAWorker::initTracks() } // use prefAp, otherwise return false -bool FlexTAWorker::initIroute_helper_pin(frGuide* guide, - frCoord& maxBegin, - frCoord& minEnd, - std::set& downViaCoordSet, - std::set& upViaCoordSet, - int& nextIrouteDir, - frCoord& pinCoord) +bool FlexTAWorker::initIroute_helper_pin( + frGuide* guide, + frCoord& maxBegin, + frCoord& minEnd, + boost::container::flat_set& downViaCoordSet, + boost::container::flat_set& upViaCoordSet, + int& nextIrouteDir, + frCoord& pinCoord) { auto [bp, ep] = guide->getPoints(); if (bp != ep) { @@ -209,13 +210,14 @@ bool FlexTAWorker::initIroute_helper_pin(frGuide* guide, return false; } -void FlexTAWorker::initIroute_helper(frGuide* guide, - frCoord& maxBegin, - frCoord& minEnd, - std::set& downViaCoordSet, - std::set& upViaCoordSet, - int& nextIrouteDir, - frCoord& pinCoord) +void FlexTAWorker::initIroute_helper( + frGuide* guide, + frCoord& maxBegin, + frCoord& minEnd, + boost::container::flat_set& downViaCoordSet, + boost::container::flat_set& upViaCoordSet, + int& nextIrouteDir, + frCoord& pinCoord) { if (!initIroute_helper_pin(guide, maxBegin, @@ -321,13 +323,14 @@ void FlexTAWorker::initIroute_helper_generic_helper(frGuide* guide, } } -void FlexTAWorker::initIroute_helper_generic(frGuide* guide, - frCoord& minBegin, - frCoord& maxEnd, - std::set& downViaCoordSet, - std::set& upViaCoordSet, - int& nextIrouteDir, - frCoord& pinCoord) +void FlexTAWorker::initIroute_helper_generic( + frGuide* guide, + frCoord& minBegin, + frCoord& maxEnd, + boost::container::flat_set& downViaCoordSet, + boost::container::flat_set& upViaCoordSet, + int& nextIrouteDir, + frCoord& pinCoord) { auto net = guide->getNet(); auto layerNum = guide->getBeginLayerNum(); @@ -441,7 +444,7 @@ void FlexTAWorker::initIroute(frGuide* guide) } frCoord maxBegin, minEnd; - std::set downViaCoordSet, upViaCoordSet; + boost::container::flat_set downViaCoordSet, upViaCoordSet; int nextIrouteDir = 0; frCoord pinCoord = std::numeric_limits::max(); initIroute_helper(guide, diff --git a/src/drt/src/ta/FlexTA_rq.cpp b/src/drt/src/ta/FlexTA_rq.cpp index 4e09e6c1df4..2df7bec24e4 100644 --- a/src/drt/src/ta/FlexTA_rq.cpp +++ b/src/drt/src/ta/FlexTA_rq.cpp @@ -99,13 +99,13 @@ void FlexTAWorkerRegionQuery::remove(taPinFig* fig) void FlexTAWorkerRegionQuery::query( const Rect& box, const frLayerNum layerNum, - std::set& result) const + boost::container::flat_set& result) const { std::vector> temp; auto& tree = impl_->shapes_.at(layerNum); transform(tree.qbegin(bgi::intersects(box)), tree.qend(), - inserter(result, result.end()), + std::inserter(result, result.end()), [](const auto& box_fig) { return box_fig.second->getPin(); }); }