From 379a22c86a16532aefa7e0548d537df7856e80b8 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 9 Nov 2021 21:55:55 +0100 Subject: [PATCH] Restored performance of some checks --- src/db/db/dbRegionCheckUtils.cc | 28 +++++++++++++++ src/db/db/dbRegionCheckUtils.h | 3 ++ src/db/db/dbRegionLocalOperations.cc | 54 +++++++++++++++++++++++++--- 3 files changed, 80 insertions(+), 5 deletions(-) diff --git a/src/db/db/dbRegionCheckUtils.cc b/src/db/db/dbRegionCheckUtils.cc index 5b85311f2..db3434914 100644 --- a/src/db/db/dbRegionCheckUtils.cc +++ b/src/db/db/dbRegionCheckUtils.cc @@ -468,6 +468,34 @@ poly2poly_check::enter (const PolygonType &o, size_t p) } } +// TODO: move to generic header +static bool interact (const db::Box &box, const db::Edge &e) +{ + if (! e.bbox ().touches (box)) { + return false; + } else if (e.is_ortho ()) { + return true; + } else { + return e.clipped (box).first; + } +} + +template +void +poly2poly_check::enter (const PolygonType &o, size_t p, const poly2poly_check::box_type &box) +{ + if (box.empty ()) { + return; + } + + for (typename PolygonType::polygon_edge_iterator e = o.begin_edge (); ! e.at_end (); ++e) { + if (interact (box, *e)) { + m_edge_heap.push_back (*e); + m_scanner.insert (& m_edge_heap.back (), p); + } + } +} + template void poly2poly_check::process () diff --git a/src/db/db/dbRegionCheckUtils.h b/src/db/db/dbRegionCheckUtils.h index d8311980d..08297468d 100644 --- a/src/db/db/dbRegionCheckUtils.h +++ b/src/db/db/dbRegionCheckUtils.h @@ -309,6 +309,8 @@ template class DB_PUBLIC poly2poly_check { public: + typedef typename PolygonType::box_type box_type; + poly2poly_check (Edge2EdgeCheckBase &output); poly2poly_check (); @@ -318,6 +320,7 @@ public: void connect (Edge2EdgeCheckBase &output); void enter (const PolygonType &o, size_t p); + void enter (const PolygonType &o, size_t p, const box_type &search_box); void process (); private: diff --git a/src/db/db/dbRegionLocalOperations.cc b/src/db/db/dbRegionLocalOperations.cc index 339f5e2dd..ac873dc06 100644 --- a/src/db/db/dbRegionLocalOperations.cc +++ b/src/db/db/dbRegionLocalOperations.cc @@ -218,12 +218,40 @@ check_local_operation::do_compute_local (db::Layout *layout, const shape } } + bool take_all = edge_check.has_negative_edge_output () || interactions.num_intruders () == 0; + + db::Box common_box; + if (! take_all) { + + db::Vector e (edge_check.distance (), edge_check.distance ()); + + db::Box subject_box; + for (typename shape_interactions::iterator i = interactions.begin (); i != interactions.end (); ++i) { + subject_box += db::box_convert () (interactions.subject_shape (i->first)); + } + + if (edge_check.requires_different_layers ()) { + db::Box intruder_box; + for (std::set::const_iterator id = ids.begin (); id != ids.end (); ++id) { + intruder_box += db::box_convert () (interactions.intruder_shape (*id).second); + } + common_box = subject_box.enlarged (e) & intruder_box.enlarged (e); + } else { + common_box = subject_box.enlarged (e); + } + + } + if (m_has_other) { size_t n = 0; for (typename shape_interactions::iterator i = interactions.begin (); i != interactions.end (); ++i) { const TS &subject = interactions.subject_shape (i->first); - m_poly_check.enter (subject, n); + if (! take_all) { + m_poly_check.enter (subject, n, common_box); + } else { + m_poly_check.enter (subject, n); + } n += 2; } @@ -261,7 +289,11 @@ check_local_operation::do_compute_local (db::Layout *layout, const shape n = 1; for (typename std::unordered_set::const_iterator o = polygons.begin (); o != polygons.end (); ++o) { - m_poly_check.enter (*o, n); + if (! take_all) { + m_poly_check.enter (*o, n, common_box); + } else { + m_poly_check.enter (*o, n); + } n += 2; } @@ -269,7 +301,11 @@ check_local_operation::do_compute_local (db::Layout *layout, const shape n = 1; for (std::set::const_iterator id = ids.begin (); id != ids.end (); ++id) { - m_poly_check.enter (interactions.intruder_shape (*id).second, n); + if (! take_all) { + m_poly_check.enter (interactions.intruder_shape (*id).second, n, common_box); + } else { + m_poly_check.enter (interactions.intruder_shape (*id).second, n); + } n += 2; } @@ -285,7 +321,11 @@ check_local_operation::do_compute_local (db::Layout *layout, const shape // we can't directly insert because TS may be != TI const TS &ts = interactions.subject_shape (i->first); insert_into_hash (polygons, ts); - m_poly_check.enter (ts, n); + if (! take_all) { + m_poly_check.enter (ts, n, common_box); + } else { + m_poly_check.enter (ts, n); + } n += 2; } @@ -294,7 +334,11 @@ check_local_operation::do_compute_local (db::Layout *layout, const shape for (std::set::const_iterator id = ids.begin (); id != ids.end (); ++id) { const TI &ti = interactions.intruder_shape (*id).second; if (polygons.find (ti) == polygons.end ()) { - m_poly_check.enter (ti, n); + if (! take_all) { + m_poly_check.enter (ti, n, common_box); + } else { + m_poly_check.enter (ti, n); + } n += 2; } }