Skip to content

Commit fd71169

Browse files
authored
Merge pull request #9465 from AcKoucher/mpl-blockages
mpl: treat virtual pin access blockages as soft constraints
2 parents 44aff4d + 7705113 commit fd71169

44 files changed

Lines changed: 3087 additions & 3386 deletions

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ rtl_macro_placer
3939
[-fence_weight fence_weight]
4040
[-boundary_weight boundary_weight]
4141
[-notch_weight notch_weight]
42-
[-macro_blockage_weight macro_blockage_weight]
42+
[-soft_blockage_weight soft_blockage_weight]
4343
[-target_util target_util]
4444
[-min_ar min_ar]
4545
[-report_directory report_directory]
@@ -78,7 +78,7 @@ Do note that while action probabilities are normalized to 1.0, the weights are n
7878
| `-fence_weight` | Weight for fence cost, or how far the macro is from zero fence violation. The allowed values are floats, and the default value is `10.0`. |
7979
| `-boundary_weight` | Weight for the boundary, or how far the hard macro clusters are from boundaries. Note that mixed macro clusters are not pushed, thus not considered in this cost. The allowed values are floats, and the default value is `50.0`. |
8080
| `-notch_weight` | Weight for the notch, or the existence of dead space that cannot be used for placement & routing. Note that this cost applies only to hard macro clusters. The allowed values are floats, and the default value is `10.0`. |
81-
| `-macro_blockage_weight` | Weight for macro blockage, or the overlapping instances of the macro. The allowed values are floats, and the default value is `10.0`. |
81+
| `-soft_blockage_weight` | Weight for the penalty based on overlap between clusters with macros and areas of virtual blockages generated by the macro placer. The idea is to prevent macros from occupying certain areas: currently we may generate these blockages to protect the surroundings of areas reserved for IO pins. The allowed values are floats, and the default value is `10.0`. |
8282

8383
### Place Macro
8484

src/mpl/include/mpl/rtl_mp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class MacroPlacer
6060
float fence_weight,
6161
float boundary_weight,
6262
float notch_weight,
63-
float macro_blockage_weight,
63+
float soft_blockage_weight,
6464
float target_util,
6565
float min_ar,
6666
const char* report_directory,

src/mpl/src/MplObserver.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,7 @@ class MplObserver
3737
virtual void finishedClustering(PhysicalHierarchy* tree) {}
3838

3939
virtual void setMaxLevel(int max_level) {}
40-
virtual void setMacroBlockages(const std::vector<odb::Rect>& macro_blockages)
41-
{
42-
}
43-
virtual void setPlacementBlockages(
44-
const std::vector<odb::Rect>& placement_blockages)
45-
{
46-
}
40+
virtual void setSoftBlockages(const std::vector<odb::Rect>& soft_blockages) {}
4741
virtual void setNets(const BundledNetList& nets) {}
4842
virtual void setShowBundledNets(bool show_bundled_nets) {}
4943
virtual void setShowClustersIds(bool show_clusters_ids) {}
@@ -75,7 +69,7 @@ class MplObserver
7569
virtual void setBoundaryPenalty(const PenaltyData& penalty) {}
7670
virtual void setFencePenalty(const PenaltyData& penalty) {}
7771
virtual void setGuidancePenalty(const PenaltyData& penalty) {}
78-
virtual void setMacroBlockagePenalty(const PenaltyData& penalty) {}
72+
virtual void setSoftBlockagePenalty(const PenaltyData& penalty) {}
7973
virtual void setFixedMacrosPenalty(const PenaltyData& penalty) {}
8074
virtual void setNotchPenalty(const PenaltyData& penalty) {}
8175
virtual void setOutlinePenalty(const PenaltyData& penalty) {}

