Skip to content

Commit 0a48973

Browse files
authored
Merge pull request #8122 from AcKoucher/mpl-overlap-function
mpl: create and use function for computing overlap shape in sa
2 parents 70c59d0 + 790fd4d commit 0a48973

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

src/mpl/src/SACoreSoftMacro.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ void SACoreSoftMacro::calBoundaryPenalty()
427427
// 1) Number of macros to prioritize clusters with more macros.
428428
// 2) The macro area percentage over the cluster's total area so that
429429
// mixed clusters with large std cell area have less penalty.
430-
431430
void SACoreSoftMacro::calMacroBlockagePenalty()
432431
{
433432
macro_blockage_penalty_ = 0.0;
@@ -445,32 +444,22 @@ void SACoreSoftMacro::calMacroBlockagePenalty()
445444

446445
for (auto& blockage : blockages_) {
447446
for (const auto& macro_id : pos_seq_) {
448-
if (macros_[macro_id].getNumMacro() > 0) {
449-
const float soft_macro_x_min = macros_[macro_id].getX();
450-
const float soft_macro_x_max
451-
= soft_macro_x_min + macros_[macro_id].getWidth();
452-
const float soft_macro_y_min = macros_[macro_id].getY();
453-
const float soft_macro_y_max
454-
= soft_macro_y_min + macros_[macro_id].getHeight();
455-
456-
const float overlap_width
457-
= std::min(blockage.xMax(), soft_macro_x_max)
458-
- std::max(blockage.xMin(), soft_macro_x_min);
459-
const float overlap_height
460-
= std::min(blockage.yMax(), soft_macro_y_max)
461-
- 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());
462451

463452
// If any of the dimensions is negative, then there's no overlap.
464-
if (overlap_width < 0 || overlap_height < 0) {
453+
if (overlap_shape.width() < 0 || overlap_shape.height() < 0) {
465454
continue;
466455
}
467456

468-
Cluster* cluster = macros_[macro_id].getCluster();
457+
Cluster* cluster = soft_macro.getCluster();
469458
float macro_dominance = cluster->getMacroArea() / cluster->getArea();
470459

471-
macro_blockage_penalty_ += overlap_width * overlap_height
472-
* macros_[macro_id].getNumMacro()
473-
* macro_dominance;
460+
macro_blockage_penalty_ += overlap_shape.width()
461+
* overlap_shape.height()
462+
* soft_macro.getNumMacro() * macro_dominance;
474463
}
475464
}
476465
}
@@ -1086,4 +1075,15 @@ void SACoreSoftMacro::moveFloorplan(const std::pair<float, float>& offset)
10861075
calPenalty();
10871076
}
10881077

1078+
Tiling SACoreSoftMacro::computeOverlapShape(const Rect& rect_a,
1079+
const Rect& rect_b) const
1080+
{
1081+
const float overlap_width = std::min(rect_a.xMax(), rect_b.xMax())
1082+
- std::max(rect_a.xMin(), rect_b.xMin());
1083+
const float overlap_height = std::min(rect_a.yMax(), rect_b.yMax())
1084+
- std::max(rect_a.yMin(), rect_b.yMin());
1085+
1086+
return Tiling(overlap_width, overlap_height);
1087+
}
1088+
10891089
} // namespace mpl

src/mpl/src/SACoreSoftMacro.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ class SACoreSoftMacro : public SimulatedAnnealingCore<SoftMacro>
9898
void attemptCentralization(float pre_cost);
9999
void moveFloorplan(const std::pair<float, float>& offset);
100100

101+
Tiling computeOverlapShape(const Rect& rect_a, const Rect& rect_b) const;
102+
101103
std::vector<Rect> blockages_;
102104

103105
Cluster* root_;

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:

0 commit comments

Comments
 (0)