Skip to content

Commit 96a642d

Browse files
authored
Merge pull request #10142 from AcKoucher/mpl-set-macro-default-halos
mpl: add new command set_macro_default_halo
2 parents 7bc6374 + faf4dbf commit 96a642d

104 files changed

Lines changed: 5052 additions & 4281 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/mpl/README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ rtl_macro_placer
2626
[-max_num_level max_num_level]
2727
[-coarsening_ratio coarsening_ratio]
2828
[-large_net_threshold large_net_threshold]
29-
[-halo_width halo_width]
29+
[-halo_width halo_width]
3030
[-halo_height halo_height]
3131
[-fence_lx fence_lx]
3232
[-fence_ly fence_ly]
@@ -57,7 +57,8 @@ rtl_macro_placer
5757
| `-max_num_level` | Maximum depth of physical hierarchical tree. The default value is `2`, and the allowed values are integers `[0, MAX_INT]`. |
5858
| `-coarsening_ratio` | The larger the coarsening_ratio, the faster the convergence process. The allowed values are floats, and the default value is `10.0`. |
5959
| `-large_net_threshold` | Ignore nets with many connections during clustering, such as global nets. The default value is `50`, and the allowed values are integers `[0, MAX_INT]`. |
60-
| `-halo_width` | Horizontal/vertical halo around macros (microns). The allowed values are floats, and the default value is `0.0`. |
60+
| `-halo_width` | **Deprecated: use `set_macro_default_halo` instead.** Horizontal halo around macros (microns). The default value is `0.0`. |
61+
| `-halo_height` | **Deprecated: use `set_macro_default_halo` instead.** Vertical halo around macros (microns). The default value is `0.0`. |
6162
| `-fence_lx`, `-fence_ly`, `-fence_ux`, `-fence_uy` | Defines the global fence bounding box coordinates. The default values are the core area coordinates). |
6263
| `-target_util` | Specifies the target utilization. The allowed values are floats and the default value is `0.25`. |
6364
| `-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`. |
@@ -122,9 +123,22 @@ set_macro_guidance_region
122123
| `-region` | The lower left corner and upper right corner {lx ly ux uy} of the region in microns. |
123124

124125

126+
### Set Macro Default Halo
127+
128+
Command for setting the default halo around all macros. Per-macro halos set with `set_macro_halo` take precedence.
129+
130+
```tcl
131+
set_macro_default_halo left bottom right top
132+
set_macro_default_halo width height
133+
```
134+
135+
#### Arguments
136+
137+
The left, bottom, right and top halo, or the width (sets both left and right) and height (sets both bottom and top), in microns.
138+
125139
### Set Macro Halo
126140

127-
Command for setting a halo for specific macros. If unset, the macro will use the default values specified in MACRO_PLACE_HALO.
141+
Command for setting a halo for specific macros. If unset, the macro will use the default halo.
128142

