Skip to content

Commit

Permalink
mpl2: create function for splitting mixed leaves individually
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Koucher <[email protected]>
  • Loading branch information
AcKoucher committed Jan 10, 2024
1 parent 0e1d396 commit 2eaf814
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 49 deletions.
103 changes: 54 additions & 49 deletions src/mpl2/src/hier_rtlmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2241,73 +2241,78 @@ void HierRTLMP::breakMixedLeafCluster(Cluster* root_cluster)
}
}

// We need to update the metrics of the design if necessary
// for each leaf clusters with macros.
for (auto& mixed_leaf : mixed_leaves) {
Cluster* parent = mixed_leaf;
breakMixedLeaf(mixed_leaf);
}

// Split by replacement if macro dominated.
if (mixed_leaf->getNumStdCell() * macro_dominated_cluster_threshold_
< mixed_leaf->getNumMacro()) {
parent = mixed_leaf->getParent();
}
// Set the inst property back
setInstProperty(root_cluster);
}

mapMacroInCluster2HardMacro(mixed_leaf);
void HierRTLMP::breakMixedLeaf(Cluster* mixed_leaf)
{
Cluster* parent = mixed_leaf;

std::vector<HardMacro*> hard_macros = mixed_leaf->getHardMacros();
std::vector<Cluster*> macro_clusters;
// Split by replacement if macro dominated.
if (mixed_leaf->getNumStdCell() * macro_dominated_cluster_threshold_
< mixed_leaf->getNumMacro()) {
parent = mixed_leaf->getParent();
}

createOneClusterForEachMacro(parent, hard_macros, macro_clusters);
mapMacroInCluster2HardMacro(mixed_leaf);

std::vector<int> size_class(hard_macros.size(), -1);
classifyMacrosBySize(hard_macros, size_class);
std::vector<HardMacro*> hard_macros = mixed_leaf->getHardMacros();
std::vector<Cluster*> macro_clusters;

calculateConnection();
createOneClusterForEachMacro(parent, hard_macros, macro_clusters);

std::vector<int> signature_class(hard_macros.size(), -1);
classifyMacrosByConnSignature(macro_clusters, signature_class);
std::vector<int> size_class(hard_macros.size(), -1);
classifyMacrosBySize(hard_macros, size_class);

std::vector<int> macro_class(hard_macros.size(), -1);
// Use both size and connection signature classifications to group
// single-macro macro clusters into the same cluster.
groupSingleMacroClusters(
macro_clusters, size_class, signature_class, macro_class);
calculateConnection();

mixed_leaf->clearHardMacros();
std::vector<int> signature_class(hard_macros.size(), -1);
classifyMacrosByConnSignature(macro_clusters, signature_class);

// IMPORTANT: Restore the structure of physical hierarchical tree. Thus the
// order of leaf clusters will not change the final macro grouping results.
setInstProperty(mixed_leaf);
std::vector<int> macro_class(hard_macros.size(), -1);
// Use both size and connection signature classifications to group
// single-macro macro clusters into the same cluster.
groupSingleMacroClusters(
macro_clusters, size_class, signature_class, macro_class);

// Never use SetInstProperty in the following lines for the reason above!
std::vector<int> virtual_conn_clusters;
mixed_leaf->clearHardMacros();

if (parent == mixed_leaf) {
addStdCellClusterToSubTree(parent, mixed_leaf, virtual_conn_clusters);
} else {
replaceByStdCellCluster(mixed_leaf, virtual_conn_clusters);
}
// IMPORTANT: Restore the structure of physical hierarchical tree. Thus the
// order of leaf clusters will not change the final macro grouping results.
setInstProperty(mixed_leaf);

// Deal with macro clusters
for (int i = 0; i < macro_class.size(); i++) {
if (macro_class[i] != i) {
continue; // this macro cluster has been merged
}
macro_clusters[i]->setClusterType(HardMacroCluster);
setClusterMetrics(macro_clusters[i]);
virtual_conn_clusters.push_back(mixed_leaf->getId());
// Never use SetInstProperty in the following lines for the reason above!
std::vector<int> virtual_conn_clusters;

// Deal with the std cells
if (parent == mixed_leaf) {
addStdCellClusterToSubTree(parent, mixed_leaf, virtual_conn_clusters);
} else {
replaceByStdCellCluster(mixed_leaf, virtual_conn_clusters);
}

// Deal with the macros
for (int i = 0; i < macro_class.size(); i++) {
if (macro_class[i] != i) {
continue; // this macro cluster has been merged
}
macro_clusters[i]->setClusterType(HardMacroCluster);
setClusterMetrics(macro_clusters[i]);
virtual_conn_clusters.push_back(mixed_leaf->getId());
}

// add virtual connections
for (int i = 0; i < virtual_conn_clusters.size(); i++) {
for (int j = i + 1; j < virtual_conn_clusters.size(); j++) {
parent->addVirtualConnection(virtual_conn_clusters[i],
virtual_conn_clusters[j]);
}
// add virtual connections
for (int i = 0; i < virtual_conn_clusters.size(); i++) {
for (int j = i + 1; j < virtual_conn_clusters.size(); j++) {
parent->addVirtualConnection(virtual_conn_clusters[i],
virtual_conn_clusters[j]);
}
}
// Set the inst property back
setInstProperty(root_cluster);
}

// Map all the macros into their HardMacro objects for all the clusters
Expand Down
1 change: 1 addition & 0 deletions src/mpl2/src/hier_rtlmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class HierRTLMP
void updateSubTree(Cluster* parent);
void breakLargeFlatCluster(Cluster* parent);
void breakMixedLeafCluster(Cluster* root_cluster);
void breakMixedLeaf(Cluster* mixed_leaf);
void mapMacroInCluster2HardMacro(Cluster* cluster);
void createOneClusterForEachMacro(Cluster* parent,
const std::vector<HardMacro*>& hard_macros,
Expand Down

0 comments on commit 2eaf814

Please sign in to comment.