Skip to content

Commit ca004a3

Browse files
authored
Merge pull request The-OpenROAD-Project#8438 from The-OpenROAD-Project-staging/mpl-new-blockages
mpl: blockages as fixed macros
2 parents c645922 + 94d3e38 commit ca004a3

20 files changed

+5022
-4959
lines changed

src/mpl/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ cc_library(
4444
"//src/par",
4545
"//src/sta:opensta_lib",
4646
"//src/utl",
47+
"@boost.polygon",
4748
"@boost.random",
4849
],
4950
)

src/mpl/src/graphics.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ void Graphics::drawObjects(gui::Painter& painter)
422422

423423
int i = 0;
424424
for (const auto& macro : soft_macros_) {
425-
if (isSkippable(macro)) {
425+
if (!macro.isBlockage() && isSkippable(macro)) {
426426
continue;
427427
}
428428

@@ -554,8 +554,7 @@ template <typename T>
554554
bool Graphics::isSkippable(const T& macro)
555555
{
556556
Cluster* cluster = macro.getCluster();
557-
558-
return !cluster /*fixed terminal*/ || cluster->isClusterOfUnplacedIOPins();
557+
return !cluster || cluster->isClusterOfUnplacedIOPins();
559558
}
560559

561560
// Draw guidance regions for macros.
@@ -662,6 +661,11 @@ void Graphics::addOutlineOffsetToLine(odb::Point& from, odb::Point& to)
662661
void Graphics::setSoftMacroBrush(gui::Painter& painter,
663662
const SoftMacro& soft_macro)
664663
{
664+
if (soft_macro.isBlockage()) {
665+
painter.setBrush(gui::Painter::kDarkGreen);
666+
return;
667+
}
668+
665669
if (soft_macro.getCluster()->getClusterType() == StdCellCluster) {
666670
painter.setBrush(gui::Painter::kDarkBlue);
667671
} else if (soft_macro.getCluster()->getClusterType() == HardMacroCluster) {

src/mpl/src/hier_rtlmp.cpp

Lines changed: 77 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "hier_rtlmp.h"
55

66
#include <algorithm>
7+
#include <boost/polygon/polygon.hpp>
78
#include <cmath>
89
#include <fstream>
910
#include <iostream>
@@ -29,7 +30,7 @@
2930
#include "mpl-util.h"
3031
#include "object.h"
3132
#include "odb/db.h"
32-
#include "odb/geom.h"
33+
#include "odb/geom_boost.h"
3334
#include "odb/util.h"
3435
#include "par/PartitionMgr.h"
3536
#include "utl/Logger.h"
@@ -850,22 +851,26 @@ void HierRTLMP::setTightPackingTilings(Cluster* macro_array)
850851
{
851852
TilingList tight_packing_tilings;
852853

853-
int divider = 1;
854-
int columns = 0, rows = 0;
854+
int num_macro = static_cast<int>(macro_array->getNumMacro());
855+
float macro_width = macro_array->getHardMacros().front()->getWidth();
856+
float macro_height = macro_array->getHardMacros().front()->getHeight();
855857

856-
while (divider <= macro_array->getNumMacro()) {
857-
if (macro_array->getNumMacro() % divider == 0) {
858-
columns = macro_array->getNumMacro() / divider;
859-
rows = divider;
858+
const Rect outline = tree_->root->getBBox();
859+
860+
int columns = 0;
861+
for (int rows = 1; rows < std::sqrt(num_macro) + 1; rows++) {
862+
if (num_macro % rows == 0) {
863+
columns = num_macro / rows;
860864

861865
// We don't consider tilings for right angle rotation orientations,
862866
// because they're not allowed in our macro placer.
863-
tight_packing_tilings.emplace_back(
864-
columns * macro_array->getHardMacros().front()->getWidth(),
865-
rows * macro_array->getHardMacros().front()->getHeight());
867+
// Tiling needs to fit inside outline
868+
if (columns * macro_width <= outline.getWidth()
869+
&& rows * macro_height <= outline.getHeight()) {
870+
tight_packing_tilings.emplace_back(columns * macro_width,
871+
rows * macro_height);
872+
}
866873
}
867-
868-
++divider;
869874
}
870875

871876
macro_array->setTilings(tight_packing_tilings);
@@ -932,8 +937,20 @@ void HierRTLMP::computePinAccessDepthLimits()
932937
pin_access_depth_limits_.y.max = max_depth_proportion * die.getHeight();
933938

934939
constexpr float min_depth_proportion = 0.04;
935-
pin_access_depth_limits_.x.min = min_depth_proportion * die.getWidth();
936-
pin_access_depth_limits_.y.min = min_depth_proportion * die.getHeight();
940+
const float proportional_min_width = min_depth_proportion * die.getWidth();
941+
const float proportional_min_height = min_depth_proportion * die.getHeight();
942+
943+
const Tiling tiling = tree_->root->getTilings().front();
944+
// Required for designs that are too tight (i.e. MockArray)
945+
const float tiling_min_width
946+
= std::floor((die.getWidth() - tiling.width())) / 2;
947+
const float tiling_min_height
948+
= std::floor((die.getHeight() - tiling.height())) / 2;
949+
950+
pin_access_depth_limits_.x.min
951+
= std::min(proportional_min_width, tiling_min_width);
952+
pin_access_depth_limits_.y.min
953+
= std::min(proportional_min_height, tiling_min_height);
937954

938955
if (logger_->debugCheck(MPL, "coarse_shaping", 1)) {
939956
logger_->report("\n Pin Access Depth (μm) | Min | Max");
@@ -1385,10 +1402,9 @@ void HierRTLMP::placeChildren(Cluster* parent, bool ignore_std_cell_area)
13851402
std::vector<SoftMacro> macros;
13861403
std::vector<BundledNet> nets;
13871404

1388-
std::vector<Rect> placement_blockages;
1389-
std::vector<Rect> macro_blockages;
1390-
1391-
findBlockagesWithinOutline(macro_blockages, placement_blockages, outline);
1405+
std::vector<Rect> blockages = findBlockagesWithinOutline(outline);
1406+
eliminateOverlaps(blockages);
1407+
createSoftMacrosForBlockages(blockages, macros);
13921408

13931409
// We store the io clusters to push them into the macros' vector
13941410
// only after it is already populated with the clusters we're trying to
@@ -1655,8 +1671,6 @@ void HierRTLMP::placeChildren(Cluster* parent, bool ignore_std_cell_area)
16551671
sa->setFences(fences);
16561672
sa->setGuides(guides);
16571673
sa->setNets(nets);
1658-
sa->addBlockages(placement_blockages);
1659-
sa->addBlockages(macro_blockages);
16601674
sa_batch.push_back(std::move(sa));
16611675
}
16621676

@@ -1733,23 +1747,20 @@ void HierRTLMP::placeChildren(Cluster* parent, bool ignore_std_cell_area)
17331747
}
17341748

17351749
// Find the area of blockages that are inside the outline.
1736-
void HierRTLMP::findBlockagesWithinOutline(
1737-
std::vector<Rect>& macro_blockages,
1738-
std::vector<Rect>& placement_blockages,
1750+
std::vector<Rect> HierRTLMP::findBlockagesWithinOutline(
17391751
const Rect& outline) const
17401752
{
1753+
std::vector<Rect> blockages_within_outline;
1754+
17411755
for (auto& blockage : placement_blockages_) {
1742-
getBlockageRegionWithinOutline(placement_blockages, blockage, outline);
1756+
getBlockageRegionWithinOutline(blockages_within_outline, blockage, outline);
17431757
}
17441758

17451759
for (auto& blockage : io_blockages_) {
1746-
getBlockageRegionWithinOutline(macro_blockages, blockage, outline);
1760+
getBlockageRegionWithinOutline(blockages_within_outline, blockage, outline);
17471761
}
17481762

1749-
if (graphics_) {
1750-
graphics_->setMacroBlockages(macro_blockages);
1751-
graphics_->setPlacementBlockages(placement_blockages);
1752-
}
1763+
return blockages_within_outline;
17531764
}
17541765

17551766
void HierRTLMP::getBlockageRegionWithinOutline(
@@ -1770,6 +1781,37 @@ void HierRTLMP::getBlockageRegionWithinOutline(
17701781
}
17711782
}
17721783

1784+
void HierRTLMP::eliminateOverlaps(std::vector<Rect>& blockages) const
1785+
{
1786+
namespace gtl = boost::polygon;
1787+
using gtl::operators::operator+=;
1788+
using PolygonSet = gtl::polygon_90_set_data<int>;
1789+
1790+
PolygonSet polygons;
1791+
for (const Rect& blockage : blockages) {
1792+
const odb::Rect dbu_blockage = micronsToDbu(block_, blockage);
1793+
polygons += dbu_blockage;
1794+
}
1795+
1796+
blockages.clear();
1797+
1798+
std::vector<odb::Rect> new_blockages;
1799+
polygons.get_rectangles(new_blockages);
1800+
1801+
for (const odb::Rect& new_blockage : new_blockages) {
1802+
blockages.push_back(dbuToMicrons(block_, new_blockage));
1803+
}
1804+
}
1805+
1806+
void HierRTLMP::createSoftMacrosForBlockages(const std::vector<Rect>& blockages,
1807+
std::vector<SoftMacro>& macros)
1808+
{
1809+
for (int id = 0; id < blockages.size(); id++) {
1810+
std::string name = fmt::format("blockage_{}", id);
1811+
macros.emplace_back(blockages[id], name);
1812+
}
1813+
}
1814+
17731815
// Create terminals for cluster placement (Soft) annealing.
17741816
void HierRTLMP::createFixedTerminals(
17751817
Cluster* parent,
@@ -1943,10 +1985,14 @@ bool HierRTLMP::runFineShaping(Cluster* parent,
19431985
MPL,
19441986
"fine_shaping",
19451987
1,
1946-
"No valid solution for children of {}"
1947-
"avail_space = {}, min_target_util = {}",
1988+
"No valid solution for children of {} "
1989+
"std_cell_area = {} avail_space = {} pa area = {} "
1990+
"std_cell_mixed_area = {} min_target_util = {}",
19481991
parent->getName(),
1992+
std_cell_cluster_area,
19491993
avail_space,
1994+
pin_access_area,
1995+
std_cell_mixed_cluster_area,
19501996
min_target_util);
19511997

19521998
return false;

src/mpl/src/hier_rtlmp.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,14 @@ class HierRTLMP
177177
void adjustMacroBlockageWeight();
178178
void placeChildren(Cluster* parent, bool ignore_std_cell_area = false);
179179

180-
void findBlockagesWithinOutline(std::vector<Rect>& macro_blockages,
181-
std::vector<Rect>& placement_blockages,
182-
const Rect& outline) const;
180+
std::vector<Rect> findBlockagesWithinOutline(const Rect& outline) const;
183181
void getBlockageRegionWithinOutline(
184182
std::vector<Rect>& blockages_within_outline,
185183
const Rect& blockage,
186184
const Rect& outline) const;
185+
void eliminateOverlaps(std::vector<Rect>& blockages) const;
186+
void createSoftMacrosForBlockages(const std::vector<Rect>& blockages,
187+
std::vector<SoftMacro>& macros);
187188
void createFixedTerminals(Cluster* parent,
188189
std::map<std::string, int>& soft_macro_id_map,
189190
std::vector<SoftMacro>& soft_macros);

src/mpl/src/object.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -935,13 +935,17 @@ SoftMacro::SoftMacro(Cluster* cluster)
935935
}
936936

937937
// Represent a blockage.
938-
SoftMacro::SoftMacro(float width, float height, const std::string& name)
938+
SoftMacro::SoftMacro(const Rect& blockage, const std::string& name)
939939
{
940940
name_ = name;
941-
width_ = width;
942-
height_ = height;
943-
area_ = width * height;
941+
x_ = blockage.xMin();
942+
y_ = blockage.yMin();
943+
width_ = blockage.getWidth();
944+
height_ = blockage.getHeight();
945+
area_ = width_ * height_;
944946
cluster_ = nullptr;
947+
fixed_ = true;
948+
is_blockage_ = true;
945949
}
946950

947951
// Represent an IO cluster or fixed terminal.
@@ -1261,6 +1265,11 @@ void SoftMacro::resizeRandomly(
12611265
height_ = area_ / width_;
12621266
}
12631267

1268+
bool SoftMacro::isBlockage() const
1269+
{
1270+
return is_blockage_;
1271+
}
1272+
12641273
// Align Flag support
12651274
void SoftMacro::setAlignFlag(bool flag)
12661275
{

src/mpl/src/object.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ class SoftMacro
402402
{
403403
public:
404404
SoftMacro(Cluster* cluster);
405-
SoftMacro(float width, float height, const std::string& name);
405+
SoftMacro(const Rect& blockage, const std::string& name);
406406
SoftMacro(const std::pair<float, float>& location,
407407
const std::string& name,
408408
float width,
@@ -452,6 +452,7 @@ class SoftMacro
452452
void setLocationF(float x, float y);
453453
void setShapeF(float width, float height);
454454
int getNumMacro() const;
455+
bool isBlockage() const;
455456
// Align Flag support
456457
void setAlignFlag(bool flag);
457458
bool getAlignFlag() const;
@@ -482,6 +483,7 @@ class SoftMacro
482483
// Interfaces with hard macro
483484
Cluster* cluster_ = nullptr;
484485
bool fixed_ = false; // if the macro is fixed
486+
bool is_blockage_ = false;
485487

486488
// Alignment support
487489
// if the cluster has been aligned related to other macro_cluster or

0 commit comments

Comments
 (0)