From fed7a4bfed878c5060df799dee277b6d110d80f4 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 1 Jan 2019 13:07:40 +0100 Subject: [PATCH] Some performance improvement for the net extractor. --- src/db/db/dbHierNetworkProcessor.cc | 30 +++++++++++++++++++++++------ src/db/db/dbHierNetworkProcessor.h | 8 ++++++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/db/db/dbHierNetworkProcessor.cc b/src/db/db/dbHierNetworkProcessor.cc index 7f6cc1289..f78fbac7f 100644 --- a/src/db/db/dbHierNetworkProcessor.cc +++ b/src/db/db/dbHierNetworkProcessor.cc @@ -157,7 +157,7 @@ template DB_PUBLIC bool Connectivity::interacts (const db::Polyg template local_cluster::local_cluster () - : m_id (0), m_needs_update (false) + : m_id (0), m_needs_update (false), m_size (0) { // .. nothing yet .. } @@ -168,6 +168,7 @@ local_cluster::clear () { m_shapes.clear (); m_needs_update = false; + m_size = 0; m_bbox = box_type (); m_attrs.clear (); } @@ -187,6 +188,7 @@ local_cluster::add (const T &s, unsigned int la) { m_shapes[la].insert (s); m_needs_update = true; + ++m_size; } template @@ -194,11 +196,12 @@ void local_cluster::join_with (const local_cluster &other) { for (typename std::map::const_iterator s = other.m_shapes.begin (); s != other.m_shapes.end (); ++s) { - tree_type &other_tree = m_shapes[s->first]; - other_tree.insert (s->second.begin (), s->second.end ()); + tree_type &tree = m_shapes[s->first]; + tree.insert (s->second.begin (), s->second.end ()); } m_attrs.insert (other.m_attrs.begin (), other.m_attrs.end ()); + m_size += other.size (); m_needs_update = true; } @@ -310,6 +313,8 @@ local_cluster::interacts (const local_cluster &other, const db::ICplxTrans return false; } + box_type common_for_other = common.transformed (trans.inverted ()); + db::box_scanner2 scanner; transformed_box bc_t (trans); db::box_convert bc; @@ -326,12 +331,19 @@ local_cluster::interacts (const local_cluster &other, const db::ICplxTrans return false; } + any = false; + for (typename std::map::const_iterator s = other.m_shapes.begin (); s != other.m_shapes.end (); ++s) { - for (typename tree_type::touching_iterator i = s->second.begin_touching (common.transformed (trans.inverted ()), bc); ! i.at_end (); ++i) { + for (typename tree_type::touching_iterator i = s->second.begin_touching (common_for_other, bc); ! i.at_end (); ++i) { scanner.insert2 (i.operator-> (), s->first); + any = true; } } + if (! any) { + return false; + } + interaction_receiver rec (conn, trans); return ! scanner.process (rec, 1 /*==touching*/, bc, bc_t); } @@ -906,6 +918,12 @@ private: } else if (x1 != x2) { + // for instance-to-instance interactions the number of connections is more important for the + // cost of the join operation: make the one with more connections the target + if (mp_cell_clusters->connections_for_cluster (x1).size () < mp_cell_clusters->connections_for_cluster (x2).size ()) { + std::swap (x1, x2); + } + mp_cell_clusters->join_cluster_with (x1, x2); mp_cell_clusters->remove_cluster (x2); @@ -1258,7 +1276,7 @@ hier_clusters::build_local_cluster (const db::Layout &layout, const db::Cell if (tl::verbosity () >= 40) { tl::log << msg; } - tl::SelfTimer (tl::verbosity () >= 41, msg); + tl::SelfTimer timer (tl::verbosity () >= 41, msg); connected_clusters &local = m_per_cell_clusters [cell.cell_index ()]; local.build_clusters (cell, shape_flags, conn); @@ -1281,7 +1299,7 @@ hier_clusters::build_hier_connections (cell_clusters_box_converter &cbc, c if (tl::verbosity () >= 40) { tl::log << msg; } - tl::SelfTimer (tl::verbosity () >= 41, msg); + tl::SelfTimer timer (tl::verbosity () >= 41, msg); connected_clusters &local = m_per_cell_clusters [cell.cell_index ()]; diff --git a/src/db/db/dbHierNetworkProcessor.h b/src/db/db/dbHierNetworkProcessor.h index d91b4d287..21b3de313 100644 --- a/src/db/db/dbHierNetworkProcessor.h +++ b/src/db/db/dbHierNetworkProcessor.h @@ -193,6 +193,13 @@ public: return m_bbox; } + /** + * @brief Gets the total number of shapes in this cluster + */ size_t size () const + { + return m_size; + } + /** * @brief Gets the shape iterator for a given layer */ @@ -246,6 +253,7 @@ private: std::map m_shapes; box_type m_bbox; attr_set m_attrs; + size_t m_size; }; /**