From a66e434e1cc19b456a099919e1eeb895057ec395 Mon Sep 17 00:00:00 2001 From: Niko Savola Date: Wed, 3 Jun 2026 14:54:04 +0300 Subject: [PATCH] Leverage execution policies for LVS equivalence --- src/db/db/dbNetlistCompare.cc | 36 +++++++++++++++++++------------ src/db/db/dbNetlistCompareCore.cc | 25 ++++++++++++++------- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/db/db/dbNetlistCompare.cc b/src/db/db/dbNetlistCompare.cc index 88f767778..2ae94e5d5 100644 --- a/src/db/db/dbNetlistCompare.cc +++ b/src/db/db/dbNetlistCompare.cc @@ -33,6 +33,14 @@ #include "tlInternational.h" #include +#include + +#if defined(__cpp_lib_execution) +#include +#define PARALLEL_EXEC_POLICY std::execution::par, +#else +#define PARALLEL_EXEC_POLICY +#endif namespace db { @@ -507,7 +515,7 @@ static std::vector unverified_names (const db::Circuit *c, const st } } - std::sort (names.begin (), names.end ()); + std::sort (PARALLEL_EXEC_POLICY names.begin (), names.end ()); return names; } @@ -563,7 +571,7 @@ compute_device_key_for_this (const db::Device &device, const db::NetGraph &g, bo } } - std::sort (k.begin (), k.end ()); + std::sort (PARALLEL_EXEC_POLICY k.begin (), k.end ()); return k; } @@ -582,7 +590,7 @@ compute_device_key_for_other (const db::Device &device, const db::NetGraph &g, b } } - std::sort (k.begin (), k.end ()); + std::sort (PARALLEL_EXEC_POLICY k.begin (), k.end ()); return k; } @@ -636,7 +644,7 @@ compute_subcircuit_key_for_this (const db::SubCircuit &subcircuit, const db::Net } } - std::sort (k.begin (), k.end ()); + std::sort (PARALLEL_EXEC_POLICY k.begin (), k.end ()); return k; } @@ -658,7 +666,7 @@ compute_subcircuit_key_for_other (const db::SubCircuit &subcircuit, const db::Ne } } - std::sort (k.begin (), k.end ()); + std::sort (PARALLEL_EXEC_POLICY k.begin (), k.end ()); return k; } @@ -1122,8 +1130,8 @@ NetlistComparer::compare_circuits (const db::Circuit *c1, const db::Circuit *c2, break; } - std::sort (nodes.begin (), nodes.end (), CompareNodeEdgePair ()); - std::sort (other_nodes.begin (), other_nodes.end (), CompareNodeEdgePair ()); + std::sort (PARALLEL_EXEC_POLICY nodes.begin (), nodes.end (), CompareNodeEdgePair ()); + std::sort (PARALLEL_EXEC_POLICY other_nodes.begin (), other_nodes.end (), CompareNodeEdgePair ()); size_t ni = compare.derive_node_identities_from_node_set (nodes, other_nodes); if (ni > 0 && ni != failed_match) { @@ -1624,8 +1632,8 @@ NetlistComparer::do_device_assignment (const db::Circuit *c1, const db::NetGraph DeviceParametersCompare cmp; - std::sort (unmatched_a.begin (), unmatched_a.end (), cmp); - std::sort (unmatched_b.begin (), unmatched_b.end (), cmp); + std::sort (PARALLEL_EXEC_POLICY unmatched_a.begin (), unmatched_a.end (), cmp); + std::sort (PARALLEL_EXEC_POLICY unmatched_b.begin (), unmatched_b.end (), cmp); for (unmatched_list::iterator i = unmatched_a.begin (), j = unmatched_b.begin (); i != unmatched_a.end () || j != unmatched_b.end (); ) { @@ -1846,8 +1854,8 @@ NetlistComparer::do_subcircuit_assignment (const db::Circuit *c1, const db::NetG } else { - std::sort (unmatched_a.begin (), unmatched_a.end (), KeySize ()); - std::sort (unmatched_b.begin (), unmatched_b.end (), KeySize ()); + std::sort (PARALLEL_EXEC_POLICY unmatched_a.begin (), unmatched_a.end (), KeySize ()); + std::sort (PARALLEL_EXEC_POLICY unmatched_b.begin (), unmatched_b.end (), KeySize ()); for (unmatched_list::iterator i = unmatched_a.begin (), j = unmatched_b.begin (); i != unmatched_a.end () || j != unmatched_b.end (); ) { @@ -1952,7 +1960,7 @@ static bool derive_symmetry_groups (const db::NetGraph &graph, const tl::equival // all other edges need to have identical destinations for the symmetry group to be // actually symmetric - std::sort (common_nodes.begin (), common_nodes.end ()); + std::sort (PARALLEL_EXEC_POLICY common_nodes.begin (), common_nodes.end ()); if (g == symmetry_group.begin ()) { common_nodes_first.swap (common_nodes); } else if (common_nodes_first != common_nodes) { @@ -2020,7 +2028,7 @@ NetlistComparer::join_symmetric_nets (db::Circuit *circuit) } } - std::sort (nodes.begin (), nodes.end (), CompareNodeEdgePair ()); + std::sort (PARALLEL_EXEC_POLICY nodes.begin (), nodes.end (), CompareNodeEdgePair ()); // Identical nodes leading to the same nodes on the other side are candidates for symmetry. @@ -2054,7 +2062,7 @@ NetlistComparer::join_symmetric_nets (db::Circuit *circuit) } - std::sort (symmetry_groups.begin (), symmetry_groups.end ()); + std::sort (PARALLEL_EXEC_POLICY symmetry_groups.begin (), symmetry_groups.end ()); symmetry_groups.erase (std::unique (symmetry_groups.begin (), symmetry_groups.end ()), symmetry_groups.end ()); if (! symmetry_groups.empty () && tl::verbosity () >= 30) { diff --git a/src/db/db/dbNetlistCompareCore.cc b/src/db/db/dbNetlistCompareCore.cc index 112937c1b..f390fc5a3 100644 --- a/src/db/db/dbNetlistCompareCore.cc +++ b/src/db/db/dbNetlistCompareCore.cc @@ -33,6 +33,15 @@ #include "tlLog.h" #include "tlInternational.h" +#include + +#if defined(__cpp_lib_execution) +#include +#define PARALLEL_EXEC_POLICY std::execution::par, +#else +#define PARALLEL_EXEC_POLICY +#endif + namespace db { @@ -354,8 +363,8 @@ static bool edges_are_compatible (const NetGraphNode::edge_type &e, const NetGra ++t2; } - std::sort (p1.begin (), p1.end ()); - std::sort (p2.begin (), p2.end ()); + std::sort (PARALLEL_EXEC_POLICY p1.begin (), p1.end ()); + std::sort (PARALLEL_EXEC_POLICY p2.begin (), p2.end ()); if (p1 != p2) { return false; @@ -464,8 +473,8 @@ NetlistCompareCore::derive_node_identities_for_edges (NetGraphNode::edge_iterato } - std::sort (nodes.begin (), nodes.end (), CompareNodeEdgePair ()); - std::sort (other_nodes.begin (), other_nodes.end (), CompareNodeEdgePair ()); + std::sort (PARALLEL_EXEC_POLICY nodes.begin (), nodes.end (), CompareNodeEdgePair ()); + std::sort (PARALLEL_EXEC_POLICY other_nodes.begin (), other_nodes.end (), CompareNodeEdgePair ()); if (db::NetlistCompareGlobalOptions::options ()->debug_netcompare) { @@ -643,8 +652,8 @@ NetlistCompareCore::derive_node_identities (size_t net_index, size_t depth, size } } - std::sort (nodes.begin (), nodes.end ()); - std::sort (other_nodes_translated.begin (), other_nodes_translated.end ()); + std::sort (PARALLEL_EXEC_POLICY nodes.begin (), nodes.end ()); + std::sort (PARALLEL_EXEC_POLICY other_nodes_translated.begin (), other_nodes_translated.end ()); // No fit, we can shortcut if (nodes != other_nodes_translated) { @@ -1460,8 +1469,8 @@ NetlistCompareCore::analyze_failed_matches () const } } - std::sort (nodes.begin (), nodes.end (), CompareNodeEdgePair ()); - std::sort (other_nodes.begin (), other_nodes.end (), CompareNodeEdgePair ()); + std::sort (PARALLEL_EXEC_POLICY nodes.begin (), nodes.end (), CompareNodeEdgePair ()); + std::sort (PARALLEL_EXEC_POLICY other_nodes.begin (), other_nodes.end (), CompareNodeEdgePair ()); auto n1 = nodes.begin (); auto n2 = other_nodes.begin ();