Skip to content

Commit

Permalink
Merge pull request #1412 from KLayout/wip2
Browse files Browse the repository at this point in the history
Wip2
  • Loading branch information
klayoutmatthias authored Jul 5, 2023
2 parents 79f26fc + 37cf773 commit 6b1aa88
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/buddies/src/bd/strmxor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ bool run_deep_xor (const XORData &xor_data)
{
db::DeepShapeStore dss;
dss.set_threads (xor_data.threads);
dss.set_wants_all_cells (true); // saves time for less cell mapping operations

double dbu = std::min (xor_data.layout_a->dbu (), xor_data.layout_b->dbu ());

Expand Down
10 changes: 5 additions & 5 deletions src/db/db/dbCellMapping.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,6 @@ class InstanceSetCompareFunction

}

std::set<db::cell_index_type> callers_b;
m_layout_b.cell (cell_b).collect_caller_cells (callers_b, selection_cone_b, -1);
callers_b.insert (cell_b);

m_repr_set = false;

std::map<db::cell_index_type, db::ICplxTrans>::const_iterator r = m_repr.find (cell_b);
Expand All @@ -164,7 +160,11 @@ class InstanceSetCompareFunction
return false;
}
}


std::set<db::cell_index_type> callers_b;
m_layout_b.cell (cell_b).collect_caller_cells (callers_b, selection_cone_b, -1);
callers_b.insert (cell_b);

trans_set_t trans (m_trans);

