Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions src/db/db/dbNetlistCompare.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
#include "tlInternational.h"

#include <cstring>
#include <algorithm>

#if defined(__cpp_lib_execution)
#include <execution>
#define PARALLEL_EXEC_POLICY std::execution::par,
#else
#define PARALLEL_EXEC_POLICY
#endif

namespace db
{
Expand Down Expand Up @@ -507,7 +515,7 @@ static std::vector<std::string> 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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 (); ) {

Expand Down Expand Up @@ -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 (); ) {

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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) {
Expand Down
25 changes: 17 additions & 8 deletions src/db/db/dbNetlistCompareCore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
#include "tlLog.h"
#include "tlInternational.h"

#include <algorithm>

#if defined(__cpp_lib_execution)
#include <execution>
#define PARALLEL_EXEC_POLICY std::execution::par,
#else
#define PARALLEL_EXEC_POLICY
#endif

namespace db
{

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 ();
Expand Down
Loading