From b9f8bef146e47ec5139df1d489235d07c5ddc2d4 Mon Sep 17 00:00:00 2001 From: Szymon Gizler Date: Wed, 30 Oct 2024 19:37:56 +0100 Subject: [PATCH] Replace std::set of points pairs with boost flat hashmap Signed-off-by: Szymon Gizler --- src/drt/src/db/infra/frPoint.h | 3 +-- src/drt/src/gc/FlexGC_impl.h | 11 ++++++----- src/drt/src/gc/FlexGC_init.cpp | 14 +++++++------- src/odb/include/odb/geom.h | 14 ++++++++++++++ 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/drt/src/db/infra/frPoint.h b/src/drt/src/db/infra/frPoint.h index 965c658b260..0939ef67d58 100644 --- a/src/drt/src/db/infra/frPoint.h +++ b/src/drt/src/db/infra/frPoint.h @@ -68,8 +68,7 @@ class Point3D : public Point 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, hash_value(((Point)p))); boost::hash_combine(seed, p.getZ()); return seed; } diff --git a/src/drt/src/gc/FlexGC_impl.h b/src/drt/src/gc/FlexGC_impl.h index 973f1cd48f8..86b0f27edcc 100644 --- a/src/drt/src/gc/FlexGC_impl.h +++ b/src/drt/src/gc/FlexGC_impl.h @@ -34,6 +34,7 @@ #include "dr/FlexDR.h" #include "frDesign.h" #include "gc/FlexGC.h" +#include namespace odb { class dbTechLayerCutSpacingTableDefRule; @@ -191,31 +192,31 @@ 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 4575e6a5962..bd12a686d42 100644 --- a/src/drt/src/gc/FlexGC_init.cpp +++ b/src/drt/src/gc/FlexGC_init.cpp @@ -486,7 +486,7 @@ 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 +552,7 @@ 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 +626,7 @@ 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 +698,7 @@ 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); @@ -852,7 +852,7 @@ 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; @@ -878,7 +878,7 @@ 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); @@ -916,7 +916,7 @@ 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); diff --git a/src/odb/include/odb/geom.h b/src/odb/include/odb/geom.h index 7cff0a8da4c..c8555b5cbde 100644 --- a/src/odb/include/odb/geom.h +++ b/src/odb/include/odb/geom.h @@ -40,6 +40,7 @@ #include "isotropy.h" #include "odb.h" #include "utl/Logger.h" +#include namespace odb { @@ -90,6 +91,19 @@ class Point int y_ = 0; }; +inline std::size_t hash_value(Point const& p) +{ + size_t hash = 0; + if constexpr (sizeof(size_t) == 8 && sizeof(size_t) == 2*sizeof(int)) { + // Use fast identity hash if possible. We don't care about avalanching since it will be mixed later by flat_map anyway + return ((size_t)p.getX() << 32) | p.getY(); + } else { + boost::hash_combine(hash, p.x()); + boost::hash_combine(hash, p.y()); + } + return hash; +} + std::ostream& operator<<(std::ostream& os, const Point& pIn); /*