From d48f416ea9c5bb8cc1892183204c199135fced2d Mon Sep 17 00:00:00 2001 From: Szymon Gizler Date: Fri, 25 Oct 2024 19:23:26 +0200 Subject: [PATCH] Replace std::map of Point3D with boost flat hashmap --- src/drt/src/db/infra/frPoint.h | 9 +++++++++ src/drt/src/io/GuideProcessor.cpp | 12 ++++++------ src/drt/src/io/GuideProcessor.h | 13 +++++++------ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/drt/src/db/infra/frPoint.h b/src/drt/src/db/infra/frPoint.h index 6443eae96b3..965c658b260 100644 --- a/src/drt/src/db/infra/frPoint.h +++ b/src/drt/src/db/infra/frPoint.h @@ -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 diff --git a/src/drt/src/io/GuideProcessor.cpp b/src/drt/src/io/GuideProcessor.cpp index ba5709e2e89..0aa1c2cdad1 100644 --- a/src/drt/src/io/GuideProcessor.cpp +++ b/src/drt/src/io/GuideProcessor.cpp @@ -1155,7 +1155,7 @@ void addSplitRect(const frCoord track_idx, void GuideProcessor::genGuides_split( std::vector& rects, const TrackIntervalsByLayer& intvs, - const std::map& gcell_pin_map, + const boost::unordered_flat_map& gcell_pin_map, frBlockObjectMap>& pin_gcell_map, bool via_access_only) const { @@ -1258,7 +1258,7 @@ void GuideProcessor::genGuides_split( } void GuideProcessor::mapPinShapesToGCells( - std::map& gcell_pin_map, + boost::unordered_flat_map& gcell_pin_map, frBlockObject* term) const { const auto pin_shapes = getPinShapes(term); @@ -1279,7 +1279,7 @@ void GuideProcessor::mapPinShapesToGCells( void GuideProcessor::initGCellPinMap( const frNet* net, - std::map& gcell_pin_map) const + boost::unordered_flat_map& gcell_pin_map) const { for (auto instTerm : net->getInstTerms()) { mapTermAccessPointsToGCells(gcell_pin_map, instTerm); @@ -1290,7 +1290,7 @@ void GuideProcessor::initGCellPinMap( } void GuideProcessor::mapTermAccessPointsToGCells( - std::map& gcell_pin_map, + boost::unordered_flat_map& gcell_pin_map, frBlockObject* pin) const { for (const auto& ap_loc : getAccessPoints(pin)) { @@ -1372,7 +1372,7 @@ std::vector> GuideProcessor::genGuides( } genGuides_prep(rects, intvs); - std::map gcell_pin_map; + boost::unordered_flat_map gcell_pin_map; frBlockObjectMap> pin_gcell_map; initGCellPinMap(net, gcell_pin_map); initPinGCellMap(net, pin_gcell_map); @@ -2013,4 +2013,4 @@ void GuideProcessor::processGuides() } } -} // namespace drt::io \ No newline at end of file +} // namespace drt::io diff --git a/src/drt/src/io/GuideProcessor.h b/src/drt/src/io/GuideProcessor.h index b3e1eafe138..3cf8a97b795 100644 --- a/src/drt/src/io/GuideProcessor.h +++ b/src/drt/src/io/GuideProcessor.h @@ -32,6 +32,7 @@ /////////////////////////////////////////////////////////////////////////////// #pragma once #include +#include #include "db/tech/frTechObject.h" #include "frDesign.h" @@ -173,7 +174,7 @@ class GuideProcessor */ void genGuides_split(std::vector& rects, const TrackIntervalsByLayer& intvs, - const std::map& gcell_pin_map, + const boost::unordered_flat_map& gcell_pin_map, frBlockObjectMap>& pin_gcell_map, bool via_access_only) const; /** @@ -188,7 +189,7 @@ class GuideProcessor */ void initGCellPinMap( const frNet* net, - std::map& gcell_pin_map) const; + boost::unordered_flat_map& gcell_pin_map) const; /** * Populates gcell_pin_map with the values associated with the passed term * based on pin shapes. @@ -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& gcell_pin_map, + void mapPinShapesToGCells(boost::unordered_flat_map& gcell_pin_map, frBlockObject* term) const; /** * Populates gcell_pin_map with the values associated with the passed pin @@ -214,7 +215,7 @@ class GuideProcessor * @param term The current pin we are processing. */ void mapTermAccessPointsToGCells( - std::map& gcell_pin_map, + boost::unordered_flat_map& gcell_pin_map, frBlockObject* pin) const; void initPinGCellMap(frNet* net, @@ -423,7 +424,7 @@ class GuidePathFinder Logger* logger_{nullptr}; frNet* net_{nullptr}; bool force_feed_through_{false}; - std::map> node_map_; + boost::unordered_flat_map> node_map_; int guide_count_{0}; int node_count_{0}; bool allow_warnings_{false}; @@ -434,4 +435,4 @@ class GuidePathFinder frBlockObjectMap> pin_gcell_map_; std::vector rects_; }; -} // namespace drt::io \ No newline at end of file +} // namespace drt::io