Skip to content

Commit cb781e9

Browse files
committed
Merge branch 'master' into mpl-notch-penalty
2 parents 287fefd + 0a48973 commit cb781e9

File tree

9 files changed

+98
-60
lines changed

9 files changed

+98
-60
lines changed

src/mpl/src/SACoreSoftMacro.cpp

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ SACoreSoftMacro::SACoreSoftMacro(PhysicalHierarchy* tree,
2929
const Rect& outline,
3030
const std::vector<SoftMacro>& macros,
3131
const SACoreWeights& core_weights,
32-
float boundary_weight,
33-
float macro_blockage_weight,
34-
float notch_weight,
32+
const SASoftWeights& soft_weights,
3533
// notch threshold
3634
float notch_h_threshold,
3735
float notch_v_threshold,
@@ -66,9 +64,9 @@ SACoreSoftMacro::SACoreSoftMacro(PhysicalHierarchy* tree,
6664
block),
6765
root_(tree->root.get())
6866
{
69-
boundary_weight_ = boundary_weight;
70-
macro_blockage_weight_ = macro_blockage_weight;
71-
notch_weight_ = notch_weight;
67+
boundary_weight_ = soft_weights.boundary;
68+
macro_blockage_weight_ = soft_weights.macro_blockage;
69+
notch_weight_ = soft_weights.notch;
7270
resize_prob_ = resize_prob;
7371
notch_h_th_ = notch_h_threshold;
7472
notch_v_th_ = notch_v_threshold;
@@ -429,7 +427,6 @@ void SACoreSoftMacro::calBoundaryPenalty()
429427
// 1) Number of macros to prioritize clusters with more macros.
430428
// 2) The macro area percentage over the cluster's total area so that
431429
// mixed clusters with large std cell area have less penalty.
432-
433430
void SACoreSoftMacro::calMacroBlockagePenalty()
434431
{
435432
macro_blockage_penalty_ = 0.0;
@@ -447,32 +444,22 @@ void SACoreSoftMacro::calMacroBlockagePenalty()
447444

448445
for (auto& blockage : blockages_) {
449446
for (const auto& macro_id : pos_seq_) {
450-
if (macros_[macro_id].getNumMacro() > 0) {
451-
const float soft_macro_x_min = macros_[macro_id].getX();
452-
const float soft_macro_x_max
453-
= soft_macro_x_min + macros_[macro_id].getWidth();
454-
const float soft_macro_y_min = macros_[macro_id].getY();
455-
const float soft_macro_y_max
456-
= soft_macro_y_min + macros_[macro_id].getHeight();
457-
458-
const float overlap_width
459-
= std::min(blockage.xMax(), soft_macro_x_max)
460-
- std::max(blockage.xMin(), soft_macro_x_min);
461-
const float overlap_height
462-
= std::min(blockage.yMax(), soft_macro_y_max)
463-
- std::max(blockage.yMin(), soft_macro_y_min);
447+
const SoftMacro& soft_macro = macros_[macro_id];
448+
if (soft_macro.getNumMacro() > 0) {
449+
Tiling overlap_shape
450+
= computeOverlapShape(blockage, soft_macro.getBBox());
464451

465452
// If any of the dimensions is negative, then there's no overlap.
466-
if (overlap_width < 0 || overlap_height < 0) {
453+
if (overlap_shape.width() < 0 || overlap_shape.height() < 0) {
467454
continue;
468455
}
469456

470-
Cluster* cluster = macros_[macro_id].getCluster();
457+
Cluster* cluster = soft_macro.getCluster();
471458
float macro_dominance = cluster->getMacroArea() / cluster->getArea();
472459

473-
macro_blockage_penalty_ += overlap_width * overlap_height
474-
* macros_[macro_id].getNumMacro()
475-
* macro_dominance;
460+
macro_blockage_penalty_ += overlap_shape.width()
461+
* overlap_shape.height()
462+
* soft_macro.getNumMacro() * macro_dominance;
476463
}
477464
}
478465
}
@@ -967,4 +954,15 @@ void SACoreSoftMacro::moveFloorplan(const std::pair<float, float>& offset)
967954
calPenalty();
968955
}
969956

957+
Tiling SACoreSoftMacro::computeOverlapShape(const Rect& rect_a,
958+
const Rect& rect_b) const
959+
{
960+
const float overlap_width = std::min(rect_a.xMax(), rect_b.xMax())
961+
- std::max(rect_a.xMin(), rect_b.xMin());
962+
const float overlap_height = std::min(rect_a.yMax(), rect_b.yMax())
963+
- std::max(rect_a.yMin(), rect_b.yMin());
964+
965+
return Tiling(overlap_width, overlap_height);
966+
}
967+
970968
} // namespace mpl

src/mpl/src/SACoreSoftMacro.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ class SACoreSoftMacro : public SimulatedAnnealingCore<SoftMacro>
2727
const Rect& outline,
2828
const std::vector<SoftMacro>& macros,
2929
const SACoreWeights& core_weights,
30-
float boundary_weight,
31-
float macro_blockage_weight,
32-
float notch_weight,
30+
const SASoftWeights& soft_weights,
3331
// notch threshold
3432
float notch_h_threshold,
3533
float notch_v_threshold,
@@ -94,6 +92,8 @@ class SACoreSoftMacro : public SimulatedAnnealingCore<SoftMacro>
9492
void attemptCentralization(float pre_cost);
9593
void moveFloorplan(const std::pair<float, float>& offset);
9694

95+
Tiling computeOverlapShape(const Rect& rect_a, const Rect& rect_b) const;
96+
9797
std::vector<Rect> blockages_;
9898

9999
Cluster* root_;

src/mpl/src/hier_rtlmp.cpp

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,17 @@ void HierRTLMP::setFenceWeight(float weight)
9393

9494
void HierRTLMP::setBoundaryWeight(float weight)
9595
{
96-
boundary_weight_ = weight;
96+
cluster_placement_weights_.boundary = weight;
9797
}
9898

9999
void HierRTLMP::setNotchWeight(float weight)
100100
{
101-
notch_weight_ = weight;
101+
cluster_placement_weights_.notch = weight;
102102
}
103103

104104
void HierRTLMP::setMacroBlockageWeight(float weight)
105105
{
106-
macro_blockage_weight_ = weight;
106+
cluster_placement_weights_.macro_blockage = weight;
107107
}
108108

109109
void HierRTLMP::setGlobalFence(float fence_lx,
@@ -304,9 +304,9 @@ void HierRTLMP::resetSAParameters()
304304

305305
placement_core_weights_.fence = 0.0;
306306

307-
boundary_weight_ = 0.0;
308-
notch_weight_ = 0.0;
309-
macro_blockage_weight_ = 0.0;
307+
cluster_placement_weights_.boundary = 0.0;
308+
cluster_placement_weights_.notch = 0.0;
309+
cluster_placement_weights_.macro_blockage = 0.0;
310310
}
311311

312312
void HierRTLMP::runCoarseShaping()
@@ -475,9 +475,7 @@ void HierRTLMP::calculateChildrenTilings(Cluster* parent)
475475
new_outline,
476476
macros,
477477
shaping_core_weights_,
478-
0.0, // boundary weight
479-
0.0, // macro blockage
480-
0.0, // notch weight
478+
SASoftWeights(),
481479
0.0, // no notch size
482480
0.0, // no notch size
483481
pos_swap_prob_ / action_sum,
@@ -535,9 +533,7 @@ void HierRTLMP::calculateChildrenTilings(Cluster* parent)
535533
new_outline,
536534
macros,
537535
shaping_core_weights_,
538-
0.0, // boundary weight
539-
0.0, // macro blockage
540-
0.0, // notch weight
536+
SASoftWeights(),
541537
0.0, // no notch size
542538
0.0, // no notch size
543539
pos_swap_prob_ / action_sum,
@@ -1320,9 +1316,9 @@ void HierRTLMP::adjustMacroBlockageWeight()
13201316
"Tree max level is {}, Changing macro blockage weight from {} "
13211317
"to {} (half of the outline weight)",
13221318
tree_->max_level,
1323-
macro_blockage_weight_,
1319+
cluster_placement_weights_.macro_blockage,
13241320
new_macro_blockage_weight);
1325-
macro_blockage_weight_ = new_macro_blockage_weight;
1321+
cluster_placement_weights_.macro_blockage = new_macro_blockage_weight;
13261322
}
13271323
}
13281324