129143
```tcl
130144
set_macro_halo

src/mpl/include/mpl/rtl_mp.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ class MacroPlacer
5050
int max_num_level,
5151
float coarsening_ratio,
5252
int large_net_threshold,
53-
int halo_width,
54-
int halo_height,
5553
odb::Rect global_fence,
5654
float area_weight,
5755
float outline_weight,
@@ -76,6 +74,7 @@ class MacroPlacer
7674

7775
void setMacroPlacementFile(const std::string& file_name);
7876
void addGuidanceRegion(odb::dbInst* macro, odb::Rect region);
77+
void setDefaultHalo(int left, int bottom, int right, int top);
7978
void setMacroHalo(odb::dbInst* macro,
8079
int left,
8180
int bottom,

src/mpl/src/hier_rtlmp.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,13 @@ void HierRTLMP::setGlobalFence(odb::Rect global_fence)
111111
}
112112
}
113113

114-
void HierRTLMP::setDefaultHalo(int halo_width, int halo_height)
114+
void HierRTLMP::setDefaultHalo(int left, int bottom, int right, int top)
115115
{
116-
default_halo_ = {halo_width, halo_height, halo_width, halo_height};
116+
if (!default_halo_.isZero()) {
117+
logger_->warn(MPL, 71, "Overwriting default macro halo.");
118+
}
119+
120+
default_halo_ = {left, bottom, right, top};
117121
}
118122

119123
void HierRTLMP::setGuidanceRegions(

src/mpl/src/hier_rtlmp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class HierRTLMP
7676
// Interfaces functions for setting options
7777
// Hierarchical Macro Placement Related Options
7878
void setGlobalFence(odb::Rect global_fence);
79-
void setDefaultHalo(int halo_width, int halo_height);
79+
void setDefaultHalo(int left, int bottom, int right, int top);
8080
void setGuidanceRegions(
8181
const std::map<odb::dbInst*, odb::Rect>& guidance_regions);
8282
void setMacroHalo(odb::dbInst* macro,

src/mpl/src/mpl.i

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ bool rtl_macro_placer_cmd(const int max_num_macro,
3434
const int max_num_level,
3535
const float coarsening_ratio,
3636
const int large_net_threshold,
37-
const float halo_width,
38-
const float halo_height,
3937
const float fence_lx,
4038
const float fence_ly,
4139
const float fence_ux,
@@ -69,8 +67,6 @@ bool rtl_macro_placer_cmd(const int max_num_macro,
6967
max_num_level,
7068
coarsening_ratio,
7169
large_net_threshold,
72-
block->micronsToDbu(halo_width),
73-
block->micronsToDbu(halo_height),
7470
global_fence,
7571
area_weight,
7672
outline_weight,
@@ -136,8 +132,21 @@ add_guidance_region(odb::dbInst* macro,
136132
}
137133

138134
void
139-
set_macro_halo(odb::dbInst* macro,
140-
float left,
135+
set_default_halo(float left,
136+
float bottom,
137+
float right,
138+
float top)
139+
{
140+
odb::dbBlock* block = ord::OpenRoad::openRoad()->getDb()->getChip()->getBlock();
141+
getMacroPlacer()->setDefaultHalo(block->micronsToDbu(left),
142+
block->micronsToDbu(bottom),
143+
block->micronsToDbu(right),
144+
block->micronsToDbu(top));
145+
}
146+
147+
void
148+
set_macro_halo(odb::dbInst* macro,
149+
float left,
141150
float bottom,
142151
float right,
143152
float top)

src/mpl/src/mpl.tcl

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ proc rtl_macro_placer { args } {
6363
set max_num_level 2
6464
set coarsening_ratio 10.0
6565
set large_net_threshold 50
66-
set halo_width 0.0
67-
set halo_height 0.0
6866
set fence_lx 0.0
6967
set fence_ly 0.0
7068
set fence_ux 0.0
@@ -109,15 +107,25 @@ proc rtl_macro_placer { args } {
109107
set large_net_threshold $keys(-large_net_threshold)
110108
}
111109

112-
if { [info exists keys(-halo_width)] && [info exists keys(-halo_height)] } {
113-
set halo_width $keys(-halo_width)
114-
set halo_height $keys(-halo_height)
115-
} elseif { [info exists keys(-halo_width)] } {
116-
set halo_width $keys(-halo_width)
117-
set halo_height $keys(-halo_width)
118-
} elseif { [info exists keys(-halo_height)] } {
119-
set halo_width $keys(-halo_height)
120-
set halo_height $keys(-halo_height)
110+
if { [info exists keys(-halo_width)] || [info exists keys(-halo_height)] } {
111+
utl::warn MPL 74 "-halo_width/-halo_height are deprecated, use\
112+
the set_macro_default_halo command instead."
113+
set halo_width 0.0
114+
set halo_height 0.0
115+
116+
if { [info exists keys(-halo_width)] } {
117+
set halo_width $keys(-halo_width)
118+
set halo_height $halo_width
119+
}
120+
121+
if { [info exists keys(-halo_height)] } {
122+
set halo_height $keys(-halo_height)
123+
if { ![info exists keys(-halo_width)] } {
124+
set halo_width $halo_height
125+
}
126+
}
127+
128+
mpl::set_default_halo $halo_width $halo_height $halo_width $halo_height
121129
}
122130

123131
if { [info exists keys(-fence_lx)] } {
@@ -191,8 +199,6 @@ proc rtl_macro_placer { args } {
191199
$max_num_level \
192200
$coarsening_ratio \
193201
$large_net_threshold \
194-
$halo_width \
195-
$halo_height \
196202
$fence_lx $fence_ly $fence_ux $fence_uy \
197203
$area_weight $outline_weight $wirelength_weight \
198204
$guidance_weight $fence_weight $boundary_weight \
@@ -292,6 +298,15 @@ proc set_macro_guidance_region { args } {
292298
mpl::add_guidance_region $macro $x1 $y1 $x2 $y2
293299
}
294300

301+
sta::define_cmd_args "set_macro_default_halo" { halo }
302+
proc set_macro_default_halo { args } {
303+
sta::parse_key_args "set_macro_default_halo" args \
304+
keys {} flags {}
305+
306+
lassign [mpl::parse_halo $args] left bottom right top
307+
mpl::set_default_halo $left $bottom $right $top
308+
}
309+
295310
sta::define_cmd_args "set_macro_halo" { -macro_name macro_name \
296311
-halo halo }
297312
proc set_macro_halo { args } {
@@ -314,10 +329,16 @@ proc set_macro_halo { args } {
314329
utl::error MPL 38 "-halo is required."
315330
}
316331

332+
lassign [mpl::parse_halo $halo] left bottom right top
333+
mpl::set_macro_halo $macro $left $bottom $right $top
334+
}
335+
336+
namespace eval mpl {
337+
proc parse_halo { halo } {
317338
set length [llength $halo]
318339

319340
if { $length != 2 && $length != 4 } {
320-
utl::error MPL 54 "-halo must be a list of 2 or 4 values."
341+
utl::error MPL 72 "Halo must have 2 or 4 values."
321342
}
322343

323344
if { $length == 2 } {
@@ -330,10 +351,15 @@ proc set_macro_halo { args } {
330351
lassign $halo left bottom right top
331352
}
332353

333-
mpl::set_macro_halo $macro $left $bottom $right $top
354+
foreach value [list $left $bottom $right $top] {
355+
if { $value < 0 } {
356+
utl::error MPL 73 "Halo values must be non-negative."
357+
}
358+
}
359+
360+
return [list $left $bottom $right $top]
334361
}
335362

336-
namespace eval mpl {
337363
proc parse_macro_name { cmd macro_name } {
338364
set block [ord::get_db_block]
339365
set inst [$block findInst "$macro_name"]

src/mpl/src/object.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ class HardMacro
265265
right = halo->xMax();
266266
top = halo->yMax();
267267
}
268+
269+
bool isZero() const
270+
{
271+
return left == 0 && bottom == 0 && right == 0 && top == 0;
272+
}
268273
};
269274

270275
HardMacro(const odb::Point& location,

src/mpl/src/rtl_mp.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ bool MacroPlacer::place(const int num_threads,
4242
const int max_num_level,
4343
const float coarsening_ratio,
4444
const int large_net_threshold,
45-
const int halo_width,
46-
const int halo_height,
4745
const odb::Rect global_fence,
4846
const float area_weight,
4947
const float outline_weight,
@@ -65,7 +63,6 @@ bool MacroPlacer::place(const int num_threads,
6563
hier_rtlmp_->setMaxNumLevel(max_num_level);
6664
hier_rtlmp_->setClusterSizeRatioPerLevel(coarsening_ratio);
6765
hier_rtlmp_->setLargeNetThreshold(large_net_threshold);
68-
hier_rtlmp_->setDefaultHalo(halo_width, halo_height);
6966
hier_rtlmp_->setGlobalFence(global_fence);
7067
hier_rtlmp_->setAreaWeight(area_weight);
7168
hier_rtlmp_->setOutlineWeight(outline_weight);
@@ -217,6 +214,11 @@ void MacroPlacer::addGuidanceRegion(odb::dbInst* macro, odb::Rect region)
217214
guidance_regions_[macro] = region;
218215
}
219216

217+
void MacroPlacer::setDefaultHalo(int left, int bottom, int right, int top)
218+
{
219+
hier_rtlmp_->setDefaultHalo(left, bottom, right, top);
220+
}
221+
220222
void MacroPlacer::setMacroHalo(odb::dbInst* macro,
221223
int left,
222224
int bottom,

src/mpl/test/BUILD

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ COMPULSORY_TESTS = [
2323
"guides2",
2424
"halos1",
2525
"halos2",
26+
"halos3",
27+
"halos4",
2628
"io_constraints1",
2729
"io_constraints10",
2830
"io_constraints2",
@@ -119,6 +121,14 @@ filegroup(
119121
"testcases/halos1.def",
120122
"testcases/orientation_improve1.lef",
121123
],
124+
"halos3": [
125+
"testcases/halo3.def",
126+
"testcases/orientation_improve1.lef",
127+
],
128+
"halos4": [
129+
"testcases/halo3.def",
130+
"testcases/orientation_improve1.lef",
131+
],
122132
"io_constraints1": [
123133
"testcases/io_constraints1.def",
124134
"testcases/macro_only.lef",

src/mpl/test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ or_integration_tests(
3333
placement_blockages1
3434
halos1
3535
halos2
36+
halos3
37+
halos4
3638
)
3739

3840

0 commit comments

Comments
 (0)