Skip to content

Commit 337520b

Browse files
authored
Merge pull request #6681 from AcKoucher/mpl-fixed-terminal-refactor
mpl: refactor to avoid future duplicated code in bug fix
2 parents 8d18347 + 5c044fe commit 337520b

File tree

2 files changed

+55
-84
lines changed

2 files changed

+55
-84
lines changed

src/mpl/src/hier_rtlmp.cpp

Lines changed: 52 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,48 +2252,7 @@ void HierRTLMP::runHierarchicalMacroPlacementWithoutBusPlanning(Cluster* parent)
22522252
io_cluster);
22532253
}
22542254

2255-
// model other clusters as fixed terminals
2256-
if (parent->getParent() != nullptr) {
2257-
std::queue<Cluster*> parents;
2258-
parents.push(parent);
2259-
while (parents.empty() == false) {
2260-
auto frontwave = parents.front();
2261-
parents.pop();
2262-
for (auto& cluster : frontwave->getParent()->getChildren()) {
2263-
if (cluster->getId() != frontwave->getId()) {
2264-
// model this as a fixed softmacro
2265-
soft_macro_id_map[cluster->getName()] = macros.size();
2266-
macros.emplace_back(
2267-
std::pair<float, float>(
2268-
cluster->getX() + cluster->getWidth() / 2.0 - outline.xMin(),
2269-
cluster->getY() + cluster->getHeight() / 2.0
2270-
- outline.yMin()),
2271-
cluster->getName(),
2272-
0.0,
2273-
0.0,
2274-
// The information of whether or not a cluster is a group of
2275-
// unplaced IO pins is needed inside the SA Core, so if a fixed
2276-
// terminal corresponds to a cluster of unplaced IO pins it needs
2277-
// to contain that cluster data.
2278-
cluster->isClusterOfUnplacedIOPins() ? cluster.get() : nullptr);
2279-
debugPrint(
2280-
logger_,
2281-
MPL,
2282-
"hierarchical_macro_placement",
2283-
1,
2284-
"fixed cluster : {}, lx = {}, ly = {}, width = {}, height = {}",
2285-
cluster->getName(),
2286-
cluster->getX(),
2287-
cluster->getY(),
2288-
cluster->getWidth(),
2289-
cluster->getHeight());
2290-
}
2291-
}
2292-
if (frontwave->getParent()->getParent() != nullptr) {
2293-
parents.push(frontwave->getParent());
2294-
}
2295-
}
2296-
}
2255+
createFixedTerminals(parent, soft_macro_id_map, macros);
22972256

22982257
// update the connnection
22992258
clustering_engine_->updateConnections();
@@ -2757,48 +2716,7 @@ void HierRTLMP::runEnhancedHierarchicalMacroPlacement(Cluster* parent)
27572716
io_cluster);
27582717
}
27592718

2760-
// model other clusters as fixed terminals
2761-
if (parent->getParent() != nullptr) {
2762-
std::queue<Cluster*> parents;
2763-
parents.push(parent);
2764-
while (parents.empty() == false) {
2765-
auto frontwave = parents.front();
2766-
parents.pop();
2767-
for (auto& cluster : frontwave->getParent()->getChildren()) {
2768-
if (cluster->getId() != frontwave->getId()) {
2769-
// model this as a fixed softmacro
2770-
soft_macro_id_map[cluster->getName()] = macros.size();
2771-
macros.emplace_back(
2772-
std::pair<float, float>(
2773-
cluster->getX() + cluster->getWidth() / 2.0 - outline.xMin(),
2774-
cluster->getY() + cluster->getHeight() / 2.0
2775-
- outline.yMin()),
2776-
cluster->getName(),
2777-
0.0,
2778-
0.0,
2779-
// The information of whether or not a cluster is a group of
2780-
// unplaced IO pins is needed inside the SA Core, so if a fixed
2781-
// terminal corresponds to a cluster of unplaced IO pins it needs
2782-
// to contain that cluster data.
2783-
cluster->isClusterOfUnplacedIOPins() ? cluster.get() : nullptr);
2784-
debugPrint(
2785-
logger_,
2786-
MPL,
2787-
"hierarchical_macro_placement",
2788-
1,
2789-
"fixed cluster : {}, lx = {}, ly = {}, width = {}, height = {}",
2790-
cluster->getName(),
2791-
cluster->getX(),
2792-
cluster->getY(),
2793-
cluster->getWidth(),
2794-
cluster->getHeight());
2795-
}
2796-
}
2797-
if (frontwave->getParent()->getParent() != nullptr) {
2798-
parents.push(frontwave->getParent());
2799-
}
2800-
}
2801-
}
2719+
createFixedTerminals(parent, soft_macro_id_map, macros);
28022720

