Skip to content

Commit e56b51d

Browse files
authored
Merge pull request #7968 from AcKoucher/mpl-keep-clustering
mpl: add option to store clustering data as dbGroups
2 parents 1e90686 + 40136a5 commit e56b51d

12 files changed

Lines changed: 738 additions & 6 deletions

File tree

src/mpl/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ rtl_macro_placer
4646
[-min_ar min_ar]
4747
[-report_directory report_directory]
4848
[-write_macro_placement file_name]
49+
[-keep_clustering_data]
4950
```
5051

5152
#### Options
@@ -66,6 +67,7 @@ rtl_macro_placer
6667
| `-min_ar` | Specifies the minimum aspect ratio $a$, or the ratio of its width to height of a `StandardCellCluster` from $[a, \frac{1}{a}]$. The allowed values are floats, and the default value is `0.33`. |
6768
| `-report_directory` | Save reports to this directory. |
6869
| `-write_macro_placement` | Generates a file with the design's macro placement in the format of calls for the `place_macro` command. |
70+
| `-keep_clustering_data` | Save the hierarchy generated by MPL's clustering engine in the form of dbGroups inside ODB. |
6971

7072
#### Simulated Annealing Weight parameters
7173

src/mpl/include/mpl/rtl_mp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ class MacroPlacer
6969
float target_util,
7070
float target_dead_space,
7171
float min_ar,
72-
const char* report_directory);
72+
const char* report_directory,
73+
bool keep_clustering_data);
7374

7475
void placeMacro(odb::dbInst* inst,
7576
const float& x_origin,

src/mpl/src/hier_rtlmp.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ void HierRTLMP::setReportDirectory(const char* report_directory)
181181
report_directory_ = report_directory;
182182
}
183183

184+
void HierRTLMP::setKeepClusteringData(bool keep_clustering_data)
185+
{
186+
keep_clustering_data_ = keep_clustering_data;
187+
}
188+
184189
// Top Level Function
185190
// The flow of our MacroPlacer is divided into 6 stages.
186191
// 1) Multilevel Autoclustering:
@@ -207,6 +212,10 @@ void HierRTLMP::run()
207212
return;
208213
}
209214

215+
if (keep_clustering_data_) {
216+
commitClusteringDataToDb();
217+
}
218+
210219
if (!tree_->has_std_cells) {
211220
resetSAParameters();
212221
}
@@ -2562,6 +2571,44 @@ void HierRTLMP::commitMacroPlacementToDb()
25622571
}
25632572
}
25642573

2574+
void HierRTLMP::commitClusteringDataToDb() const
2575+
{
2576+
createGroupForCluster(tree_->root.get(), nullptr);
2577+
}
2578+
2579+
void HierRTLMP::createGroupForCluster(Cluster* cluster,
2580+
odb::dbGroup* parent_group) const
2581+
{
2582+
if (cluster->isIOCluster()) {
2583+
return;
2584+
}
2585+
2586+
odb::dbGroup* cluster_group
2587+
= parent_group != nullptr
2588+
? odb::dbGroup::create(parent_group, cluster->getName().c_str())
2589+
: odb::dbGroup::create(block_, cluster->getName().c_str());
2590+
2591+
cluster_group->setType(odb::dbGroupType::VISUAL_DEBUG);
2592+
2593+
for (odb::dbInst* inst : cluster->getLeafStdCells()) {
2594+
cluster_group->addInst(inst);
2595+
}
2596+
2597+
for (odb::dbInst* macro : cluster->getLeafMacros()) {
2598+
cluster_group->addInst(macro);
2599+
}
2600+
2601+
for (odb::dbModule* module : cluster->getDbModules()) {
2602+
for (odb::dbInst* inst : module->getLeafInsts()) {
2603+
cluster_group->addInst(inst);
2604+
}
2605+
}
2606+
2607+
for (const auto& child : cluster->getChildren()) {
2608+
createGroupForCluster(child.get(), cluster_group);
2609+
}
2610+
}
2611+
25652612
void HierRTLMP::setMacroPlacementFile(const std::string& file_name)
25662613
{
25672614
macro_placement_file_ = file_name;

src/mpl/src/hier_rtlmp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class HierRTLMP
105105
void setTargetDeadSpace(float target_dead_space);
106106
void setMinAR(float min_ar);
107107
void setReportDirectory(const char* report_directory);
108+
void setKeepClusteringData(bool keep_clustering_data);
108109
void setDebug(std::unique_ptr<MplObserver>& graphics);
109110
void setDebugShowBundledNets(bool show_bundled_nets);
110111
void setDebugShowClustersIds(bool show_clusters_ids);
@@ -134,6 +135,9 @@ class HierRTLMP
134135
void updateMacrosOnDb();
135136
void updateMacroOnDb(const HardMacro* hard_macro);
136137
void commitMacroPlacementToDb();
138+
void commitClusteringDataToDb() const;
139+
void createGroupForCluster(Cluster* cluster,
140+
odb::dbGroup* parent_group) const;
137141
void clear();
138142
void computeWireLength() const;
139143

@@ -309,6 +313,7 @@ class HierRTLMP
309313
const float conversion_tolerance_ = 0.01;
310314

311315
bool skip_macro_placement_ = false;
316+
bool keep_clustering_data_{false};
312317

313318
std::unique_ptr<MplObserver> graphics_;
314319
bool is_debug_only_final_result_{false};

src/mpl/src/mpl.i

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ bool rtl_macro_placer_cmd(const int max_num_macro,
5252
const float target_util,
5353
const float target_dead_space,
5454
const float min_ar,
55-
const char* report_directory) {
55+
const char* report_directory,
56+
const bool keep_clustering_data) {
5657

5758
auto macro_placer = getMacroPlacer();
5859
const int num_threads = ord::OpenRoad::openRoad()->getThreadCount();
@@ -83,7 +84,8 @@ bool rtl_macro_placer_cmd(const int max_num_macro,
8384
target_util,
8485
target_dead_space,
8586
min_ar,
86-
report_directory);
87+
report_directory,
88+
keep_clustering_data);
8789
}
8890

8991
void set_debug_cmd(odb::dbBlock* block,

src/mpl/src/mpl.tcl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ sta::define_cmd_args "rtl_macro_placer" { -max_num_macro max_num_macro \
2929
-min_ar min_ar \
3030
-report_directory report_directory \
3131
-write_macro_placement file_name \
32+
-keep_clustering_data \
3233
}
3334
proc rtl_macro_placer { args } {
3435
sta::parse_key_args "rtl_macro_placer" args \
@@ -42,7 +43,7 @@ proc rtl_macro_placer { args } {
4243
-target_dead_space -min_ar \
4344
-report_directory \
4445
-write_macro_placement } \
45-
flags {}
46+
flags {-keep_clustering_data}
4647

4748
sta::check_argc_eq0 "rtl_macro_placer" $args
4849

@@ -198,7 +199,8 @@ proc rtl_macro_placer { args } {
198199
$target_util \
199200
$target_dead_space \
200201
$min_ar \
201-
$report_directory]
202+
$report_directory \
203+
[info exists flags(-keep_clustering_data)]]
202204
} {
203205
return false
204206
}

src/mpl/src/rtl_mp.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ bool MacroPlacer::place(const int num_threads,
5959
const float target_util,
6060
const float target_dead_space,
6161
const float min_ar,
62-
const char* report_directory)
62+
const char* report_directory,
63+
const bool keep_clustering_data)
6364
{
6465
hier_rtlmp_->setClusterSize(
6566
max_num_macro, min_num_macro, max_num_inst, min_num_inst);
@@ -84,6 +85,7 @@ bool MacroPlacer::place(const int num_threads,
8485
hier_rtlmp_->setMinAR(min_ar);
8586
hier_rtlmp_->setReportDirectory(report_directory);
8687
hier_rtlmp_->setNumThreads(num_threads);
88+
hier_rtlmp_->setKeepClusteringData(keep_clustering_data);
8789

8890
hier_rtlmp_->setGuidanceRegions(guidance_regions_);
8991

src/mpl/test/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ COMPULSORY_TESTS = [
3333
"boundary_push3",
3434
"centralization1",
3535
"clocked_macro",
36+
"keep_clustering_data",
3637
"fixed_macros",
3738
]
3839

@@ -119,6 +120,7 @@ filegroup(
119120
"io_constraints6": ["testcases/io_constraints6.def"],
120121
"io_constraints7": ["testcases/io_constraints6.def"],
121122
"io_constraints8": ["testcases/io_constraints6.def"],
123+
"keep_clustering_data": ["testcases/io_constraints6.def"],
122124
}.get(test_name, []),
123125
),
124126
)

src/mpl/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ or_integration_tests(
2626
boundary_push3
2727
centralization1
2828
clocked_macro
29+
keep_clustering_data
2930
fixed_macros
3031
)
3132

0 commit comments

Comments
 (0)