Skip to content

Commit 3b64247

Browse files
authored
Merge pull request #10325 from TheMightyDuckOfDoom/mpl-fix-commit-clustering-runtime
mpl: improve runtime of commitClusteringdataToDb()
2 parents ff29559 + 01438e8 commit 3b64247

1 file changed

Lines changed: 32 additions & 4 deletions

File tree

src/mpl/src/hier_rtlmp.cpp

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "hier_rtlmp.h"
55

66
#include <algorithm>
7+
#include <cassert>
78
#include <cmath>
89
#include <cstdint>
910
#include <fstream>
@@ -2410,6 +2411,27 @@ void HierRTLMP::commitMacroPlacementToDb()
24102411
void HierRTLMP::commitClusteringDataToDb() const
24112412
{
24122413
createGroupForCluster(tree_->root.get(), nullptr);
2414+
2415+
// Check that all instances are in a group
2416+
int ungrouped_instances = 0;
2417+
for (odb::dbInst* inst : block_->getInsts()) {
2418+
if (inst->getGroup() == nullptr) {
2419+
debugPrint(logger_,
2420+
MPL,
2421+
"commit_clustering_data",
2422+
1,
2423+
"Instance {} is not in any group.",
2424+
inst->getName());
2425+
ungrouped_instances++;
2426+
}
2427+
}
2428+
if (ungrouped_instances > 0) {
2429+
logger_->error(MPL,
2430+
49,
2431+
"{} instances are not in any group after committing "
2432+
"clustering data to the database.",
2433+
ungrouped_instances);
2434+
}
24132435
}
24142436

24152437
void HierRTLMP::createGroupForCluster(Cluster* cluster,
@@ -2427,22 +2449,28 @@ void HierRTLMP::createGroupForCluster(Cluster* cluster,
24272449
cluster_group->setType(odb::dbGroupType::VISUAL_DEBUG);
24282450

24292451
for (odb::dbInst* inst : cluster->getLeafStdCells()) {
2452+
assert(inst->getGroup() == nullptr);
24302453
cluster_group->addInst(inst);
24312454
}
24322455

24332456
for (odb::dbInst* macro : cluster->getLeafMacros()) {
2457+
assert(macro->getGroup() == nullptr);
24342458
cluster_group->addInst(macro);
24352459
}
24362460

2461+
for (const auto& child : cluster->getChildren()) {
2462+
createGroupForCluster(child.get(), cluster_group);
2463+
}
2464+
24372465
for (odb::dbModule* module : cluster->getDbModules()) {
24382466
for (odb::dbInst* inst : module->getLeafInsts()) {
2467+
if (inst->getGroup() != nullptr) {
2468+
// Skip if it is part of a child cluster
2469+
continue;
2470+
}
24392471
cluster_group->addInst(inst);
24402472
}
24412473
}
2442-
2443-
for (const auto& child : cluster->getChildren()) {
2444-
createGroupForCluster(child.get(), cluster_group);
2445-
}
24462474
}
24472475

24482476
void HierRTLMP::setMacroPlacementFile(const std::string& file_name)

0 commit comments

Comments
 (0)