28032721
// update the connnection
28042722
clustering_engine_->updateConnections();
@@ -3142,6 +3060,56 @@ void HierRTLMP::computeBlockageOverlap(std::vector<Rect>& overlapping_blockages,
31423060
}
31433061
}
31443062

3063+
// Create terminals for cluster placement (Soft) annealing.
3064+
void HierRTLMP::createFixedTerminals(
3065+
Cluster* parent,
3066+
std::map<std::string, int>& soft_macro_id_map,
3067+
std::vector<SoftMacro>& soft_macros)
3068+
{
3069+
if (!parent->getParent()) {
3070+
return;
3071+
}
3072+
3073+
Rect outline = parent->getBBox();
3074+
std::queue<Cluster*> parents;
3075+
parents.push(parent);
3076+
3077+
while (!parents.empty()) {
3078+
auto frontwave = parents.front();
3079+
parents.pop();
3080+
3081+
Cluster* grandparent = frontwave->getParent();
3082+
for (auto& cluster : grandparent->getChildren()) {
3083+
if (cluster->getId() != frontwave->getId()) {
3084+
soft_macro_id_map[cluster->getName()]
3085+
= static_cast<int>(soft_macros.size());
3086+
3087+
const float center_x = cluster->getX() + cluster->getWidth() / 2.0;
3088+
const float center_y = cluster->getY() + cluster->getHeight() / 2.0;
3089+
Point location = {center_x - outline.xMin(), center_y - outline.yMin()};
3090+
3091+
// The information of whether or not a cluster is a group of
3092+
// unplaced IO pins is needed inside the SA Core, so if a fixed
3093+
// terminal corresponds to a cluster of unplaced IO pins it needs
3094+
// to contain that cluster data.
3095+
Cluster* fixed_terminal_cluster
3096+
= cluster->isClusterOfUnplacedIOPins() ? cluster.get() : nullptr;
3097+
3098+
// Note that a fixed terminal is just a point.
3099+
soft_macros.emplace_back(location,
3100+
cluster->getName(),
3101+
0.0f /* width */,
3102+
0.0f /* height */,
3103+
fixed_terminal_cluster);
3104+
}
3105+
}
3106+
3107+
if (frontwave->getParent()->getParent() != nullptr) {
3108+
parents.push(frontwave->getParent());
3109+
}
3110+
}
3111+
}
3112+
31453113
// Determine the shape of each cluster based on target utilization
31463114
// and target dead space. In constrast to all previous works, we
31473115
// use two parameters: target utilization, target_dead_space.

src/mpl/src/hier_rtlmp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ class HierRTLMP
207207
void computeBlockageOverlap(std::vector<Rect>& overlapping_blockages,
208208
const Rect& blockage,
209209
const Rect& outline);
210+
void createFixedTerminals(Cluster* parent,
211+
std::map<std::string, int>& soft_macro_id_map,
212+
std::vector<SoftMacro>& soft_macros);
210213
void updateChildrenShapesAndLocations(
211214
Cluster* parent,
212215
const std::vector<SoftMacro>& shaped_macros,

0 commit comments

Comments
 (0)