From 8150e732af03365792ee2bc8c26b36b01db169b7 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 8 Apr 2025 19:14:01 +0200 Subject: [PATCH] Hopefully fixing strm2xor finally, added a test --- src/buddies/unit_tests/bdStrmxorTests.cc | 57 +++++++++++++++++++---- src/db/db/dbHierarchyBuilder.cc | 26 ++++------- testdata/bd/strmxor_au7d.oas | Bin 0 -> 522 bytes testdata/bd/strmxor_covered1.gds | Bin 0 -> 1152 bytes testdata/bd/strmxor_covered2.gds | Bin 0 -> 1296 bytes 5 files changed, 58 insertions(+), 25 deletions(-) create mode 100644 testdata/bd/strmxor_au7d.oas create mode 100644 testdata/bd/strmxor_covered1.gds create mode 100644 testdata/bd/strmxor_covered2.gds diff --git a/src/buddies/unit_tests/bdStrmxorTests.cc b/src/buddies/unit_tests/bdStrmxorTests.cc index cde4afde0..c065bbb43 100644 --- a/src/buddies/unit_tests/bdStrmxorTests.cc +++ b/src/buddies/unit_tests/bdStrmxorTests.cc @@ -105,7 +105,7 @@ TEST(1A_Flat) "Result summary (layers without differences are not shown):\n" "\n" " Layer Output Differences (shape count)\n" - " -------------------------------------------------------\n" + " ----------------------------------------------------------------\n" " 3/0 3/0 30\n" " 6/0 6/0 41\n" " 8/1 8/1 1\n" @@ -146,8 +146,8 @@ TEST(1A_Deep) "Layer 10/0 is not present in first layout, but in second\n" "Result summary (layers without differences are not shown):\n" "\n" - " Layer Output Differences (shape count)\n" - " -------------------------------------------------------\n" + " Layer Output Differences (hierarchical shape count)\n" + " ----------------------------------------------------------------\n" " 3/0 3/0 3\n" " 6/0 6/0 314\n" " 8/1 8/1 1\n" @@ -177,7 +177,7 @@ TEST(1B_Flat) "Result summary (layers without differences are not shown):\n" "\n" " Layer Output Differences (shape count)\n" - " -------------------------------------------------------\n" + " ----------------------------------------------------------------\n" " 3/0 - 30\n" " 6/0 - 41\n" " 8/1 - 1\n" @@ -206,9 +206,9 @@ TEST(1B_Deep) "Layer 10/0 is not present in first layout, but in second\n" "Result summary (layers without differences are not shown):\n" "\n" - " Layer Output Differences (shape count)\n" - " -------------------------------------------------------\n" - " 3/0 - 30\n" + " Layer Output Differences (hierarchical shape count)\n" + " ----------------------------------------------------------------\n" + " 3/0 - 3\n" " 6/0 - 314\n" " 8/1 - 1\n" " 10/0 - (no such layer in first layout)\n" @@ -417,7 +417,7 @@ TEST(3_FlatCount) "Result summary (layers without differences are not shown):\n" "\n" " Layer Output Differences (shape count)\n" - " -------------------------------------------------------\n" + " ----------------------------------------------------------------\n" " 3/0 - 31\n" " 6/0 - 217\n" " 8/1 - 168\n" @@ -483,7 +483,7 @@ TEST(3_FlatCountHeal) "Result summary (layers without differences are not shown):\n" "\n" " Layer Output Differences (shape count)\n" - " -------------------------------------------------------\n" + " ----------------------------------------------------------------\n" " 3/0 - 30\n" " 6/0 - 41\n" " 8/1 - 1\n" @@ -756,3 +756,42 @@ TEST(6_Deep) "Layer 10/0 is not present in first layout, but in second\n" ); } + +TEST(7_OptimizeDeep) +{ + tl::CaptureChannel cap; + + std::string input_a = tl::testdata (); + input_a += "/bd/strmxor_covered1.gds"; + + std::string input_b = tl::testdata (); + input_b += "/bd/strmxor_covered2.gds"; + + std::string au = tl::testdata (); + au += "/bd/strmxor_au7d.oas"; + + std::string output = this->tmp_file ("tmp.oas"); + + const char *argv[] = { "x", "-u", input_a.c_str (), input_b.c_str (), output.c_str () }; + + EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), (char **) argv), 1); + + db::Layout layout; + + { + tl::InputStream stream (output); + db::Reader reader (stream); + reader.read (layout); + } + + db::compare_layouts (this, layout, au, db::NormalizationMode (db::NoNormalization | db::AsPolygons)); + EXPECT_EQ (cap.captured_text (), + "Result summary (layers without differences are not shown):\n" + "\n" + " Layer Output Differences (hierarchical shape count)\n" + " ----------------------------------------------------------------\n" + " 2/0 2/0 1\n" + " 3/0 3/0 8\n" + "\n" + ); +} diff --git a/src/db/db/dbHierarchyBuilder.cc b/src/db/db/dbHierarchyBuilder.cc index bf68802fc..b54354858 100644 --- a/src/db/db/dbHierarchyBuilder.cc +++ b/src/db/db/dbHierarchyBuilder.cc @@ -152,15 +152,17 @@ static std::pair > 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_wants_all_cells (false), m_trans (trans) + : mp_target (target), m_target_layer (target_layer), m_wants_all_cells (false), m_trans (trans) { set_shape_receiver (pipe); + reset (); } 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_wants_all_cells (false), m_trans (trans) + : mp_target (target), m_target_layer (0), m_wants_all_cells (false), m_trans (trans) { set_shape_receiver (pipe); + reset (); } HierarchyBuilder::~HierarchyBuilder () @@ -178,6 +180,8 @@ void HierarchyBuilder::reset () { m_initial_pass = true; + m_cm_new_entry = false; + mp_initial_cell = 0; m_cells_to_be_filled.clear (); @@ -186,7 +190,6 @@ HierarchyBuilder::reset () m_cells_seen.clear (); m_cell_stack.clear (); m_cm_entry = null_iterator; - m_cm_new_entry = false; } const std::pair & @@ -384,12 +387,7 @@ HierarchyBuilder::make_cell_variant (const HierarchyBuilder::CellMapKey &key, co HierarchyBuilder::new_inst_mode HierarchyBuilder::new_inst (const RecursiveShapeIterator *iter, const db::CellInstArray &inst, const db::ICplxTrans &always_apply, const db::Box & /*region*/, const box_tree_type * /*complex_region*/, bool all, bool skip_shapes) { - if (skip_shapes) { - - // don't consider this instance if all cells are skipped - return NI_skip; - - } else if (all) { + if (all) { CellMapKey key (inst.object ().cell_index (), iter->is_child_inactive (inst.object ().cell_index ()), std::set ()); db::cell_index_type new_cell = make_cell_variant (key, iter->layout ()->cell_name (inst.object ().cell_index ())); @@ -406,7 +404,7 @@ HierarchyBuilder::new_inst (const RecursiveShapeIterator *iter, const db::CellIn } // To see the cell once, use NI_single. If we did see the cell already, skip the whole instance array. - return m_cells_seen.find (key) == m_cells_seen.end () ? NI_single : NI_skip; + return (! skip_shapes && m_cells_seen.find (key) == m_cells_seen.end ()) ? NI_single : NI_skip; } else { @@ -419,11 +417,7 @@ HierarchyBuilder::new_inst (const RecursiveShapeIterator *iter, const db::CellIn bool HierarchyBuilder::new_inst_member (const RecursiveShapeIterator *iter, const db::CellInstArray &inst, const db::ICplxTrans &always_apply, const db::ICplxTrans &trans, const db::Box ®ion, const box_tree_type *complex_region, bool all, bool skip_shapes) { - if (skip_shapes) { - - return false; - - } else if (all) { + if (all) { return true; @@ -449,7 +443,7 @@ HierarchyBuilder::new_inst_member (const RecursiveShapeIterator *iter, const db: } } - return m_cells_seen.find (key) == m_cells_seen.end (); + return ! skip_shapes && m_cells_seen.find (key) == m_cells_seen.end (); } } diff --git a/testdata/bd/strmxor_au7d.oas b/testdata/bd/strmxor_au7d.oas new file mode 100644 index 0000000000000000000000000000000000000000..9d64f3f3893f25cab4cb296864bba870aa54b2f8 GIT binary patch literal 522 zcmY!lcJ=kt^>+;R4CduxWH!_@V0gjKC?n3q!6L)YEF;ds&!EJR>XUoMnybM;fb~F; z;|1o9>4KX(8~>b$4qRRSKbqrK6n{_8gJqfnXwp1GBk`Zz`y_i$~x7q literal 0 HcmV?d00001 diff --git a/testdata/bd/strmxor_covered1.gds b/testdata/bd/strmxor_covered1.gds new file mode 100644 index 0000000000000000000000000000000000000000..f3d6eb6c4a02dd7bc3abe9987e76a9e581f1a214 GIT binary patch literal 1152 zcmb7@y-EW?6ot?JO%|ddCW;`7f{j4}mZC)@KPaN&4?!el9w854AvS_f5G~Rrg|&#K zg_SR&m4%fgjAwS4I9Zi-7lv=SyZ794XYN42w$Bh)cIFi>d;nRjnD6jyvAr$y9dIcrrfpadIh*R`yd&kXEak{o1e_t)y{3*U!kzif zw&{85|w1Fkl69|4cXBI>weR6m2HF1a^umR%N9zhc3n z*i_)vTBLgXqUzp4kazg`g{%34q0@hByzwwTsWHh=BiU_r?3TV0+%ERGuXjLR z1K7F*4hEV!t~ha5j9CYkZ-L@@#CicZ{s1&}oDAzHOph-_^YCaqKb)k5`Pn>?Qu1!b JsB5_{z5pQMw(_j#Xl-uH!p>uw_FxJ{4n5ddgGe|(O>HA@TAK$n*( zOdX9a-d{eC&)$q)oNX16%l!SHF=htvDQQ|=I51h4>f3FewUrTTtAP-3_pSXbD6O@7 zfYYmt*7cmwt8iQ^RYwTFy%x`{i+38utejFi%XlwJ&Z*^`D5G^fC-mse-%zSf=sh0K zi^r?(&`+6ThyLGrm$w?RD|5cYH)UVX3H@6j!|jNwBaH6XgtS*@uKZ@cdWXEf>2oBf zxyI3+^SJ%MQT)a5X8+cBVsU&>qn@Egy4$HAxAdLjcHn|}xB?Q4xlPv? z%mUpdAi;(-B!2!l@)2W08uNF|Gjoz)LmG1jK+iCcV8a@DW=}L?3^fwHJ0iVXon`Hp zguvt>uv}K^y0ESnwKw=bFmw)dvd4up9l+Xajk->T@l&cNFs8V&`cprwq?G!ZSZ6P? KmlM=jzK<_V<@z=N literal 0 HcmV?d00001