double mag = m_layout_b.dbu () / m_layout_a.dbu ();
Expand Down
1 change: 1 addition & 0 deletions src/db/db/dbDeepRegion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1916,6 +1916,7 @@ DeepRegion::run_check (db::edge_relation_type rel, bool different_polygons, cons

// force different polygons in the different properties case to skip intra-polygon checks
if (pc_always_different (options.prop_constraint)) {
// TODO: this forces merged primaries, so maybe that is not a good optimization?
different_polygons = true;
}

Expand Down
16 changes: 14 additions & 2 deletions src/db/db/dbDeepShapeStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,13 @@ static unsigned int init_layer (db::Layout &layout, const db::RecursiveShapeIter
}

DeepShapeStore::DeepShapeStore ()
: m_keep_layouts (true)
: m_keep_layouts (true), m_wants_all_cells (false)
{
++s_instance_count;
}

DeepShapeStore::DeepShapeStore (const std::string &topcell_name, double dbu)
: m_keep_layouts (true)
: m_keep_layouts (true), m_wants_all_cells (false)
{
++s_instance_count;

Expand Down Expand Up @@ -765,6 +765,16 @@ double DeepShapeStore::max_area_ratio () const
return m_state.max_area_ratio ();
}

void DeepShapeStore::set_wants_all_cells (bool f)
{
m_wants_all_cells = f;
}

bool DeepShapeStore::wants_all_cells () const
{
return m_wants_all_cells;
}

void DeepShapeStore::set_reject_odd_polygons (bool f)
{
m_state.set_reject_odd_polygons (f);
Expand Down Expand Up @@ -929,6 +939,8 @@ DeepLayer DeepShapeStore::create_polygon_layer (const db::RecursiveShapeIterator
db::Layout &layout = m_layouts[layout_index]->layout;
db::HierarchyBuilder &builder = m_layouts[layout_index]->builder;

builder.set_wants_all_cells (m_wants_all_cells);

unsigned int layer_index = init_layer (layout, si);
builder.set_target_layer (layer_index);

Expand Down
18 changes: 18 additions & 0 deletions src/db/db/dbDeepShapeStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,23 @@ class DB_PUBLIC DeepShapeStore
*/
int threads () const;

/**
* @brief Sets a flag indicating whether the working layouts will store the whole original hierarchy
*
* Setting this flag to true will make the deep shape store copy the
* hierarchy exactly from the origin layouts. This will take somewhat
* more memory but avoid future cell hierarchy mapping operations.
*
* If set to false, only the needed parts of the hierarchy are copied.
* This part may need to grow when further operations are triggered.
*/
void set_wants_all_cells (bool f);

/**
* @brief Gets a flag indicating whether the working layouts will store the whole original hierarchy
*/
bool wants_all_cells () const;

/**
* @brief Sets a flag indicating whether to reject odd polygons
*
Expand Down Expand Up @@ -878,6 +895,7 @@ class DB_PUBLIC DeepShapeStore
DeepShapeStoreState m_state;
std::list<DeepShapeStoreState> m_state_stack;
bool m_keep_layouts;
bool m_wants_all_cells;
tl::Mutex m_lock;

struct DeliveryMappingCacheKey
Expand Down
4 changes: 2 additions & 2 deletions src/db/db/dbHierarchyBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ static std::pair<bool, std::set<db::Box> > compute_clip_variant (const db::Box &
}

HierarchyBuilder::HierarchyBuilder (db::Layout *target, unsigned int target_layer, const db::ICplxTrans &trans, HierarchyBuilderShapeReceiver *pipe)
: mp_target (target), m_initial_pass (true), m_cm_new_entry (false), m_target_layer (target_layer), m_trans (trans)
: mp_target (target), m_initial_pass (true), m_cm_new_entry (false), m_target_layer (target_layer), m_wants_all_cells (false), m_trans (trans)
{
set_shape_receiver (pipe);
}

HierarchyBuilder::HierarchyBuilder (db::Layout *target, const db::ICplxTrans &trans, HierarchyBuilderShapeReceiver *pipe)
: mp_target (target), m_initial_pass (true), m_cm_new_entry (false), m_target_layer (0), m_trans (trans)
: mp_target (target), m_initial_pass (true), m_cm_new_entry (false), m_target_layer (0), m_wants_all_cells (false), m_trans (trans)
{
set_shape_receiver (pipe);
}
Expand Down
10 changes: 10 additions & 0 deletions src/db/db/dbHierarchyBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ class DB_PUBLIC HierarchyBuilder
*/
void set_shape_receiver (HierarchyBuilderShapeReceiver *pipe);

virtual bool wants_all_cells () const { return m_wants_all_cells; }
virtual void begin (const RecursiveShapeIterator *iter);
virtual void end (const RecursiveShapeIterator *iter);
virtual void enter_cell (const RecursiveShapeIterator *iter, const db::Cell *cell, const db::Box &region, const box_tree_type *complex_region);
Expand All @@ -311,6 +312,14 @@ class DB_PUBLIC HierarchyBuilder
m_target_layer = target_layer;
}

/**
* @brief Sets the target layer - shapes will be put there
*/
void set_wants_all_cells (bool f)
{
m_wants_all_cells = f;
}

/**
* @brief Reset the builder - performs a new initial pass
*/
Expand Down Expand Up @@ -416,6 +425,7 @@ class DB_PUBLIC HierarchyBuilder
cell_map_type::const_iterator m_cm_entry;
bool m_cm_new_entry;
unsigned int m_target_layer;
bool m_wants_all_cells;
std::vector<std::pair<bool, std::vector<db::Cell *> > > m_cell_stack;
db::Cell *mp_initial_cell;

Expand Down
6 changes: 5 additions & 1 deletion src/db/db/dbRecursiveShapeIterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,11 @@ RecursiveShapeIterator::next_shape (RecursiveShapeReceiver *receiver) const

// determine whether the cell is empty with respect to the layers specified
bool is_empty = false;
if (! m_has_layers) {
if (receiver && receiver->wants_all_cells ()) {

// don't skip empty cells in that case

} else if (! m_has_layers) {

is_empty = mp_layout->cell (m_inst->cell_index ()).bbox (m_layer).empty ();

Expand Down
5 changes: 5 additions & 0 deletions src/db/db/dbRecursiveShapeIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,11 @@ class DB_PUBLIC RecursiveShapeReceiver
*/
virtual ~RecursiveShapeReceiver () { }

/**
* @brief Returns true, if the receivers wants the full hierarchy and not just non-empty cells
*/
virtual bool wants_all_cells () const { return false; }

/**
* @brief Called once when the iterator begins pushing
*/
Expand Down
15 changes: 15 additions & 0 deletions src/db/db/gsiDeclDbDeepShapeStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@ Class<db::DeepShapeStore> decl_dbDeepShapeStore ("db", "DeepShapeStore",
gsi::method ("threads", &db::DeepShapeStore::threads,
"@brief Gets the number of threads.\n"
) +
gsi::method ("wants_all_cells=", &db::DeepShapeStore::set_wants_all_cells, gsi::arg ("flag"),
"@brief Sets a flag wether to copy the full hierarchy for the working layouts\n"
"\n"
"The DeepShapeStore object keeps a copy of the original hierarchy internally for the working layouts.\n"
"By default, this hierarchy is mapping only non-empty cells. While the operations proceed, more cells "
"may need to be added. This conservative approach saves some memory, but the update operations may "
"reduce overall performance. Setting this flag to 'true' switches to a mode where the full "
"hierarchy is copied always. This will take more memory but may save CPU time.\n"
"\n"
"This attribute has been introduced in version 0.28.10."
) +
gsi::method ("wants_all_cells", &db::DeepShapeStore::wants_all_cells,
"@brief Gets a flag wether to copy the full hierarchy for the working layouts\n"
"This attribute has been introduced in version 0.28.10."
) +
gsi::method ("reject_odd_polygons=", &db::DeepShapeStore::set_reject_odd_polygons, gsi::arg ("count"),
"@brief Sets a flag indicating whether to reject odd polygons\n"
"\n"
Expand Down
2 changes: 1 addition & 1 deletion src/drc/drc/built-in-macros/_drc_layer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2630,7 +2630,7 @@ def andnot(other)
# @brief Returns the intersection points of intersecting edge segments for two edge collections
# @synopsis layer.intersections(edges)
# This operation is similar to the "&" operator, but it does also report intersection points
# between non-colinear, but intersection edges. Such points are reported as point-like,
# between non-colinear, but intersecting edges. Such points are reported as point-like,
# degenerated edge objects.
#
# This method is available for edge layers. The argument must be an edge layer.
Expand Down
6 changes: 3 additions & 3 deletions src/lay/lay/gsiDeclLayMainWindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -472,15 +472,15 @@ Class<lay::MainWindow> decl_MainWindow (QT_EXTERNAL_BASE (QMainWindow) "lay", "M
"\n"
"This method has been added in version 0.24."
) +
gsi::method ("message", &lay::MainWindow::message, gsi::arg ("message"), gsi::arg ("time"),
gsi::method ("message", &lay::MainWindow::message, gsi::arg ("message"), gsi::arg ("time", -1, "infinite"),
"@brief Displays a message in the status bar\n"
"\n"
"@param message The message to display\n"
"@param time The time how long to display the message in ms\n"
"@param time The time how long to display the message in ms. A negative value means 'infinitely'.\n"
"\n"
"This given message is shown in the status bar for the given time.\n"
"\n"
"This method has been added in version 0.18."
"This method has been added in version 0.18. The 'time' parameter was made optional in version 0.28.10."
) +
gsi::method ("resize", (void (lay::MainWindow::*)(int, int)) &lay::MainWindow::resize, gsi::arg ("width"), gsi::arg ("height"),
"@brief Resizes the window\n"
Expand Down

0 comments on commit 6b1aa88

Please sign in to comment.