@@ -1603,9 +1599,7 @@ void HierRTLMP::placeChildren(Cluster* parent)
16031599
outline,
16041600
shaped_macros,
16051601
placement_core_weights_,
1606-
boundary_weight_,
1607-
macro_blockage_weight_,
1608-
notch_weight_,
1602+
cluster_placement_weights_,
16091603
notch_h_th_,
16101604
notch_v_th_,
16111605
pos_swap_prob_ / action_sum,
@@ -1991,9 +1985,7 @@ void HierRTLMP::placeChildrenUsingMinimumTargetUtil(Cluster* parent)
19911985
outline,
19921986
shaped_macros,
19931987
placement_core_weights_,
1994-
boundary_weight_,
1995-
macro_blockage_weight_,
1996-
notch_weight_,
1988+
cluster_placement_weights_,
19971989
notch_h_th_,
19981990
notch_v_th_,
19991991
pos_swap_prob_ / action_sum,

src/mpl/src/hier_rtlmp.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ class HierRTLMP
269269
float notch_v_th_ = 10.0;
270270
float notch_h_th_ = 10.0;
271271

272-
// For cluster and macro placement.
273-
SACoreWeights placement_core_weights_;
272+
SACoreWeights placement_core_weights_; // For cluster and macro placement.
273+
SASoftWeights cluster_placement_weights_;
274274

275275
// For generation of the coarse shape (tiling) of clusters with macros.
276276
const SACoreWeights shaping_core_weights_{1.0f /* area */,
@@ -279,11 +279,6 @@ class HierRTLMP
279279
0.0f /* guidance */,
280280
0.0f /* fence */};
281281

282-
// Soft-Especific Weights
283-
float boundary_weight_ = 5.0;
284-
float notch_weight_ = 1.0; // Used inside Core, but only for Soft.
285-
float macro_blockage_weight_ = 1.0;
286-
287282
std::map<std::string, Rect> fences_; // macro_name, fence
288283
std::map<odb::dbInst*, Rect> guides_; // Macro -> Guidance Region
289284
std::vector<Rect> placement_blockages_;

src/mpl/src/shapes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ struct Interval
1414
float max{0.0f};
1515
};
1616

17-
// Coarse shape of a cluster that contains macros.
1817
class Tiling
1918
{
2019
public:

src/mpl/src/util.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ struct SACoreWeights
7272
float fence{0.0f};
7373
};
7474

75+
struct SASoftWeights
76+
{
77+
float boundary{0.0f};
78+
float notch{0.0f};
79+
float macro_blockage{0.0f};
80+
};
81+
7582
// The cost of a certain penalty is:
7683
// cost = weight * normalized_penalty
7784
//

0 commit comments

Comments
 (0)