Skip to content

Commit f5d7e6c

Browse files
committed
mpl:
1. Cache actual offset die area instead of just the half perimeter and use the cached die to compute the max dist for max cost. 2. Some renaming. Signed-off-by: Arthur Koucher <[email protected]>
1 parent e463017 commit f5d7e6c

File tree

2 files changed

+29
-28
lines changed

2 files changed

+29
-28
lines changed

src/mpl/src/SimulatedAnnealingCore.cpp

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,16 @@ SimulatedAnnealingCore<T>::SimulatedAnnealingCore(PhysicalHierarchy* tree,
8585
logger_ = logger;
8686
macros_ = macros;
8787

88+
setDieArea(tree->die_area);
8889
setBlockedBoundariesForIOs();
89-
die_hpwl_ = tree->die_area.getPerimeter() / 2;
90+
}
91+
92+
template <class T>
93+
void SimulatedAnnealingCore<T>::setDieArea(const Rect& die_area)
94+
{
95+
die_area_ = die_area;
96+
die_area_.moveHor(-outline_.xMin());
97+
die_area_.moveVer(-outline_.yMin());
9098
}
9199

92100
template <class T>
@@ -326,47 +334,42 @@ void SimulatedAnnealingCore<T>::calWirelength()
326334
template <class T>
327335
void SimulatedAnnealingCore<T>::addBoundaryDistToWirelength(
328336
const T& macro,
329-
const T& io,
337+
const T& unplaced_ios,
330338
const float net_weight)
331339
{
340+
// To generate maximum cost.
341+
const float max_dist = die_area_.getPerimeter() / 2;
342+
332343
if (isOutsideTheOutline(macro)) {
333-
wirelength_ += net_weight * die_hpwl_;
344+
wirelength_ += net_weight * max_dist;
334345
return;
335346
}
336347

337348
const float x1 = macro.getPinX();
338349
const float y1 = macro.getPinY();
339350

340-
Boundary constraint_boundary = io.getCluster()->getConstraintBoundary();
351+
Boundary constraint_boundary
352+
= unplaced_ios.getCluster()->getConstraintBoundary();
341353

342354
if (constraint_boundary == NONE) {
343-
// We need to use the bbox of the SoftMacro and NOT the Cluster to
344-
// get shape of the cluster of unconstrained IOs - which has the
345-
// shape of the die but it's offset based on the current outline.
346-
// Reminder:
347-
// - The SoftMacro bbox is the bbox w.r.t to the current outline.
348-
// - The Cluster bbox is the bbox w.r.t. to the origin of the actual
349-
// die area.
350-
const Rect& offset_die = io.getBBox();
351-
352-
float dist_to_left = die_hpwl_;
355+
float dist_to_left = max_dist;
353356
if (!left_is_blocked_) {
354-
dist_to_left = std::abs(x1 - offset_die.xMin());
357+
dist_to_left = std::abs(x1 - die_area_.xMin());
355358
}
356359

357-
float dist_to_right = die_hpwl_;
360+
float dist_to_right = max_dist;
358361
if (!right_is_blocked_) {
359-
dist_to_right = std::abs(x1 - offset_die.xMax());
362+
dist_to_right = std::abs(x1 - die_area_.xMax());
360363
}
361364

362-
float dist_to_bottom = die_hpwl_;
365+
float dist_to_bottom = max_dist;
363366
if (!bottom_is_blocked_) {
364-
dist_to_right = std::abs(y1 - offset_die.yMin());
367+
dist_to_right = std::abs(y1 - die_area_.yMin());
365368
}
366369

367-
float dist_to_top = die_hpwl_;
370+
float dist_to_top = max_dist;
368371
if (!top_is_blocked_) {
369-
dist_to_top = std::abs(y1 - offset_die.yMax());
372+
dist_to_top = std::abs(y1 - die_area_.yMax());
370373
}
371374

372375
wirelength_
@@ -375,11 +378,11 @@ void SimulatedAnnealingCore<T>::addBoundaryDistToWirelength(
375378
{dist_to_left, dist_to_right, dist_to_bottom, dist_to_top});
376379
} else if (constraint_boundary == Boundary::L
377380
|| constraint_boundary == Boundary::R) {
378-
const float x2 = io.getPinX();
381+
const float x2 = unplaced_ios.getPinX();
379382
wirelength_ += net_weight * std::abs(x2 - x1);
380383
} else if (constraint_boundary == Boundary::T
381384
|| constraint_boundary == Boundary::B) {
382-
const float y2 = io.getPinY();
385+
const float y2 = unplaced_ios.getPinY();
383386
wirelength_ += net_weight * std::abs(y2 - y1);
384387
}
385388
}

src/mpl/src/SimulatedAnnealingCore.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class SimulatedAnnealingCore
126126
void fastSA();
127127

128128
void initSequencePair();
129+
void setDieArea(const Rect& die_area);
129130
void setBlockedBoundariesForIOs();
130131
void updateBestValidResult();
131132
void useBestValidResult();
@@ -135,7 +136,7 @@ class SimulatedAnnealingCore
135136
void calOutlinePenalty();
136137
void calWirelength();
137138
void addBoundaryDistToWirelength(const T& macro,
138-
const T& io,
139+
const T& unplaced_ios,
139140
float net_weight);
140141
bool isOutsideTheOutline(const T& macro) const;
141142
void calGuidancePenalty();
@@ -163,10 +164,7 @@ class SimulatedAnnealingCore
163164
void report(const PenaltyData& penalty) const;
164165

165166
Rect outline_;
166-
167-
// The max cost for distance to boundary wirelength computation
168-
// when one of the SoftMacros is a cluster of unplaced IO pins.
169-
float die_hpwl_;
167+
Rect die_area_; // Offset to the current outline.
170168

171169
// Boundaries blocked for IO pins
172170
std::set<Boundary> blocked_boundaries_;

0 commit comments

Comments
 (0)