Skip to content
Merged
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
18 changes: 15 additions & 3 deletions src/mpl/src/clusterEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1710,25 +1710,29 @@ void ClusteringEngine::mergeChildrenBelowThresholds(
for (auto& small_child : small_children) {
small_children_ids.push_back(small_child->getId());
}

// Firstly we perform Type 1 merge
for (int i = 0; i < num_small_children; i++) {
Cluster* close_cluster = findSingleWellFormedConnectedCluster(
small_children[i], small_children_ids);
if (close_cluster && attemptMerge(close_cluster, small_children[i])) {
if (close_cluster != nullptr
&& mergeHonorsMaxThresholds(close_cluster, small_children[i])
&& attemptMerge(close_cluster, small_children[i])) {
cluster_class[i] = close_cluster->getId();
}
}

// Then we perform Type 2 merge
std::vector<Cluster*> new_small_children;
for (int i = 0; i < num_small_children; i++) {
if (cluster_class[i] == -1) { // the cluster has not been merged
for (int j = i + 1; j < num_small_children; j++) {
if (cluster_class[j] != -1) {
continue;
}

if (sameConnectionSignature(small_children[i], small_children[j])) {
if (mergeHonorsMaxThresholds(small_children[i], small_children[j])
&& sameConnectionSignature(small_children[i],
small_children[j])) {
if (attemptMerge(small_children[i], small_children[j])) {
cluster_class[j] = i;
} else {
Expand All @@ -1746,6 +1750,7 @@ void ClusteringEngine::mergeChildrenBelowThresholds(
}

// Then we perform Type 3 merge: merge all dust cluster
std::vector<Cluster*> new_small_children;
const int dust_cluster_std_cell = 10;
for (int i = 0; i < num_small_children; i++) {
if (cluster_class[i] == -1) { // the cluster has not been merged
Expand Down Expand Up @@ -1815,6 +1820,13 @@ void ClusteringEngine::mergeChildrenBelowThresholds(
"Finished merging clusters");
}

bool ClusteringEngine::mergeHonorsMaxThresholds(const Cluster* a,
const Cluster* b) const
{
return ((a->getNumMacro() + b->getNumMacro()) <= max_macro_)
&& ((a->getNumStdCell() + b->getNumStdCell()) <= max_std_cell_);
}

bool ClusteringEngine::sameConnectionSignature(Cluster* a, Cluster* b) const
{
std::vector<int> a_neighbors = findNeighbors(a, /* ignore */ b);
Expand Down
1 change: 1 addition & 0 deletions src/mpl/src/clusterEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class ClusteringEngine
bool partitionerSolutionIsFullyUnbalanced(const std::vector<int>& solution,
int num_other_cluster_vertices);
void mergeChildrenBelowThresholds(std::vector<Cluster*>& small_children);
bool mergeHonorsMaxThresholds(const Cluster* a, const Cluster* b) const;
bool sameConnectionSignature(Cluster* a, Cluster* b) const;
bool strongConnection(Cluster* a,
Cluster* b,
Expand Down