From 2eaf8145467d732bceebf8a0c9da398d58e83b59 Mon Sep 17 00:00:00 2001 From: Arthur Koucher Date: Wed, 10 Jan 2024 13:43:18 -0300 Subject: [PATCH] mpl2: create function for splitting mixed leaves individually Signed-off-by: Arthur Koucher --- src/mpl2/src/hier_rtlmp.cpp | 103 +++++++++++++++++++----------------- src/mpl2/src/hier_rtlmp.h | 1 + 2 files changed, 55 insertions(+), 49 deletions(-) diff --git a/src/mpl2/src/hier_rtlmp.cpp b/src/mpl2/src/hier_rtlmp.cpp index a82705aa226..42965e645c5 100644 --- a/src/mpl2/src/hier_rtlmp.cpp +++ b/src/mpl2/src/hier_rtlmp.cpp @@ -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 hard_macros = mixed_leaf->getHardMacros(); - std::vector 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 size_class(hard_macros.size(), -1); - classifyMacrosBySize(hard_macros, size_class); + std::vector hard_macros = mixed_leaf->getHardMacros(); + std::vector macro_clusters; - calculateConnection(); + createOneClusterForEachMacro(parent, hard_macros, macro_clusters); - std::vector signature_class(hard_macros.size(), -1); - classifyMacrosByConnSignature(macro_clusters, signature_class); + std::vector size_class(hard_macros.size(), -1); + classifyMacrosBySize(hard_macros, size_class); - std::vector 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 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 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 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 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 diff --git a/src/mpl2/src/hier_rtlmp.h b/src/mpl2/src/hier_rtlmp.h index 4461110ff89..5497f463bbb 100644 --- a/src/mpl2/src/hier_rtlmp.h +++ b/src/mpl2/src/hier_rtlmp.h @@ -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& hard_macros,