diff --git a/src/db/db/db.pro b/src/db/db/db.pro index d316c1c60..1c1285342 100644 --- a/src/db/db/db.pro +++ b/src/db/db/db.pro @@ -454,3 +454,7 @@ INCLUDEPATH += $$TL_INC $$GSI_INC DEPENDPATH += $$TL_INC $$GSI_INC LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi +packagesExist(tbb) { + LIBS += -ltbb +} + diff --git a/src/db/db/dbNetlistCompare.cc b/src/db/db/dbNetlistCompare.cc index 88f767778..9054d2200 100644 --- a/src/db/db/dbNetlistCompare.cc +++ b/src/db/db/dbNetlistCompare.cc @@ -1,4 +1,18 @@ +// NOTE: must be included before any Qt header, otherwise TBB's +// emit() method collides with Qt's "emit" keyword macro. +#if __cplusplus >= 201703L + #if __has_include() + #include + #endif +#endif + +#if defined(__cpp_lib_execution) +#define PARALLEL_EXEC_POLICY std::execution::par, +#else +#define PARALLEL_EXEC_POLICY +#endif + /* KLayout Layout Viewer @@ -33,6 +47,7 @@ #include "tlInternational.h" #include +#include namespace db { @@ -507,7 +522,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 +578,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 +597,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 +651,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 +673,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 +1137,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 +1639,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 +1861,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 +1967,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 +2035,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 +2069,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..8bb5f6dfd 100644 --- a/src/db/db/dbNetlistCompareCore.cc +++ b/src/db/db/dbNetlistCompareCore.cc @@ -1,4 +1,18 @@ +// NOTE: must be included before any Qt header, otherwise TBB's +// emit() method collides with Qt's "emit" keyword macro. +#if __cplusplus >= 201703L + #if __has_include() + #include + #endif +#endif + +#if defined(__cpp_lib_execution) +#define PARALLEL_EXEC_POLICY std::execution::par, +#else +#define PARALLEL_EXEC_POLICY +#endif + /* KLayout Layout Viewer @@ -33,6 +47,8 @@ #include "tlLog.h" #include "tlInternational.h" +#include + namespace db { @@ -354,8 +370,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 +480,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 +659,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 +1476,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 ();