From 078258bf09bb7fe96527be6a6e8064d2dd2f8080 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 6 Jun 2023 23:35:40 +0200 Subject: [PATCH 1/3] New branch for XOR performance improvement in deep mode --- src/db/db/dbHierProcessor.cc | 3 ++- src/db/unit_tests/dbHierProcessorTests.cc | 6 ++++++ testdata/algo/hlp18.oas | Bin 0 -> 482 bytes 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 testdata/algo/hlp18.oas diff --git a/src/db/db/dbHierProcessor.cc b/src/db/db/dbHierProcessor.cc index e65f14a3a..60be2d0f9 100644 --- a/src/db/db/dbHierProcessor.cc +++ b/src/db/db/dbHierProcessor.cc @@ -1239,7 +1239,8 @@ private: void collect_instance_interactions (const db::CellInstArray *inst1, const db::CellInstArray *inst2) { - // TODO: this algorithm is not in particular effective for identical arrays + // TODO: this algorithm is not in particular effective for identical arrays or for arrays + // vs. single instances const db::Cell &cell1 = mp_subject_layout->cell (inst1->object ().cell_index ()); const db::Cell &cell2 = mp_intruder_layout->cell (inst2->object ().cell_index ()); diff --git a/src/db/unit_tests/dbHierProcessorTests.cc b/src/db/unit_tests/dbHierProcessorTests.cc index 7e9fe165f..504f36c2e 100644 --- a/src/db/unit_tests/dbHierProcessorTests.cc +++ b/src/db/unit_tests/dbHierProcessorTests.cc @@ -1278,3 +1278,9 @@ TEST(FlatOperation) run_test_bool22_flat (_this, "hlp17_flat.oas", TMAndNot, 100, 101); } +TEST(Arrays) +{ + // Large arrays, NOT + run_test_bool2 (_this, "hlp18.oas", TMNot, 100); +} + diff --git a/testdata/algo/hlp18.oas b/testdata/algo/hlp18.oas new file mode 100644 index 0000000000000000000000000000000000000000..970739b6406487773b50cae479bef1208d6b687a GIT binary patch literal 482 zcmY!lcJ=kt^>+;R4CduxWH!_@V0gjKC?n3q!6L)YEF;ds&!EJR>XUoMnybM;fb~F; z;|1o9>4KX(8~>b$4qRRSKbqrK6n{_8gJqfOV literal 0 HcmV?d00001 From d604003e3fef952bf4746894c345a73b5adcdab4 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 8 Jun 2023 19:03:57 +0200 Subject: [PATCH 2/3] Changing XOR implementation to mapped The previous implementation for two layouts was based on the twofold traversal of hierarchies but that is less efficient than first mapping and then doing the XOR within the single layout. --- src/db/db/dbDeepRegion.cc | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/db/db/dbDeepRegion.cc b/src/db/db/dbDeepRegion.cc index 0d7d725de..bed425c3d 100644 --- a/src/db/db/dbDeepRegion.cc +++ b/src/db/db/dbDeepRegion.cc @@ -962,10 +962,31 @@ DeepRegion::xor_with (const Region &other, db::PropertyConstraint property_const // Implement XOR as (A-B)+(B-A) - only this implementation // is compatible with the local processor scheme - DeepLayer n1 (and_or_not_with (other_deep, false, property_constraint)); - DeepLayer n2 (other_deep->and_or_not_with (this, false, property_constraint)); + // Prepare a version of "other_deep" that is mapped into the hierarchy space + // of "this" + std::unique_ptr other_deep_mapped; + if (&other_deep->deep_layer ().layout () == &deep_layer ().layout ()) { + // shallow copy for reconfiguration (progress etc.) + other_deep_mapped.reset (new DeepRegion (other_deep->deep_layer ())); + } else { + // deep copy with mapped hierarchy + other_deep_mapped.reset (new DeepRegion (deep_layer ().derived ())); + other_deep_mapped->deep_layer ().add_from (other_deep->deep_layer ()); + } + + other_deep_mapped->set_strict_handling (strict_handling ()); + other_deep_mapped->set_base_verbosity (base_verbosity ()); + if (report_progress ()) { + other_deep_mapped->enable_progress (progress_desc () + tl::to_string (tr (" - reverse part"))); + } else { + other_deep_mapped->disable_progress (); + } + + DeepLayer n1 (and_or_not_with (other_deep_mapped.get (), false, property_constraint)); + DeepLayer n2 (other_deep_mapped->and_or_not_with (this, false, property_constraint)); n1.add_from (n2); + return new DeepRegion (n1); } From 6735f6c5d685c2f67722c4ac27ae4469633f01c8 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 8 Jun 2023 19:06:12 +0200 Subject: [PATCH 3/3] New test case --- testdata/algo/hlp18.oas | Bin 482 -> 596 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/testdata/algo/hlp18.oas b/testdata/algo/hlp18.oas index 970739b6406487773b50cae479bef1208d6b687a..2c45f1226e2203ee2ae8a16e08b474e6f22c6c58 100644 GIT binary patch delta 247 zcmaFFe1&B~RlTS&BLgGT1^x%I6a7RjnHZTS_)YLzD8Epimr;qq&Rp2$;DH@onWC3j z|8f6W^h}ed$Ke{&&*ri_JmNoEU2+}n@K*`{<-1|Hp20|wN&JWXD?@|kFANO4Oo9g( zd6|_M3KE3>9QcxG`k1xupg52G*Bz2^8%`T_Mj0C!80k)^FUaiP_)z?@Q)M8xo0`J! z=6h{-Sc@eb_i+Dl_~-N!XyYVJ0aY`FgRGx`_U)96-ynX%xKpaZ#qNdaHK(om6WFua u8JL;<{al$@-8@}=T$tIwlo2y?h<^YR<8CIP=ad-oj3U*H3_n6&fE6h*7-%G?efwTKRWSX*iiEV%&m~_A88^