Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b50a9e0
mpl: model blockages as macro clusters constrained by fences
AcKoucher Jun 4, 2025
49961c0
mpl: blockages as fixed soft macros
joaomai Sep 16, 2025
9ddbaaa
mpl: revert fence weight
joaomai Sep 16, 2025
b215fe7
mpl: generate only valid tilings for interconnected arrays
joaomai Sep 18, 2025
afe7aa4
mpl: compute min depth based on smallest valid tiling
joaomai Sep 18, 2025
719e326
clang-format
joaomai Sep 25, 2025
507c379
clang-format
joaomai Sep 25, 2025
d082005
mpl: use is_blockage_ flag
joaomai Sep 26, 2025
40c1818
mpl: remove auto and use isBlockage
joaomai Sep 26, 2025
84caee9
mpl: remove blockages from soft macro map
joaomai Sep 27, 2025
89e81a2
Merge branch 'master' into mpl-new-blockages
joaomai Sep 27, 2025
d0f97f6
clang-format
joaomai Sep 27, 2025
13b56b3
Merge branch 'master' into mpl-new-blockages
joaomai Sep 29, 2025
da1006e
mpl: update tests
joaomai Sep 29, 2025
116aca0
Merge branch 'master' into mpl-new-blockages
joaomai Sep 30, 2025
22cf64b
mpl: add boost/polygon to bazel deps
joaomai Oct 1, 2025
dd38f2b
buildifier
joaomai Oct 1, 2025
051f2cd
Merge branch 'master' into mpl-new-blockages
joaomai Oct 2, 2025
b173d4c
mpl: remove outdated comment
joaomai Oct 2, 2025
cd0dc9e
mpl: floor and comment in PA depth limit
joaomai Oct 2, 2025
6650dda
Merge branch 'master' into mpl-new-blockages
joaomai Oct 2, 2025
82b488b
mpl: remove comment
joaomai Oct 2, 2025
d754e9e
Merge branch 'master' into mpl-new-blockages
joaomai Oct 7, 2025
58bd700
clang-format
joaomai Oct 8, 2025
2cb77c5
Merge branch 'master' into mpl-new-blockages
joaomai Oct 9, 2025
bb6c011
Merge branch 'master' into mpl-new-blockages
joaomai Oct 10, 2025
af4219e
Merge branch 'master' into mpl-new-blockages
joaomai Oct 12, 2025
2b24960
Merge branch 'master' into mpl-new-blockages
joaomai Oct 13, 2025
b953cc8
Merge branch 'master' into mpl-new-blockages
joaomai Oct 14, 2025
94d3e38
Merge branch 'master' into mpl-new-blockages
joaomai Oct 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/mpl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ cc_library(
"//src/par",
"//src/sta:opensta_lib",
"//src/utl",
"@boost.polygon",
"@boost.random",
],
)
Expand Down
10 changes: 7 additions & 3 deletions src/mpl/src/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ void Graphics::drawObjects(gui::Painter& painter)