src/mpl/src/SACoreSoftMacro.cpp

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ SACoreSoftMacro::SACoreSoftMacro(PhysicalHierarchy* tree,
6666
root_(tree->root.get())
6767
{
6868
boundary_weight_ = soft_weights.boundary;
69-
macro_blockage_weight_ = soft_weights.macro_blockage;
69+
soft_blockage_weight_ = soft_weights.soft_blockage;
7070
notch_weight_ = soft_weights.notch;
7171
resize_prob_ = resize_prob;
7272
notch_h_th_ = notch_h_threshold;
@@ -126,14 +126,14 @@ float SACoreSoftMacro::getNormBoundaryPenalty() const
126126
return norm_boundary_penalty_;
127127
}
128128

129-
float SACoreSoftMacro::getMacroBlockagePenalty() const
129+
float SACoreSoftMacro::getSoftBlockagePenalty() const
130130
{
131-
return macro_blockage_penalty_;
131+
return soft_blockage_penalty_;
132132
}
133133

134-
float SACoreSoftMacro::getNormMacroBlockagePenalty() const
134+
float SACoreSoftMacro::getNormSoftBlockagePenalty() const
135135
{
136-
return norm_macro_blockage_penalty_;
136+
return norm_soft_blockage_penalty_;
137137
}
138138

139139
float SACoreSoftMacro::getNotchPenalty() const
@@ -170,9 +170,9 @@ float SACoreSoftMacro::calNormCost() const
170170
if (norm_boundary_penalty_ > 0.0) {
171171
cost += boundary_weight_ * boundary_penalty_ / norm_boundary_penalty_;
172172
}
173-
if (norm_macro_blockage_penalty_ > 0.0) {
174-
cost += macro_blockage_weight_ * macro_blockage_penalty_
175-
/ norm_macro_blockage_penalty_;
173+
if (norm_soft_blockage_penalty_ > 0.0) {
174+
cost += soft_blockage_weight_ * soft_blockage_penalty_
175+
/ norm_soft_blockage_penalty_;
176176
}
177177
if (norm_fixed_macros_penalty_ > 0.0) {
178178
cost += fixed_macros_weight_ * fixed_macros_penalty_
@@ -191,7 +191,7 @@ void SACoreSoftMacro::calPenalty()
191191
calGuidancePenalty();
192192
calFencePenalty();
193193
calBoundaryPenalty();
194-
calMacroBlockagePenalty();
194+
calSoftBlockagePenalty();
195195
calNotchPenalty();
196196
calFixedMacrosPenalty();
197197
if (graphics_) {
@@ -255,7 +255,7 @@ void SACoreSoftMacro::saveState()
255255
pre_guidance_penalty_ = guidance_penalty_;
256256
pre_fence_penalty_ = fence_penalty_;
257257
pre_boundary_penalty_ = boundary_penalty_;
258-
pre_macro_blockage_penalty_ = macro_blockage_penalty_;
258+
pre_soft_blockage_penalty_ = soft_blockage_penalty_;
259259
pre_notch_penalty_ = notch_penalty_;
260260
}
261261

@@ -288,7 +288,7 @@ void SACoreSoftMacro::restoreState()
288288
guidance_penalty_ = pre_guidance_penalty_;
289289
fence_penalty_ = pre_fence_penalty_;
290290
boundary_penalty_ = pre_boundary_penalty_;
291-
macro_blockage_penalty_ = pre_macro_blockage_penalty_;
291+
soft_blockage_penalty_ = pre_soft_blockage_penalty_;
292292
notch_penalty_ = pre_notch_penalty_;
293293
}
294294

@@ -302,7 +302,7 @@ void SACoreSoftMacro::initialize()
302302
std::vector<float> guidance_penalty_list;
303303
std::vector<float> fence_penalty_list;
304304
std::vector<float> boundary_penalty_list;
305-
std::vector<float> macro_blockage_penalty_list;
305+
std::vector<float> soft_blockage_penalty_list;
306306
std::vector<float> notch_penalty_list;
307307
std::vector<float> area_penalty_list;
308308
std::vector<float> fixed_macros_penalty_list;
@@ -329,7 +329,7 @@ void SACoreSoftMacro::initialize()
329329
guidance_penalty_list.push_back(guidance_penalty_);
330330
fence_penalty_list.push_back(fence_penalty_);
331331
boundary_penalty_list.push_back(boundary_penalty_);
332-
macro_blockage_penalty_list.push_back(macro_blockage_penalty_);
332+
soft_blockage_penalty_list.push_back(soft_blockage_penalty_);
333333
notch_penalty_list.push_back(notch_penalty_);
334334
fixed_macros_penalty_list.push_back(fixed_macros_penalty_);
335335
}
@@ -341,7 +341,7 @@ void SACoreSoftMacro::initialize()
341341
norm_guidance_penalty_ = calAverage(guidance_penalty_list);
342342
norm_fence_penalty_ = calAverage(fence_penalty_list);
343343
norm_boundary_penalty_ = calAverage(boundary_penalty_list);
344-
norm_macro_blockage_penalty_ = calAverage(macro_blockage_penalty_list);
344+
norm_soft_blockage_penalty_ = calAverage(soft_blockage_penalty_list);
345345
norm_notch_penalty_ = calAverage(notch_penalty_list);
346346
norm_fixed_macros_penalty_ = calAverage(fixed_macros_penalty_list);
347347

@@ -367,8 +367,8 @@ void SACoreSoftMacro::initialize()
367367
norm_fence_penalty_ = 1.0;
368368
}
369369

