Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
108 changes: 77 additions & 31 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 @@ -850,22 +851,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 @@ -932,8 +937,20 @@ 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();
// Required for designs that are too tight (i.e. MockArray)
const float tiling_min_width
= std::floor((die.getWidth() - tiling.width())) / 2;
const float tiling_min_height
= std::floor((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 @@ -1385,10 +1402,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 @@ -1655,8 +1671,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 @@ -1733,23 +1747,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 @@ -1770,6 +1781,37 @@ 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));
}
}

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 Expand Up @@ -1943,10 +1985,14 @@ bool HierRTLMP::runFineShaping(Cluster* parent,
MPL,
"fine_shaping",
1,
"No valid solution for children of {}"
"avail_space = {}, min_target_util = {}",
"No valid solution for children of {} "
"std_cell_area = {} avail_space = {} pa area = {} "
"std_cell_mixed_area = {} min_target_util = {}",
parent->getName(),
std_cell_cluster_area,
avail_space,
pin_access_area,
std_cell_mixed_cluster_area,
min_target_util);

return false;
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 @@ -177,13 +177,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
Loading