From 1ea687d7b7e7e39e1e708665a1ed0075acd20623 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 3 Feb 2019 01:48:14 +0100 Subject: [PATCH] More details control over verbosity of region ops Plus: the region op control attributes (threads, min_coherence etc.) got lost when replacing the delegate of a region. Now they are maintained in most cases. --- src/db/db/dbAsIfFlatRegion.cc | 21 ++++++++++++++ src/db/db/dbDeepRegion.cc | 6 ++++ src/db/db/dbEdges.cc | 8 ++++-- src/db/db/dbEdges.h | 2 +- src/db/db/dbFlatRegion.cc | 6 ++++ src/db/db/dbHierProcessor.cc | 29 ++++++++++++-------- src/db/db/dbHierProcessor.h | 11 ++++++++ src/db/db/dbLayout.cc | 14 ++++++---- src/db/db/dbNetlistDeviceExtractor.cc | 1 + src/db/db/dbNetlistDeviceExtractorClasses.cc | 1 + src/db/db/dbOriginalLayerRegion.cc | 3 ++ src/db/db/dbRegion.h | 20 ++++++++++++++ src/db/db/dbRegionDelegate.cc | 7 +++++ src/db/db/dbRegionDelegate.h | 7 +++++ src/db/db/gsiDeclDbRegion.cc | 14 ++++++++++ 15 files changed, 129 insertions(+), 21 deletions(-) diff --git a/src/db/db/dbAsIfFlatRegion.cc b/src/db/db/dbAsIfFlatRegion.cc index 6becce312..3e97ea64d 100644 --- a/src/db/db/dbAsIfFlatRegion.cc +++ b/src/db/db/dbAsIfFlatRegion.cc @@ -458,6 +458,9 @@ RegionDelegate * AsIfFlatRegion::selected_interacting_generic (const Region &other, int mode, bool touching, bool inverse) const { db::EdgeProcessor ep (report_progress (), progress_desc ()); + if (base_verbosity ()) { + ep.set_base_verbosity (base_verbosity ()); + } // shortcut if (empty ()) { @@ -1055,6 +1058,9 @@ AsIfFlatRegion::merged (bool min_coherence, unsigned int min_wc) const } else { db::EdgeProcessor ep (report_progress (), progress_desc ()); + if (base_verbosity ()) { + ep.set_base_verbosity (base_verbosity ()); + } // count edges and reserve memory size_t n = 0; @@ -1132,6 +1138,9 @@ AsIfFlatRegion::sized (coord_type dx, coord_type dy, unsigned int mode) const // Generic case - the size operation will merge first db::EdgeProcessor ep (report_progress (), progress_desc ()); + if (base_verbosity ()) { + ep.set_base_verbosity (base_verbosity ()); + } // count edges and reserve memory size_t n = 0; @@ -1213,6 +1222,9 @@ AsIfFlatRegion::and_with (const Region &other) const // Generic case db::EdgeProcessor ep (report_progress (), progress_desc ()); + if (base_verbosity ()) { + ep.set_base_verbosity (base_verbosity ()); + } // count edges and reserve memory size_t n = 0; @@ -1267,6 +1279,9 @@ AsIfFlatRegion::not_with (const Region &other) const // Generic case db::EdgeProcessor ep (report_progress (), progress_desc ()); + if (base_verbosity ()) { + ep.set_base_verbosity (base_verbosity ()); + } // count edges and reserve memory size_t n = 0; @@ -1319,6 +1334,9 @@ AsIfFlatRegion::xor_with (const Region &other) const // Generic case db::EdgeProcessor ep (report_progress (), progress_desc ()); + if (base_verbosity ()) { + ep.set_base_verbosity (base_verbosity ()); + } // count edges and reserve memory size_t n = 0; @@ -1372,6 +1390,9 @@ AsIfFlatRegion::or_with (const Region &other) const // Generic case db::EdgeProcessor ep (report_progress (), progress_desc ()); + if (base_verbosity ()) { + ep.set_base_verbosity (base_verbosity ()); + } // count edges and reserve memory size_t n = 0; diff --git a/src/db/db/dbDeepRegion.cc b/src/db/db/dbDeepRegion.cc index df83fbb05..8488a06c8 100644 --- a/src/db/db/dbDeepRegion.cc +++ b/src/db/db/dbDeepRegion.cc @@ -261,6 +261,9 @@ DeepRegion::ensure_merged_polygons_valid () const m_merged_polygons.clear (); db::EdgeProcessor ep (report_progress (), progress_desc ()); + if (base_verbosity ()) { + ep.set_base_verbosity (base_verbosity ()); + } // count edges and reserve memory size_t n = 0; @@ -347,6 +350,9 @@ DeepRegion::and_or_not_with (const DeepRegion *other, bool and_op) const db::BoolAndOrNotLocalOperation op (and_op); db::LocalProcessor proc (const_cast (&m_deep_layer.layout ()), const_cast (&m_deep_layer.initial_cell ()), &other->deep_layer ().layout (), &other->deep_layer ().initial_cell ()); + if (base_verbosity ()) { + proc.set_base_verbosity (base_verbosity ()); + } proc.set_threads (m_deep_layer.store ()->threads ()); proc.set_area_ratio (m_deep_layer.store ()->max_area_ratio ()); proc.set_max_vertex_count (m_deep_layer.store ()->max_vertex_count ()); diff --git a/src/db/db/dbEdges.cc b/src/db/db/dbEdges.cc index f2a797c86..05a8c9ea0 100644 --- a/src/db/db/dbEdges.cc +++ b/src/db/db/dbEdges.cc @@ -59,7 +59,7 @@ Edges::~Edges () Edges &Edges::operator= (const Edges &other) { if (this != &other) { - set_delegate (other.mp_delegate->clone ()); + set_delegate (other.mp_delegate->clone (), false); } return *this; } @@ -100,9 +100,13 @@ Edges::iter () const } void -Edges::set_delegate (EdgesDelegate *delegate) +Edges::set_delegate (EdgesDelegate *delegate, bool keep_attributes) { if (delegate != mp_delegate) { + if (keep_attributes && mp_delegate && delegate) { + // copy attributes (threads, min_coherence etc.) from old to new + *delegate = *mp_delegate; + } delete mp_delegate; mp_delegate = delegate; } diff --git a/src/db/db/dbEdges.h b/src/db/db/dbEdges.h index efdb7c4b8..c4dfc493f 100644 --- a/src/db/db/dbEdges.h +++ b/src/db/db/dbEdges.h @@ -1268,7 +1268,7 @@ private: EdgesDelegate *mp_delegate; - void set_delegate (EdgesDelegate *delegate); + void set_delegate (EdgesDelegate *delegate, bool keep_attributes = true); FlatEdges *flat_edges (); }; diff --git a/src/db/db/dbFlatRegion.cc b/src/db/db/dbFlatRegion.cc index 52d6ba07f..d3eb99105 100644 --- a/src/db/db/dbFlatRegion.cc +++ b/src/db/db/dbFlatRegion.cc @@ -107,6 +107,9 @@ FlatRegion::ensure_merged_polygons_valid () const m_merged_polygons.clear (); db::EdgeProcessor ep (report_progress (), progress_desc ()); + if (base_verbosity ()) { + ep.set_base_verbosity (base_verbosity ()); + } // count edges and reserve memory size_t n = 0; @@ -243,6 +246,9 @@ RegionDelegate *FlatRegion::merged_in_place (bool min_coherence, unsigned int mi invalidate_cache (); db::EdgeProcessor ep (report_progress (), progress_desc ()); + if (base_verbosity ()) { + ep.set_base_verbosity (base_verbosity ()); + } // count edges and reserve memory size_t n = 0; diff --git a/src/db/db/dbHierProcessor.cc b/src/db/db/dbHierProcessor.cc index 73fb42941..03a2fb5d6 100644 --- a/src/db/db/dbHierProcessor.cc +++ b/src/db/db/dbHierProcessor.cc @@ -255,14 +255,17 @@ LocalProcessorCellContexts::create (const context_key_type &intruders) } static void -subtract (std::unordered_set &res, const std::unordered_set &other, db::Layout *layout, size_t max_vertex_count, double area_ratio) +subtract (std::unordered_set &res, const std::unordered_set &other, db::Layout *layout, const db::LocalProcessor *proc) { if (other.empty ()) { return; } + size_t max_vertex_count = proc->max_vertex_count (); + double area_ratio = proc->area_ratio (); + db::EdgeProcessor ep; - ep.set_base_verbosity (60); + ep.set_base_verbosity (proc->base_verbosity () + 30); size_t p1 = 0, p2 = 1; @@ -328,7 +331,7 @@ LocalProcessorCellContexts::compute_results (const LocalProcessorContexts &conte ++index; - if (tl::verbosity () >= 50) { + if (tl::verbosity () >= proc->base_verbosity () + 20) { tl::log << tr ("Computing local results for ") << cell->layout ()->cell_name (cell->cell_index ()) << " (context " << index << "/" << total << ")"; } @@ -374,10 +377,10 @@ LocalProcessorCellContexts::compute_results (const LocalProcessorContexts &conte if (! lost.empty ()) { - subtract (lost, res, cell->layout (), proc->max_vertex_count (), proc->area_ratio ()); + subtract (lost, res, cell->layout (), proc); if (! lost.empty ()) { - subtract (common, lost, cell->layout (), proc->max_vertex_count (), proc->area_ratio ()); + subtract (common, lost, cell->layout (), proc); for (std::vector >::const_iterator cc = sorted_contexts.begin (); cc != c; ++cc) { cc->second->propagate (lost); } @@ -394,7 +397,7 @@ LocalProcessorCellContexts::compute_results (const LocalProcessorContexts &conte if (! gained.empty ()) { - subtract (gained, common, cell->layout (), proc->max_vertex_count (), proc->area_ratio ()); + subtract (gained, common, cell->layout (), proc); if (! gained.empty ()) { c->second->propagate (gained); @@ -822,13 +825,13 @@ LocalProcessorResultComputationTask::perform () // LocalProcessor implementation LocalProcessor::LocalProcessor (db::Layout *layout, db::Cell *top) - : mp_subject_layout (layout), mp_intruder_layout (layout), mp_subject_top (top), mp_intruder_top (top), m_nthreads (0), m_max_vertex_count (0), m_area_ratio (0.0) + : mp_subject_layout (layout), mp_intruder_layout (layout), mp_subject_top (top), mp_intruder_top (top), m_nthreads (0), m_max_vertex_count (0), m_area_ratio (0.0), m_base_verbosity (30) { // .. nothing yet .. } LocalProcessor::LocalProcessor (db::Layout *subject_layout, db::Cell *subject_top, const db::Layout *intruder_layout, const db::Cell *intruder_top) - : mp_subject_layout (subject_layout), mp_intruder_layout (intruder_layout), mp_subject_top (subject_top), mp_intruder_top (intruder_top), m_nthreads (0), m_max_vertex_count (0), m_area_ratio (0.0) + : mp_subject_layout (subject_layout), mp_intruder_layout (intruder_layout), mp_subject_top (subject_top), mp_intruder_top (intruder_top), m_nthreads (0), m_max_vertex_count (0), m_area_ratio (0.0), m_base_verbosity (30) { // .. nothing yet .. } @@ -844,6 +847,8 @@ std::string LocalProcessor::description (const LocalOperation *op) const void LocalProcessor::run (LocalOperation *op, unsigned int subject_layer, unsigned int intruder_layer, unsigned int output_layer) { + tl::SelfTimer timer (tl::verbosity () > m_base_verbosity, tl::to_string (tr ("Executing ")) + description (op)); + LocalProcessorContexts contexts; compute_contexts (contexts, op, subject_layer, intruder_layer); compute_results (contexts, op, output_layer); @@ -861,7 +866,7 @@ void LocalProcessor::compute_contexts (LocalProcessorContexts &contexts, const L { try { - tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (tr ("Computing contexts for ")) + description (op)); + tl::SelfTimer timer (tl::verbosity () > m_base_verbosity + 10, tl::to_string (tr ("Computing contexts for ")) + description (op)); if (m_nthreads > 0) { mp_cc_job.reset (new tl::Job (m_nthreads)); @@ -916,7 +921,7 @@ void LocalProcessor::compute_contexts (LocalProcessorContexts &contexts, { CRONOLOGY_COLLECTION_BRACKET(event_compute_contexts) - if (tl::verbosity () >= 50) { + if (tl::verbosity () >= m_base_verbosity + 20) { if (! subject_parent) { tl::log << tr ("Computing context for top cell ") << mp_subject_layout->cell_name (subject_cell->cell_index ()); } else { @@ -1114,7 +1119,7 @@ void LocalProcessor::compute_contexts (LocalProcessorContexts &contexts, void LocalProcessor::compute_results (LocalProcessorContexts &contexts, const LocalOperation *op, unsigned int output_layer) const { - tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (tr ("Computing results for ")) + description (op)); + tl::SelfTimer timer (tl::verbosity () > m_base_verbosity + 10, tl::to_string (tr ("Computing results for ")) + description (op)); // avoids updates while we work on the layout mp_subject_layout->update (); @@ -1138,7 +1143,7 @@ LocalProcessor::compute_results (LocalProcessorContexts &contexts, const LocalOp while (true) { ++iter; - tl::SelfTimer timer (tl::verbosity () >= 41, tl::sprintf (tl::to_string (tr ("Computing results iteration #%d")), iter)); + tl::SelfTimer timer (tl::verbosity () > m_base_verbosity + 10, tl::sprintf (tl::to_string (tr ("Computing results iteration #%d")), iter)); bool any = false; std::unordered_set later; diff --git a/src/db/db/dbHierProcessor.h b/src/db/db/dbHierProcessor.h index 5bc2cf4d1..720897bd2 100644 --- a/src/db/db/dbHierProcessor.h +++ b/src/db/db/dbHierProcessor.h @@ -337,6 +337,16 @@ public: m_description = d; } + void set_base_verbosity (int vb) + { + m_base_verbosity = vb; + } + + int base_verbosity () const + { + return m_base_verbosity; + } + void set_threads (unsigned int nthreads) { m_nthreads = nthreads; @@ -379,6 +389,7 @@ private: unsigned int m_nthreads; size_t m_max_vertex_count; double m_area_ratio; + int m_base_verbosity; mutable std::auto_ptr > mp_cc_job; std::string description (const LocalOperation *op) const; diff --git a/src/db/db/dbLayout.cc b/src/db/db/dbLayout.cc index 1bbfd432b..af6fea042 100644 --- a/src/db/db/dbLayout.cc +++ b/src/db/db/dbLayout.cc @@ -42,6 +42,8 @@ namespace db { +static const int layout_base_verbosity = 30; + // ----------------------------------------------------------------- // The undo/redo operations @@ -1278,7 +1280,7 @@ Layout::update () const void Layout::do_update () { - tl::SelfTimer timer (tl::verbosity () >= 21, tl::to_string (tr ("Sorting"))); + tl::SelfTimer timer (tl::verbosity () > layout_base_verbosity, tl::to_string (tr ("Sorting"))); // establish a progress report since this operation can take some time. // HINT: because of some gcc bug, automatic destruction of the tl::Progress @@ -1293,12 +1295,12 @@ Layout::do_update () // the hierarchy management informations if (hier_dirty ()) { { - tl::SelfTimer timer (tl::verbosity () >= 31, "Updating relations"); + tl::SelfTimer timer (tl::verbosity () > layout_base_verbosity + 10, "Updating relations"); pr->set_desc (tl::to_string (tr ("Updating relations"))); update_relations (); } { - tl::SelfTimer timer (tl::verbosity () >= 31, "Topological sort"); + tl::SelfTimer timer (tl::verbosity () > layout_base_verbosity + 10, "Topological sort"); pr->set_desc (tl::to_string (tr ("Topological sorting"))); tl_assert (topological_sort ()); } @@ -1316,7 +1318,7 @@ Layout::do_update () if (bboxes_dirty ()) { { - tl::SelfTimer timer (tl::verbosity () >= 31, "Updating bounding boxes"); + tl::SelfTimer timer (tl::verbosity () > layout_base_verbosity + 10, "Updating bounding boxes"); unsigned int layers = 0; pr->set (0); pr->set_desc (tl::to_string (tr ("Updating bounding boxes"))); @@ -1338,7 +1340,7 @@ Layout::do_update () } { - tl::SelfTimer timer (tl::verbosity () >= 31, "Sorting shapes"); + tl::SelfTimer timer (tl::verbosity () > layout_base_verbosity + 10, "Sorting shapes"); pr->set (0); pr->set_desc (tl::to_string (tr ("Sorting shapes"))); for (bottom_up_iterator c = begin_bottom_up (); c != end_bottom_up (); ++c) { @@ -1351,7 +1353,7 @@ Layout::do_update () // sort the instance trees now, since we have computed the bboxes if (hier_dirty () || ! dirty_parents.empty ()) { - tl::SelfTimer timer (tl::verbosity () >= 31, "Sorting instances"); + tl::SelfTimer timer (tl::verbosity () > layout_base_verbosity + 10, "Sorting instances"); size_t layers = 0; pr->set (0); pr->set_desc (tl::to_string (tr ("Sorting instances"))); diff --git a/src/db/db/dbNetlistDeviceExtractor.cc b/src/db/db/dbNetlistDeviceExtractor.cc index d30906149..7f6394ec0 100644 --- a/src/db/db/dbNetlistDeviceExtractor.cc +++ b/src/db/db/dbNetlistDeviceExtractor.cc @@ -271,6 +271,7 @@ void NetlistDeviceExtractor::extract_without_initialize (db::Layout &layout, db: for (db::recursive_cluster_shape_iterator si (device_clusters, *l, *ci, *c); ! si.at_end(); ++si) { insert_into_region (*si, si.trans (), r); } + r.set_base_verbosity (50); } db::Box box; diff --git a/src/db/db/dbNetlistDeviceExtractorClasses.cc b/src/db/db/dbNetlistDeviceExtractorClasses.cc index 8fa72d3ac..a93c13ed6 100644 --- a/src/db/db/dbNetlistDeviceExtractorClasses.cc +++ b/src/db/db/dbNetlistDeviceExtractorClasses.cc @@ -86,6 +86,7 @@ void NetlistDeviceExtractorMOS3Transistor::extract_devices (const std::vectorset_base_verbosity (vb); + } + + /** + * @brief Gets the base verbosity + */ + unsigned int base_verbosity () const + { + return mp_delegate->base_verbosity (); + } + /** * @brief Enable progress reporting * diff --git a/src/db/db/dbRegionDelegate.cc b/src/db/db/dbRegionDelegate.cc index fd1392ec6..fc8381ca9 100644 --- a/src/db/db/dbRegionDelegate.cc +++ b/src/db/db/dbRegionDelegate.cc @@ -30,6 +30,7 @@ namespace db RegionDelegate::RegionDelegate () { + m_base_verbosity = 0; m_report_progress = false; m_merged_semantics = true; m_strict_handling = false; @@ -45,6 +46,7 @@ RegionDelegate & RegionDelegate::operator= (const RegionDelegate &other) { if (this != &other) { + m_base_verbosity = other.m_base_verbosity; m_report_progress = other.m_report_progress; m_merged_semantics = other.m_merged_semantics; m_strict_handling = other.m_strict_handling; @@ -69,6 +71,11 @@ void RegionDelegate::disable_progress () m_report_progress = false; } +void RegionDelegate::set_base_verbosity (int vb) +{ + m_base_verbosity = vb; +} + void RegionDelegate::set_min_coherence (bool f) { m_merge_min_coherence = f; diff --git a/src/db/db/dbRegionDelegate.h b/src/db/db/dbRegionDelegate.h index d0a971946..fe1ffcb25 100644 --- a/src/db/db/dbRegionDelegate.h +++ b/src/db/db/dbRegionDelegate.h @@ -80,6 +80,12 @@ public: virtual RegionDelegate *clone () const = 0; + void set_base_verbosity (int vb); + int base_verbosity () const + { + return m_base_verbosity; + } + void enable_progress (const std::string &progress_desc); void disable_progress (); @@ -200,6 +206,7 @@ private: bool m_merge_min_coherence; bool m_report_progress; std::string m_progress_desc; + int m_base_verbosity; }; } diff --git a/src/db/db/gsiDeclDbRegion.cc b/src/db/db/gsiDeclDbRegion.cc index f5b1e6877..5b7c47b31 100644 --- a/src/db/db/gsiDeclDbRegion.cc +++ b/src/db/db/gsiDeclDbRegion.cc @@ -2384,6 +2384,20 @@ Class decl_Region ("db", "Region", "@brief Disable progress reporting\n" "Calling this method will disable progress reporting. See \\enable_progress.\n" ) + + method ("base_verbosity=", &db::Region::set_base_verbosity, gsi::arg ("verbosity"), + "@brief Sets the minimum verbosity for timing reports\n" + "Timing reports will be given only if the verbosity is larger than this value. " + "Detailed reports will be given when the verbosity is more than this value plus 10.\n" + "In binary operations, the base verbosity of the first argument is considered.\n" + "\n" + "This method has been introduced in version 0.26.\n" + ) + + method ("base_verbosity", &db::Region::base_verbosity, + "@brief Gets the minimum verbosity for timing reports\n" + "See \\base_verbosity= for details.\n" + "\n" + "This method has been introduced in version 0.26.\n" + ) + method ("Euclidian", &euclidian_metrics, "@brief Specifies Euclidian metrics for the check functions\n" "This value can be used for the metrics parameter in the check functions, i.e. \\width_check. "