370-
if (norm_macro_blockage_penalty_ <= 1e-4) {
371-
norm_macro_blockage_penalty_ = 1.0;
370+
if (norm_soft_blockage_penalty_ <= 1e-4) {
371+
norm_soft_blockage_penalty_ = 1.0;
372372
}
373373

374374
if (norm_boundary_penalty_ <= 1e-4) {
@@ -393,7 +393,7 @@ void SACoreSoftMacro::initialize()
393393
guidance_penalty_ = guidance_penalty_list[i];
394394
fence_penalty_ = fence_penalty_list[i];
395395
boundary_penalty_ = boundary_penalty_list[i];
396-
macro_blockage_penalty_ = macro_blockage_penalty_list[i];
396+
soft_blockage_penalty_ = soft_blockage_penalty_list[i];
397397
notch_penalty_ = notch_penalty_list[i];
398398
fixed_macros_penalty_ = fixed_macros_penalty_list[i];
399399
cost_list.push_back(calNormCost());
@@ -474,29 +474,29 @@ void SACoreSoftMacro::calBoundaryPenalty()
474474
}
475475
}
476476

477-
// Penalty for overlapping between clusters with macros and macro blockages.
478-
// There may be situations in which we cannot guarantee that there will be
479-
// no overlap, so we consider:
477+
// Penalty for overlapping between clusters with macros and virtual blockages
478+
// generated by the macro placer. There may be situations in which we cannot
479+
// guarantee that there will be no overlap, so we consider:
480480
// 1) Number of macros to prioritize clusters with more macros.
481481
// 2) The macro area percentage over the cluster's total area so that
482482
// mixed clusters with large std cell area have less penalty.
483-
void SACoreSoftMacro::calMacroBlockagePenalty()
483+
void SACoreSoftMacro::calSoftBlockagePenalty()
484484
{
485-
macro_blockage_penalty_ = 0.0;
486-
if (blockages_.empty() || macro_blockage_weight_ <= 0.0) {
485+
soft_blockage_penalty_ = 0.0;
486+
if (soft_blockages_.empty() || soft_blockage_weight_ <= 0.0) {
487487
return;
488488
}
489489

490490
int tot_num_macros = 0;
491-
for (const auto& macro_id : pos_seq_) {
491+
for (const int macro_id : pos_seq_) {
492492
tot_num_macros += macros_[macro_id].getNumMacro();
493493
}
494494
if (tot_num_macros <= 0) {
495495
return;
496496
}
497497

498-
for (auto& blockage : blockages_) {
499-
for (const auto& macro_id : pos_seq_) {
498+
for (const odb::Rect& blockage : soft_blockages_) {
499+
for (const int macro_id : pos_seq_) {
500500
const SoftMacro& soft_macro = macros_[macro_id];
501501
if (soft_macro.getNumMacro() > 0) {
502502
odb::Rect overlap;
@@ -511,18 +511,19 @@ void SACoreSoftMacro::calMacroBlockagePenalty()
511511
const float macro_dominance
512512
= cluster->getMacroArea() / static_cast<float>(cluster->getArea());
513513

514-
macro_blockage_penalty_
514+
soft_blockage_penalty_
515515
+= overlap.area() * soft_macro.getNumMacro() * macro_dominance;
516516
}
517517
}
518518
}
519519
// normalization
520-
macro_blockage_penalty_ = macro_blockage_penalty_ / tot_num_macros;
520+
soft_blockage_penalty_ = soft_blockage_penalty_ / tot_num_macros;
521521
if (graphics_) {
522-
graphics_->setMacroBlockagePenalty({"Macro Blockage",
523-
macro_blockage_weight_,
524-
macro_blockage_penalty_,
525-
norm_macro_blockage_penalty_});
522+
graphics_->setSoftBlockagePenalty(
523+
{.name = "Soft Blockage",
524+
.weight = soft_blockage_weight_,
525+
.value = soft_blockage_penalty_,
526+
.normalization_factor = norm_soft_blockage_penalty_});
526527
}
527528
}
528529

@@ -995,10 +996,10 @@ void SACoreSoftMacro::printResults() const
995996
boundary_weight_,
996997
boundary_penalty_,
997998
norm_boundary_penalty_});
998-
report({"Macro Blockage",
999-
macro_blockage_weight_,
1000-
macro_blockage_penalty_,
1001-
norm_macro_blockage_penalty_});
999+
report({.name = "Soft Blockage",
1000+
.weight = soft_blockage_weight_,
1001+
.value = soft_blockage_penalty_,
1002+
.normalization_factor = norm_soft_blockage_penalty_});
10021003
report({"Notch", notch_weight_, notch_penalty_, norm_notch_penalty_});
10031004
reportTotalCost();
10041005
if (logger_->debugCheck(MPL, "hierarchical_macro_placement", 2)) {
@@ -1173,10 +1174,9 @@ int SACoreSoftMacro::getSegmentIndex(const int segment,
11731174
return index;
11741175
}
11751176

1176-
// The blockages here are only those that overlap with the annealing outline.
1177-
void SACoreSoftMacro::addBlockages(const std::vector<odb::Rect>& blockages)
1177+
void SACoreSoftMacro::setSoftBlockages(const RectList& soft_blockages)
11781178
{
1179-
blockages_.insert(blockages_.end(), blockages.begin(), blockages.end());
1179+
soft_blockages_ = soft_blockages;
11801180
}
11811181

11821182
std::vector<odb::Point> SACoreSoftMacro::getClustersLocations() const

src/mpl/src/SACoreSoftMacro.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class SACoreSoftMacro : public SimulatedAnnealingCore<SoftMacro>
5555
float getNormBoundaryPenalty() const;
5656
float getNotchPenalty() const;
5757
float getNormNotchPenalty() const;
58-
float getMacroBlockagePenalty() const;
59-
float getNormMacroBlockagePenalty() const;
58+
float getSoftBlockagePenalty() const;
59+
float getNormSoftBlockagePenalty() const;
6060

6161
void printResults() const; // just for test
6262

@@ -65,7 +65,7 @@ class SACoreSoftMacro : public SimulatedAnnealingCore<SoftMacro>
6565
// adjust the size of MixedCluster to fill the empty space
6666
void fillDeadSpace() override;
6767
void attemptMacroClusterAlignment();
68-
void addBlockages(const std::vector<odb::Rect>& blockages);
68+
void setSoftBlockages(const RectList& soft_blockages);
6969

7070
bool centralizationWasReverted() { return centralization_was_reverted_; }
7171

@@ -116,7 +116,7 @@ class SACoreSoftMacro : public SimulatedAnnealingCore<SoftMacro>
116116
int end_row);
117117
float calSingleNotchPenalty(int width, int height);
118118
void calNotchPenalty();
119-
void calMacroBlockagePenalty();
119+
void calSoftBlockagePenalty();
120120
void calFixedMacrosPenalty();
121121

122122
std::vector<odb::Point> getClustersLocations() const;
@@ -127,7 +127,7 @@ class SACoreSoftMacro : public SimulatedAnnealingCore<SoftMacro>
127127

128128
void findFixedMacros();
129129

130-
std::vector<odb::Rect> blockages_;
130+
std::vector<odb::Rect> soft_blockages_;
131131
std::vector<odb::Rect> fixed_macros_;
132132

133133
Cluster* root_;
@@ -143,22 +143,22 @@ class SACoreSoftMacro : public SimulatedAnnealingCore<SoftMacro>
143143

144144
// additional penalties
145145
float boundary_weight_ = 0.0;
146-
float macro_blockage_weight_ = 0.0;
146+
float soft_blockage_weight_ = 0.0;
147147
float notch_weight_ = 0.0;
148148
const float fixed_macros_weight_ = 100.0;
149149

150150
float boundary_penalty_ = 0.0;
151151
float notch_penalty_ = 0.0;
152-
float macro_blockage_penalty_ = 0.0;
152+
float soft_blockage_penalty_ = 0.0;
153153
float fixed_macros_penalty_ = 0.0;
154154

155155
float pre_boundary_penalty_ = 0.0;
156156
float pre_notch_penalty_ = 0.0;
157-
float pre_macro_blockage_penalty_ = 0.0;
157+
float pre_soft_blockage_penalty_ = 0.0;
158158

159159
float norm_boundary_penalty_ = 0.0;
160160
float norm_notch_penalty_ = 0.0;
161-
float norm_macro_blockage_penalty_ = 0.0;
161+
float norm_soft_blockage_penalty_ = 0.0;
162162
float norm_fixed_macros_penalty_ = 0.0;
163163

164164
// action prob

0 commit comments

Comments
 (0)