int i = 0;
for (const auto& macro : soft_macros_) {
if (isSkippable(macro)) {
if (!macro.isBlockage() && isSkippable(macro)) {
continue;
}

Expand Down Expand Up @@ -554,8 +554,7 @@ template <typename T>
bool Graphics::isSkippable(const T& macro)
{
Cluster* cluster = macro.getCluster();

return !cluster /*fixed terminal*/ || cluster->isClusterOfUnplacedIOPins();
return !cluster || cluster->isClusterOfUnplacedIOPins();
}

// Draw guidance regions for macros.
Expand Down Expand Up @@ -662,6 +661,11 @@ void Graphics::addOutlineOffsetToLine(odb::Point& from, odb::Point& to)
void Graphics::setSoftMacroBrush(gui::Painter& painter,
const SoftMacro& soft_macro)
{
if (soft_macro.isBlockage()) {
painter.setBrush(gui::Painter::kDarkGreen);
return;
}

if (soft_macro.getCluster()->getClusterType() == StdCellCluster) {
painter.setBrush(gui::Painter::kDarkBlue);
} else if (soft_macro.getCluster()->getClusterType() == HardMacroCluster) {
Expand Down
100 changes: 71 additions & 29 deletions src/mpl/src/hier_rtlmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "hier_rtlmp.h"

#include <algorithm>
#include <boost/polygon/polygon.hpp>
#include <cmath>
#include <fstream>
#include <iostream>
Expand All @@ -29,7 +30,7 @@
#include "mpl-util.h"
#include "object.h"
#include "odb/db.h"
#include "odb/geom.h"
#include "odb/geom_boost.h"
#include "odb/util.h"
#include "par/PartitionMgr.h"
#include "utl/Logger.h"
Expand Down Expand Up @@ -847,22 +848,26 @@ void HierRTLMP::setTightPackingTilings(Cluster* macro_array)
{
TilingList tight_packing_tilings;

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

while (divider <= macro_array->getNumMacro()) {
if (macro_array->getNumMacro() % divider == 0) {
columns = macro_array->getNumMacro() / divider;
rows = divider;
const Rect outline = tree_->root->getBBox();

int columns = 0;
for (int rows = 1; rows < std::sqrt(num_macro) + 1; rows++) {
if (num_macro % rows == 0) {
columns = num_macro / rows;

// We don't consider tilings for right angle rotation orientations,
// because they're not allowed in our macro placer.
tight_packing_tilings.emplace_back(
columns * macro_array->getHardMacros().front()->getWidth(),
rows * macro_array->getHardMacros().front()->getHeight());
// Tiling needs to fit inside outline
if (columns * macro_width <= outline.getWidth()
&& rows * macro_height <= outline.getHeight()) {
tight_packing_tilings.emplace_back(columns * macro_width,
rows * macro_height);
}
}

++divider;
}

macro_array->setTilings(tight_packing_tilings);
Expand Down Expand Up @@ -929,8 +934,17 @@ void HierRTLMP::computePinAccessDepthLimits()
pin_access_depth_limits_.y.max = max_depth_proportion * die.getHeight();

constexpr float min_depth_proportion = 0.04;
pin_access_depth_limits_.x.min = min_depth_proportion * die.getWidth();
pin_access_depth_limits_.y.min = min_depth_proportion * die.getHeight();
const float proportional_min_width = min_depth_proportion * die.getWidth();
const float proportional_min_height = min_depth_proportion * die.getHeight();

const Tiling tiling = tree_->root->getTilings().front();
const float tiling_min_width = (die.getWidth() - tiling.width()) / 2;
const float tiling_min_height = (die.getHeight() - tiling.height()) / 2;

pin_access_depth_limits_.x.min
= std::min(proportional_min_width, tiling_min_width);
pin_access_depth_limits_.y.min
= std::min(proportional_min_height, tiling_min_height);

if (logger_->debugCheck(MPL, "coarse_shaping", 1)) {
logger_->report("\n Pin Access Depth (μm) | Min | Max");
Expand Down Expand Up @@ -1382,10 +1396,9 @@ void HierRTLMP::placeChildren(Cluster* parent, bool ignore_std_cell_area)
std::vector<SoftMacro> macros;
std::vector<BundledNet> nets;

std::vector<Rect> placement_blockages;
std::vector<Rect> macro_blockages;

findBlockagesWithinOutline(macro_blockages, placement_blockages, outline);
std::vector<Rect> blockages = findBlockagesWithinOutline(outline);
eliminateOverlaps(blockages);
createSoftMacrosForBlockages(blockages, macros);

// We store the io clusters to push them into the macros' vector
// only after it is already populated with the clusters we're trying to
Expand Down Expand Up @@ -1656,8 +1669,6 @@ void HierRTLMP::placeChildren(Cluster* parent, bool ignore_std_cell_area)
sa->setFences(fences);
sa->setGuides(guides);
sa->setNets(nets);
sa->addBlockages(placement_blockages);
sa->addBlockages(macro_blockages);
sa_batch.push_back(std::move(sa));
}

Expand Down Expand Up @@ -1734,23 +1745,20 @@ void HierRTLMP::placeChildren(Cluster* parent, bool ignore_std_cell_area)
}

// Find the area of blockages that are inside the outline.
void HierRTLMP::findBlockagesWithinOutline(
std::vector<Rect>& macro_blockages,
std::vector<Rect>& placement_blockages,
std::vector<Rect> HierRTLMP::findBlockagesWithinOutline(
const Rect& outline) const
{
std::vector<Rect> blockages_within_outline;

for (auto& blockage : placement_blockages_) {
getBlockageRegionWithinOutline(placement_blockages, blockage, outline);
getBlockageRegionWithinOutline(blockages_within_outline, blockage, outline);
}

for (auto& blockage : io_blockages_) {
getBlockageRegionWithinOutline(macro_blockages, blockage, outline);
getBlockageRegionWithinOutline(blockages_within_outline, blockage, outline);
}

if (graphics_) {
graphics_->setMacroBlockages(macro_blockages);
graphics_->setPlacementBlockages(placement_blockages);
}
return blockages_within_outline;
}

void HierRTLMP::getBlockageRegionWithinOutline(
Expand All @@ -1771,6 +1779,40 @@ void HierRTLMP::getBlockageRegionWithinOutline(
}
}

void HierRTLMP::eliminateOverlaps(std::vector<Rect>& blockages) const
{
namespace gtl = boost::polygon;
using gtl::operators::operator+=;
using PolygonSet = gtl::polygon_90_set_data<int>;

PolygonSet polygons;
for (const Rect& blockage : blockages) {
const odb::Rect dbu_blockage = micronsToDbu(block_, blockage);
polygons += dbu_blockage;
}

blockages.clear();

std::vector<odb::Rect> new_blockages;
polygons.get_rectangles(new_blockages);

for (const odb::Rect& new_blockage : new_blockages) {
blockages.push_back(dbuToMicrons(block_, new_blockage));
}
}

// We model blockages as macro clusters (SoftMacros) constrained to fences.
// The rationale of this model comes from the fact that the area occupied
// by blockages should be empty, i.e., with neither macros or std cells.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this comment is a leftover from the previous attempted approach. It is not accurate and should be removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add the rationale to the PR description.

void HierRTLMP::createSoftMacrosForBlockages(const std::vector<Rect>& blockages,
std::vector<SoftMacro>& macros)
{
for (int id = 0; id < blockages.size(); id++) {
std::string name = fmt::format("blockage_{}", id);
macros.emplace_back(blockages[id], name);
}
}

// Create terminals for cluster placement (Soft) annealing.
void HierRTLMP::createFixedTerminals(
Cluster* parent,
Expand Down
7 changes: 4 additions & 3 deletions src/mpl/src/hier_rtlmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,14 @@ class HierRTLMP
void adjustMacroBlockageWeight();
void placeChildren(Cluster* parent, bool ignore_std_cell_area = false);

void findBlockagesWithinOutline(std::vector<Rect>& macro_blockages,
std::vector<Rect>& placement_blockages,
const Rect& outline) const;
std::vector<Rect> findBlockagesWithinOutline(const Rect& outline) const;
void getBlockageRegionWithinOutline(
std::vector<Rect>& blockages_within_outline,
const Rect& blockage,
const Rect& outline) const;
void eliminateOverlaps(std::vector<Rect>& blockages) const;
void createSoftMacrosForBlockages(const std::vector<Rect>& blockages,
std::vector<SoftMacro>& macros);
void createFixedTerminals(Cluster* parent,
std::map<std::string, int>& soft_macro_id_map,
std::vector<SoftMacro>& soft_macros);
Expand Down
17 changes: 13 additions & 4 deletions src/mpl/src/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,13 +935,17 @@ SoftMacro::SoftMacro(Cluster* cluster)
}

// Represent a blockage.
SoftMacro::SoftMacro(float width, float height, const std::string& name)
SoftMacro::SoftMacro(const Rect& blockage, const std::string& name)
{
name_ = name;
width_ = width;
height_ = height;
area_ = width * height;
x_ = blockage.xMin();
y_ = blockage.yMin();
width_ = blockage.getWidth();
height_ = blockage.getHeight();
area_ = width_ * height_;
cluster_ = nullptr;
fixed_ = true;
is_blockage_ = true;
}

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

bool SoftMacro::isBlockage() const
{
return is_blockage_;
}

// Align Flag support
void SoftMacro::setAlignFlag(bool flag)
{
Expand Down
4 changes: 3 additions & 1 deletion src/mpl/src/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ class SoftMacro
{
public:
SoftMacro(Cluster* cluster);
SoftMacro(float width, float height, const std::string& name);
SoftMacro(const Rect& blockage, const std::string& name);
SoftMacro(const std::pair<float, float>& location,
const std::string& name,
float width,
Expand Down Expand Up @@ -452,6 +452,7 @@ class SoftMacro
void setLocationF(float x, float y);
void setShapeF(float width, float height);
int getNumMacro() const;
bool isBlockage() const;
// Align Flag support
void setAlignFlag(bool flag);
bool getAlignFlag() const;
Expand Down Expand Up @@ -482,6 +483,7 @@ class SoftMacro
// Interfaces with hard macro
Cluster* cluster_ = nullptr;
bool fixed_ = false; // if the macro is fixed
bool is_blockage_ = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is useful for debugging. See other comments.


// Alignment support
// if the cluster has been aligned related to other macro_cluster or
Expand Down
108 changes: 54 additions & 54 deletions src/mpl/test/boundary_push2.defok
Original file line number Diff line number Diff line change
Expand Up @@ -183,60 +183,60 @@ TRACKS Y 140 DO 282 STEP 3200 LAYER metal9 ;
TRACKS X 190 DO 282 STEP 3200 LAYER metal10 ;
TRACKS Y 140 DO 282 STEP 3200 LAYER metal10 ;
COMPONENTS 54 ;
- MACRO_1 HM_100x100_1x1 + FIXED ( 600 20770 ) S ;
- MACRO_2 HM_100x100_1x1 + FIXED ( 239440 221810 ) S ;
- MACRO_3 HM_100x100_1x1 + FIXED ( 600 221810 ) S ;
- MACRO_4 HM_100x100_1x1 + FIXED ( 239440 20770 ) S ;
- _001_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _002_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _003_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _004_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _005_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _006_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _007_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _008_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _009_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _010_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _011_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _012_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _013_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _014_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _015_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _016_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _017_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _018_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _019_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _020_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _021_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _022_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _023_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _024_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _025_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _026_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _027_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _028_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _029_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _030_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _031_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _032_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _033_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _034_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _035_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _036_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _037_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _038_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _039_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _040_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _041_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _042_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _043_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _044_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _045_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _046_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _047_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _048_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _049_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- _050_ DFF_X1 + PLACED ( 216791 219800 ) N ;
- MACRO_1 HM_100x100_1x1 + FIXED ( 239440 18530 ) S ;
- MACRO_2 HM_100x100_1x1 + FIXED ( 600 219570 ) S ;
- MACRO_3 HM_100x100_1x1 + FIXED ( 600 18530 ) S ;
- MACRO_4 HM_100x100_1x1 + FIXED ( 239440 219570 ) S ;
- _001_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _002_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _003_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _004_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _005_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _006_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _007_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _008_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _009_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _010_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _011_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _012_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _013_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _014_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _015_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _016_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _017_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _018_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _019_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _020_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _021_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _022_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _023_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _024_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _025_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _026_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _027_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _028_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _029_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _030_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _031_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _032_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _033_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _034_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _035_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _036_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _037_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _038_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _039_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _040_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _041_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _042_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _043_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _044_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _045_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _046_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _047_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _048_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _049_ DFF_X1 + PLACED ( 197971 217497 ) N ;
- _050_ DFF_X1 + PLACED ( 197971 217497 ) N ;
END COMPONENTS
PINS 4 ;
- io_1 + NET io_1 + DIRECTION INPUT + USE SIGNAL ;
Expand Down
Loading