Skip to content

Commit

Permalink
Replace std::map of Point3D with boost flat hashmap
Browse files Browse the repository at this point in the history
  • Loading branch information
sgizler committed Nov 22, 2024
1 parent 58af449 commit d48f416
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
9 changes: 9 additions & 0 deletions src/drt/src/db/infra/frPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ class Point3D : public Point
return z_ < rhs.z_;
}

friend std::size_t hash_value(Point3D const& p)
{
std::size_t seed = 0;
boost::hash_combine(seed, p.getX());
boost::hash_combine(seed, p.getY());
boost::hash_combine(seed, p.getZ());
return seed;
}

private:
int z_{0};
template <class Archive>
Expand Down
12 changes: 6 additions & 6 deletions src/drt/src/io/GuideProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ void addSplitRect(const frCoord track_idx,
void GuideProcessor::genGuides_split(
std::vector<frRect>& rects,
const TrackIntervalsByLayer& intvs,
const std::map<Point3D, frBlockObjectSet>& gcell_pin_map,
const boost::unordered_flat_map<Point3D, frBlockObjectSet>& gcell_pin_map,
frBlockObjectMap<std::set<Point3D>>& pin_gcell_map,
bool via_access_only) const
{
Expand Down Expand Up @@ -1258,7 +1258,7 @@ void GuideProcessor::genGuides_split(
}

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

void GuideProcessor::initGCellPinMap(
const frNet* net,
std::map<Point3D, frBlockObjectSet>& gcell_pin_map) const
boost::unordered_flat_map<Point3D, frBlockObjectSet>& gcell_pin_map) const
{
for (auto instTerm : net->getInstTerms()) {
mapTermAccessPointsToGCells(gcell_pin_map, instTerm);
Expand All @@ -1290,7 +1290,7 @@ void GuideProcessor::initGCellPinMap(
}

void GuideProcessor::mapTermAccessPointsToGCells(
std::map<Point3D, frBlockObjectSet>& gcell_pin_map,
boost::unordered_flat_map<Point3D, frBlockObjectSet>& gcell_pin_map,
frBlockObject* pin) const
{
for (const auto& ap_loc : getAccessPoints(pin)) {
Expand Down Expand Up @@ -1372,7 +1372,7 @@ std::vector<std::pair<frBlockObject*, Point>> GuideProcessor::genGuides(
}
genGuides_prep(rects, intvs);

std::map<Point3D, frBlockObjectSet> gcell_pin_map;
boost::unordered_flat_map<Point3D, frBlockObjectSet> gcell_pin_map;
frBlockObjectMap<std::set<Point3D>> pin_gcell_map;
initGCellPinMap(net, gcell_pin_map);
initPinGCellMap(net, pin_gcell_map);
Expand Down Expand Up @@ -2013,4 +2013,4 @@ void GuideProcessor::processGuides()
}
}

} // namespace drt::io
} // namespace drt::io
13 changes: 7 additions & 6 deletions src/drt/src/io/GuideProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include <boost/icl/interval_set.hpp>
#include <boost/unordered/unordered_flat_map.hpp>

#include "db/tech/frTechObject.h"
#include "frDesign.h"
Expand Down Expand Up @@ -173,7 +174,7 @@ class GuideProcessor
*/
void genGuides_split(std::vector<frRect>& rects,
const TrackIntervalsByLayer& intvs,
const std::map<Point3D, frBlockObjectSet>& gcell_pin_map,
const boost::unordered_flat_map<Point3D, frBlockObjectSet>& gcell_pin_map,
frBlockObjectMap<std::set<Point3D>>& pin_gcell_map,
bool via_access_only) const;
/**
Expand All @@ -188,7 +189,7 @@ class GuideProcessor
*/
void initGCellPinMap(
const frNet* net,
std::map<Point3D, frBlockObjectSet>& gcell_pin_map) const;
boost::unordered_flat_map<Point3D, frBlockObjectSet>& gcell_pin_map) const;
/**
* Populates gcell_pin_map with the values associated with the passed term
* based on pin shapes.
Expand All @@ -200,7 +201,7 @@ 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<Point3D, frBlockObjectSet>& gcell_pin_map,
void mapPinShapesToGCells(boost::unordered_flat_map<Point3D, frBlockObjectSet>& gcell_pin_map,
frBlockObject* term) const;
/**
* Populates gcell_pin_map with the values associated with the passed pin
Expand All @@ -214,7 +215,7 @@ class GuideProcessor
* @param term The current pin we are processing.
*/
void mapTermAccessPointsToGCells(
std::map<Point3D, frBlockObjectSet>& gcell_pin_map,
boost::unordered_flat_map<Point3D, frBlockObjectSet>& gcell_pin_map,
frBlockObject* pin) const;

void initPinGCellMap(frNet* net,
Expand Down Expand Up @@ -423,7 +424,7 @@ class GuidePathFinder
Logger* logger_{nullptr};
frNet* net_{nullptr};
bool force_feed_through_{false};
std::map<Point3D, std::set<int>> node_map_;
boost::unordered_flat_map<Point3D, std::set<int>> node_map_;
int guide_count_{0};
int node_count_{0};
bool allow_warnings_{false};
Expand All @@ -434,4 +435,4 @@ class GuidePathFinder
frBlockObjectMap<std::set<Point3D>> pin_gcell_map_;
std::vector<frRect> rects_;
};
} // namespace drt::io
} // namespace drt::io

0 comments on commit d48f416

Please sign in to comment.