Skip to content

Commit a86247f

Browse files
authored
Merge pull request #10398 from calewis/refactor-odb-ptr-sets-jetski
Refactor odb ptr sets and maps to be deterministic and not use std::less
2 parents 08035c8 + d288df7 commit a86247f

175 files changed

Lines changed: 1163 additions & 1271 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc")
1414

1515
package(
1616
features = [
17-
"-parse_headers",
17+
"parse_headers",
1818
"layering_check",
1919
# TODO(b/299593765): Fix strict ordering.
2020
"-libcxx_assertions",

src/Timing.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "db_sta/dbNetwork.hh"
1515
#include "db_sta/dbSta.hh"
16+
#include "odb/PtrSetMap.h"
1617
#include "odb/db.h"
1718
#include "ord/Design.h"
1819
#include "ord/OpenRoad.hh"
@@ -282,7 +283,7 @@ std::vector<odb::dbMTerm*> Timing::getTimingFanoutFrom(odb::dbMTerm* input)
282283
sta::Port* port = network->dbToSta(input);
283284
sta::LibertyPort* lib_port = network->libertyPort(port);
284285

285-
std::set<odb::dbMTerm*> outputs;
286+
odb::PtrSet<odb::dbMTerm> outputs;
286287
for (auto arc_set : lib_cell->timingArcSets(lib_port, /* to */ nullptr)) {
287288
const sta::TimingRole* role = arc_set->role();
288289
if (role->isTimingCheck() || role->isAsyncTimingCheck()

src/ant/src/AntennaChecker.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "absl/synchronization/mutex.h"
2424
#include "boost/pending/disjoint_sets.hpp"
2525
#include "boost/polygon/polygon.hpp"
26+
#include "odb/PtrSetMap.h"
2627
#include "odb/db.h"
2728
#include "odb/dbShape.h"
2829
#include "odb/dbTypes.h"
@@ -910,7 +911,7 @@ int AntennaChecker::Impl::checkGates(odb::dbNet* db_net,
910911
}
911912

912913
std::unordered_map<odb::dbITerm*, int> num_diodes_added;
913-
std::map<odb::dbTechLayer*, std::set<odb::dbITerm*>> pin_added;
914+
odb::PtrMap<odb::dbTechLayer, odb::PtrSet<odb::dbITerm>> pin_added;
914915
// if checkGates is used by repair antennas
915916
if (pin_violation_count > 0) {
916917
for (const auto& [gate, violation_layers] : gates_with_violations) {
@@ -1051,7 +1052,7 @@ void AntennaChecker::Impl::buildLayerMaps(odb::dbNet* db_net,
10511052
{
10521053
odb::dbWire* wires = db_net->getWire();
10531054

1054-
std::map<odb::dbTechLayer*, PolygonSet> set_by_layer;
1055+
odb::PtrMap<odb::dbTechLayer, PolygonSet> set_by_layer;
10551056

10561057
wiresToPolygonSetMap(wires, set_by_layer);
10571058
avoidPinIntersection(db_net, set_by_layer);

src/ant/src/AntennaCheckerImpl.hh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "absl/synchronization/mutex.h"
1515
#include "ant/AntennaChecker.hh"
16+
#include "odb/PtrSetMap.h"
1617
#include "odb/db.h"
1718
#include "odb/dbWireGraph.h"
1819

@@ -72,12 +73,12 @@ struct ViolationReport
7273
ViolationReport() { violated = false; }
7374
};
7475

75-
using LayerToNodeInfo = std::map<odb::dbTechLayer*, NodeInfo>;
76+
using LayerToNodeInfo = odb::PtrMap<odb::dbTechLayer, NodeInfo>;
7677
using GraphNodes = std::vector<std::unique_ptr<GraphNode>>;
77-
using LayerToGraphNodes = std::map<odb::dbTechLayer*, GraphNodes>;
78-
using GateToLayerToNodeInfo = std::map<odb::dbITerm*, LayerToNodeInfo>;
78+
using LayerToGraphNodes = odb::PtrMap<odb::dbTechLayer, GraphNodes>;
79+
using GateToLayerToNodeInfo = odb::PtrMap<odb::dbITerm, LayerToNodeInfo>;
7980
using GateToViolationLayers
80-
= std::map<odb::dbITerm*, std::set<odb::dbTechLayer*>>;
81+
= odb::PtrMap<odb::dbITerm, odb::PtrSet<odb::dbTechLayer>>;
8182

8283
class AntennaChecker::Impl
8384
{
@@ -171,11 +172,11 @@ class AntennaChecker::Impl
171172
odb::dbDatabase* db_{nullptr};
172173
odb::dbBlock* block_{nullptr};
173174
utl::Logger* logger_{nullptr};
174-
std::map<odb::dbTechLayer*, AntennaModel> layer_info_;
175+
odb::PtrMap<odb::dbTechLayer, AntennaModel> layer_info_;
175176
int net_violation_count_{0};
176177
std::string report_file_name_;
177178
std::vector<odb::dbNet*> nets_;
178-
std::map<odb::dbNet*, ViolationReport> net_to_report_;
179+
odb::PtrMap<odb::dbNet, ViolationReport> net_to_report_;
179180
absl::Mutex map_mutex_;
180181
// consts
181182
static constexpr int kMaxDiodeCountPerGate = 10;

src/ant/src/Polygon.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "AntennaCheckerImpl.hh"
1010
#include "boost/polygon/polygon.hpp"
11+
#include "odb/PtrSetMap.h"
1112
#include "odb/db.h"
1213
#include "odb/dbShape.h"
1314
#include "odb/dbTransform.h"
@@ -50,8 +51,9 @@ std::vector<int> findNodesWithIntersection(const GraphNodes& graph_nodes,
5051
return ids;
5152
}
5253

53-
void wiresToPolygonSetMap(odb::dbWire* wires,
54-
std::map<odb::dbTechLayer*, PolygonSet>& set_by_layer)
54+
void wiresToPolygonSetMap(
55+
odb::dbWire* wires,
56+
odb::PtrMap<odb::dbTechLayer, PolygonSet>& set_by_layer)
5557
{
5658
using gtl::operators::operator+=;
5759

@@ -84,8 +86,9 @@ void wiresToPolygonSetMap(odb::dbWire* wires,
8486
}
8587
}
8688

87-
void avoidPinIntersection(odb::dbNet* db_net,
88-
std::map<odb::dbTechLayer*, PolygonSet>& set_by_layer)
89+
void avoidPinIntersection(
90+
odb::dbNet* db_net,
91+
odb::PtrMap<odb::dbTechLayer, PolygonSet>& set_by_layer)
8992
{
9093
using gtl::operators::operator-=;
9194

src/ant/src/Polygon.hh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "ant/AntennaChecker.hh"
1313
#include "boost/functional/hash.hpp"
1414
#include "boost/polygon/polygon.hpp"
15+
#include "odb/PtrSetMap.h"
1516
#include "odb/db.h"
1617
#include "odb/geom.h"
1718

@@ -42,9 +43,9 @@ std::vector<int> findNodesWithIntersection(const GraphNodes& graph_nodes,
4243
const Polygon& pol);
4344
void wiresToPolygonSetMap(
4445
odb::dbWire* wires,
45-
std::map<odb::dbTechLayer*, PolygonSet>& set_by_layer);
46+
odb::PtrMap<odb::dbTechLayer, PolygonSet>& set_by_layer);
4647
void avoidPinIntersection(
4748
odb::dbNet* db_net,
48-
std::map<odb::dbTechLayer*, PolygonSet>& set_by_layer);
49+
odb::PtrMap<odb::dbTechLayer, PolygonSet>& set_by_layer);
4950

5051
} // namespace ant

src/ant/src/WireBuilder.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <utility>
1111
#include <vector>
1212

13+
#include "odb/PtrSetMap.h"
1314
#include "odb/db.h"
1415
#include "odb/dbWireGraph.h"
1516
#include "odb/geom.h"
@@ -110,7 +111,7 @@ class WireBuilder
110111
odb::dbDatabase* db_{nullptr};
111112
odb::dbBlock* block_{nullptr};
112113
utl::Logger* logger_{nullptr};
113-
std::map<odb::dbTechLayer*, odb::dbTechVia*> default_vias_;
114+
odb::PtrMap<odb::dbTechLayer, odb::dbTechVia*> default_vias_;
114115
};
115116

116117
} // namespace ant

src/cts/include/cts/TritonCTS.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <utility>
1313
#include <vector>
1414

15+
#include "odb/PtrSetMap.h"
1516
#include "odb/db.h"
1617
#include "odb/geom.h"
1718
#include "utl/Logger.h"
@@ -114,7 +115,7 @@ class TritonCTS
114115
void populateTritonCTS();
115116
void destroyClockModNet(sta::Pin* pin_driver);
116117
void writeClockNetsToDb(TreeBuilder* builder,
117-
std::set<odb::dbNet*>& clkLeafNets);
118+
odb::PtrSet<odb::dbNet>& clkLeafNets);
118119
void writeClockNDRsToDb(TreeBuilder* builder);
119120
int getNetSpacing(odb::dbTechLayer* layer, int width1, int width2);
120121
void incrementNumClocks() { ++numberOfClocks_; }
@@ -187,7 +188,7 @@ class TritonCTS
187188
Clock& clockNet);
188189
odb::dbITerm* getFirstInput(odb::dbInst* inst) const;
189190
odb::dbITerm* getSingleOutput(odb::dbInst* inst, odb::dbITerm* input) const;
190-
void findClockRoots(sta::Clock* clk, std::set<odb::dbNet*>& clockNets);
191+
void findClockRoots(sta::Clock* clk, odb::PtrSet<odb::dbNet>& clockNets);
191192
float getInputPinCap(odb::dbITerm* iterm);
192193
bool isSink(odb::dbITerm* iterm);
193194
ClockInst* getClockFromInst(odb::dbInst* inst);
@@ -224,11 +225,11 @@ class TritonCTS
224225
rsz::Resizer* resizer_ = nullptr;
225226
est::EstimateParasitics* estimate_parasitics_ = nullptr;
226227
std::vector<std::unique_ptr<TreeBuilder>> builders_;
227-
std::set<odb::dbNet*> staClockNets_;
228-
std::set<odb::dbNet*> visitedClockNets_;
229-
std::map<odb::dbInst*, ClockInst*> inst2clkbuf_;
228+
odb::PtrSet<odb::dbNet> staClockNets_;
229+
odb::PtrSet<odb::dbNet> visitedClockNets_;
230+
odb::PtrMap<odb::dbInst, ClockInst*> inst2clkbuf_;
230231
std::map<ClockInst*, ClockSubNet*> driver2subnet_;
231-
std::map<odb::dbNet*, TreeBuilder*> net2builder_;
232+
odb::PtrMap<odb::dbNet, TreeBuilder*> net2builder_;
232233

233234
// db vars
234235
odb::dbDatabase* db_ = nullptr;

src/cts/src/CtsOptions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "CtsObserver.h"
1717
#include "Util.h"
18+
#include "odb/PtrSetMap.h"
1819
#include "odb/db.h"
1920
#include "odb/dbBlockCallBackObj.h"
2021
#include "utl/Logger.h"
@@ -40,7 +41,7 @@ class CtsOptions : public odb::dbBlockCallBackObj
4041
DUMMY,
4142
TREE
4243
};
43-
using MasterCount = std::map<odb::dbMaster*, int>;
44+
using MasterCount = odb::PtrMap<odb::dbMaster, int>;
4445

4546
CtsOptions(utl::Logger* logger, stt::SteinerTreeBuilder* sttBuildder)
4647
: logger_(logger), sttBuilder_(sttBuildder)

src/cts/src/LatencyBalancer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "TreeBuilder.h"
2020
#include "Util.h"
2121
#include "cts/TritonCTS.h"
22+
#include "odb/PtrSetMap.h"
2223
#include "odb/db.h"
2324
#include "odb/dbObject.h"
2425
#include "odb/dbSet.h"
@@ -529,7 +530,7 @@ odb::dbITerm* LatencyBalancer::insertDelayBuffers(
529530
odb::dbInst* lastBuffer = nullptr;
530531

531532
// Use load pins buffering at the end
532-
std::set<odb::dbObject*> load_pins;
533+
odb::PtrSet<odb::dbObject> load_pins;
533534
for (odb::dbITerm* sinkInput : sinksInput) {
534535
load_pins.insert(sinkInput);
535536
}

0 commit comments

Comments
 (0)