Skip to content

Commit d48f416

Browse files
committed
Replace std::map of Point3D with boost flat hashmap
1 parent 58af449 commit d48f416

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

src/drt/src/db/infra/frPoint.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ class Point3D : public Point
6565
return z_ < rhs.z_;
6666
}
6767

68+
friend std::size_t hash_value(Point3D const& p)
69+
{
70+
std::size_t seed = 0;
71+
boost::hash_combine(seed, p.getX());
72+
boost::hash_combine(seed, p.getY());
73+
boost::hash_combine(seed, p.getZ());
74+
return seed;
75+
}
76+
6877
private:
6978
int z_{0};
7079
template <class Archive>

src/drt/src/io/GuideProcessor.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ void addSplitRect(const frCoord track_idx,
11551155
void GuideProcessor::genGuides_split(
11561156
std::vector<frRect>& rects,
11571157
const TrackIntervalsByLayer& intvs,
1158-
const std::map<Point3D, frBlockObjectSet>& gcell_pin_map,
1158+
const boost::unordered_flat_map<Point3D, frBlockObjectSet>& gcell_pin_map,
11591159
frBlockObjectMap<std::set<Point3D>>& pin_gcell_map,
11601160
bool via_access_only) const
11611161
{
@@ -1258,7 +1258,7 @@ void GuideProcessor::genGuides_split(
12581258
}
12591259

12601260
void GuideProcessor::mapPinShapesToGCells(
1261-
std::map<Point3D, frBlockObjectSet>& gcell_pin_map,
1261+
boost::unordered_flat_map<Point3D, frBlockObjectSet>& gcell_pin_map,
12621262
frBlockObject* term) const
12631263
{
12641264
const auto pin_shapes = getPinShapes(term);
@@ -1279,7 +1279,7 @@ void GuideProcessor::mapPinShapesToGCells(
12791279

12801280
void GuideProcessor::initGCellPinMap(
12811281
const frNet* net,
1282-
std::map<Point3D, frBlockObjectSet>& gcell_pin_map) const
1282+
boost::unordered_flat_map<Point3D, frBlockObjectSet>& gcell_pin_map) const
12831283
{
12841284
for (auto instTerm : net->getInstTerms()) {
12851285
mapTermAccessPointsToGCells(gcell_pin_map, instTerm);
@@ -1290,7 +1290,7 @@ void GuideProcessor::initGCellPinMap(
12901290
}
12911291

12921292
void GuideProcessor::mapTermAccessPointsToGCells(
1293-
std::map<Point3D, frBlockObjectSet>& gcell_pin_map,
1293+
boost::unordered_flat_map<Point3D, frBlockObjectSet>& gcell_pin_map,
12941294
frBlockObject* pin) const
12951295
{
12961296
for (const auto& ap_loc : getAccessPoints(pin)) {
@@ -1372,7 +1372,7 @@ std::vector<std::pair<frBlockObject*, Point>> GuideProcessor::genGuides(
13721372
}
13731373
genGuides_prep(rects, intvs);
13741374

1375-
std::map<Point3D, frBlockObjectSet> gcell_pin_map;
1375+
boost::unordered_flat_map<Point3D, frBlockObjectSet> gcell_pin_map;
13761376
frBlockObjectMap<std::set<Point3D>> pin_gcell_map;
13771377
initGCellPinMap(net, gcell_pin_map);
13781378
initPinGCellMap(net, pin_gcell_map);
@@ -2013,4 +2013,4 @@ void GuideProcessor::processGuides()
20132013
}
20142014
}
20152015

2016-
} // namespace drt::io
2016+
} // namespace drt::io

src/drt/src/io/GuideProcessor.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
///////////////////////////////////////////////////////////////////////////////
3333
#pragma once
3434
#include <boost/icl/interval_set.hpp>
35+
#include <boost/unordered/unordered_flat_map.hpp>
3536

3637
#include "db/tech/frTechObject.h"
3738
#include "frDesign.h"
@@ -173,7 +174,7 @@ class GuideProcessor
173174
*/
174175
void genGuides_split(std::vector<frRect>& rects,
175176
const TrackIntervalsByLayer& intvs,
176-
const std::map<Point3D, frBlockObjectSet>& gcell_pin_map,
177+
const boost::unordered_flat_map<Point3D, frBlockObjectSet>& gcell_pin_map,
177178
frBlockObjectMap<std::set<Point3D>>& pin_gcell_map,
178179
bool via_access_only) const;
179180
/**
@@ -188,7 +189,7 @@ class GuideProcessor
188189
*/
189190
void initGCellPinMap(
190191
const frNet* net,
191-
std::map<Point3D, frBlockObjectSet>& gcell_pin_map) const;
192+
boost::unordered_flat_map<Point3D, frBlockObjectSet>& gcell_pin_map) const;
192193
/**
193194
* Populates gcell_pin_map with the values associated with the passed term
194195
* based on pin shapes.
@@ -200,7 +201,7 @@ class GuideProcessor
200201
* @param gcell_pin_map The map to be populated with the results.
201202
* @param term The current pin we are processing.
202203
*/
203-
void mapPinShapesToGCells(std::map<Point3D, frBlockObjectSet>& gcell_pin_map,
204+
void mapPinShapesToGCells(boost::unordered_flat_map<Point3D, frBlockObjectSet>& gcell_pin_map,
204205
frBlockObject* term) const;
205206
/**
206207
* Populates gcell_pin_map with the values associated with the passed pin
@@ -214,7 +215,7 @@ class GuideProcessor
214215
* @param term The current pin we are processing.
215216
*/
216217
void mapTermAccessPointsToGCells(
217-
std::map<Point3D, frBlockObjectSet>& gcell_pin_map,
218+
boost::unordered_flat_map<Point3D, frBlockObjectSet>& gcell_pin_map,
218219
frBlockObject* pin) const;
219220

220221
void initPinGCellMap(frNet* net,
@@ -423,7 +424,7 @@ class GuidePathFinder
423424
Logger* logger_{nullptr};
424425
frNet* net_{nullptr};
425426
bool force_feed_through_{false};
426-
std::map<Point3D, std::set<int>> node_map_;
427+
boost::unordered_flat_map<Point3D, std::set<int>> node_map_;
427428
int guide_count_{0};
428429
int node_count_{0};
429430
bool allow_warnings_{false};
@@ -434,4 +435,4 @@ class GuidePathFinder
434435
frBlockObjectMap<std::set<Point3D>> pin_gcell_map_;
435436
std::vector<frRect> rects_;
436437
};
437-
} // namespace drt::io
438+
} // namespace drt::io

0 commit comments

Comments
 (0)