Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
68f0125
mpl: create halos only on sides with pins
joaomai Mar 25, 2026
eae91e0
mpl: get pin direction from layer
joaomai Mar 27, 2026
2497dce
mpl: consider minimum spacing when creating halos
joaomai Apr 6, 2026
8bd03cf
mpl: add flag use_full_halo
joaomai Apr 15, 2026
1fd9384
mpl: use use_full_halo when creating macro halos
joaomai Apr 15, 2026
d706f6b
mpl: remove leftover log
joaomai Apr 22, 2026
a660929
mpl: row and col orientation improve when using pin aware halos
joaomai Apr 22, 2026
970948f
mpl: remove root tiling check for pin access depth calc
joaomai Apr 27, 2026
0d45b2d
mpl: update minimum spacing calculation
joaomai May 20, 2026
f6d857f
mpl: small refactor on orientation improve
joaomai May 20, 2026
291f7ca
mpl: use minimum_spacing as minimum halo size
joaomai May 21, 2026
e385982
mpl: bugfix on cluster orientation improve
joaomai May 25, 2026
ba0fea4
mpl: better names for buildMacroHalo variables
joaomai May 29, 2026
dc85178
mpl: test flag -use_full_halo
joaomai May 29, 2026
01c15ea
mpl: update tests
joaomai May 29, 2026
3389e4c
mpl: update use_full_halo test BUILD file and comments
joaomai May 29, 2026
454eafe
mpl: update README with new -use_full_halo flag
joaomai May 29, 2026
e9f5c44
mpl: update BUILD file path for halos5 test
joaomai May 29, 2026
94b4709
buildifier
joaomai May 29, 2026
43dd2d9
mpl: assign halo based on pin proximity to boundary
joaomai Jun 9, 2026
22359e3
clang-format
joaomai Jun 9, 2026
c20d7e2
mpl: isEquidistantDifferentDirections method
joaomai Jun 16, 2026
c95fa94
Merge branch 'master' into mpl-halo-on-pins
joaomai Jul 1, 2026
4b2c32a
Revert "mpl: remove root tiling check for pin access depth calc"
joaomai Jul 1, 2026
f88d80a
mpl: adjust macro halo for fixed macros
joaomai Jul 6, 2026
74c7ec3
mpl: const and better comment
joaomai Jul 6, 2026
dedb9e5
mpl: refactor orientation improve
joaomai Jul 7, 2026
9f8f74a
Merge branch 'master' into mpl-halo-on-pins
joaomai Jul 7, 2026
cb5dec8
clang-format
joaomai Jul 7, 2026
c20c4cc
mpl: use tiling based pin access depth only when both are smaller
joaomai Jul 9, 2026
f38d6d5
Merge branch 'master' into mpl-halo-on-pins
joaomai Jul 9, 2026
f38d2c2
mpl: update tests
joaomai Jul 12, 2026
4261928
Merge branch 'master' into mpl-halo-on-pins
joaomai Jul 13, 2026
0aaf229
mpl: improve some comments
joaomai Jul 19, 2026
d66c38e
Merge branch 'master' into mpl-halo-on-pins
joaomai Jul 19, 2026
369e59b
Merge branch 'master' into mpl-halo-on-pins
joaomai Jul 21, 2026
fd5b45f
Merge branch 'master' into mpl-halo-on-pins
joaomai Jul 22, 2026
5d53bd9
update ng45/tinyRocket test
joaomai Jul 22, 2026
7cfb210
Merge branch 'master' into mpl-halo-on-pins
joaomai Jul 23, 2026
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
2 changes: 2 additions & 0 deletions src/mpl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ rtl_macro_placer
[-report_directory report_directory]
[-write_macro_placement file_name]
[-keep_clustering_data]
[-use_full_halo]
```

#### Options
Expand All @@ -65,6 +66,7 @@ rtl_macro_placer
| `-report_directory` | Save reports to this directory. |
| `-write_macro_placement` | Generates a file with the design's macro placement in the format of calls for the `place_macro` command. |
| `-keep_clustering_data` | Save the hierarchy generated by MPL's clustering engine in the form of dbGroups inside ODB. |
| `-use_full_halo` | Remove pin awareness from halo assignment. |

#### Simulated Annealing Weight parameters

Expand Down
5 changes: 4 additions & 1 deletion src/mpl/include/mpl/rtl_mp.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ class MacroPlacer
float target_util,
float min_ar,
const char* report_directory,
bool keep_clustering_data);
bool keep_clustering_data,
bool use_full_halo);

void blockMacroChannels();

void placeMacro(odb::dbInst* inst,
const float& x_origin,
const float& y_origin,
Expand Down
155 changes: 143 additions & 12 deletions src/mpl/src/clusterEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ void ClusteringEngine::setTree(PhysicalHierarchy* tree)

void ClusteringEngine::setHalos(
const HardMacro::Halo& base_halo,
const bool use_full_halo,
const odb::PtrMap<odb::dbInst, HardMacro::Halo>& macro_to_halo)
{
base_halo_ = base_halo;
use_full_halo_ = use_full_halo;
macro_to_halo_ = macro_to_halo;
}

Expand Down Expand Up @@ -2063,6 +2065,7 @@ std::string ClusteringEngine::generateMacroAndCoreDimensionsTable(
void ClusteringEngine::createHardMacros()
{
const odb::Rect& core = block_->getCoreArea();
const int minimum_spacing = getMinimumSpacing();

for (odb::dbInst* inst : block_->getInsts()) {
if (inst->isBlock()) {
Expand All @@ -2082,18 +2085,7 @@ void ClusteringEngine::createHardMacros()
tree_->has_fixed_macros = true;
}

HardMacro::Halo halo;
if (macro_to_halo_.contains(inst)) {
halo = macro_to_halo_.at(inst);
} else if (inst->getHalo() != nullptr) {
const HardMacro::Halo inst_halo(inst->getHalo());
halo = inst_halo;
if (!inst->getHalo()->isSoft()) {
halo = inst_halo.floorTo(base_halo_);
}
} else {
halo = base_halo_;
}
HardMacro::Halo halo = buildMacroHalo(inst, minimum_spacing);

auto macro = std::make_unique<HardMacro>(inst, halo);

Expand Down Expand Up @@ -2163,6 +2155,145 @@ int ClusteringEngine::getNumberOfIOs(Cluster* target) const
return number_of_ios;
}

HardMacro::Halo ClusteringEngine::buildMacroHalo(odb::dbInst* inst,
int minimum_spacing) const
{
if (macro_to_halo_.contains(inst)) {
return macro_to_halo_.at(inst);
}

HardMacro::Halo full_halo;
if (inst->getHalo() != nullptr) {
odb::Rect inst_halo = inst->getHalo()->getBox();
if (inst->getHalo()->isSoft()) {
full_halo = HardMacro::Halo(inst->getHalo());
Comment thread
AcKoucher marked this conversation as resolved.
Resolved
} else {
full_halo = {std::max(inst_halo.xMin(), base_halo_.left),
std::max(inst_halo.yMin(), base_halo_.bottom),
std::max(inst_halo.xMax(), base_halo_.right),
std::max(inst_halo.yMax(), base_halo_.top)};
}
} else {
full_halo = base_halo_;
}

if (use_full_halo_) {
return full_halo;
}

HardMacro::Halo halo(minimum_spacing);

odb::dbMaster* master = inst->getMaster();

for (odb::dbMTerm* mterm : master->getMTerms()) {
if (mterm->getSigType() != odb::dbSigType::SIGNAL) {
continue;
}

for (odb::dbMPin* mpin : mterm->getMPins()) {
for (odb::dbBox* box : mpin->getGeometry()) {
odb::Rect pin_rect = box->getBox();

std::vector<std::pair<int, Boundary>> dist_to_boundary{
{pin_rect.xMin(), Boundary::L},
{pin_rect.yMin(), Boundary::B},
{master->getWidth() - pin_rect.xMax(), Boundary::R},
{master->getHeight() - pin_rect.yMax(), Boundary::T}};
Comment thread
joaomai marked this conversation as resolved.
Resolved

std::ranges::sort(dist_to_boundary);

Boundary closest = dist_to_boundary[0].second;

auto& candidate = dist_to_boundary[0];
auto& second_candidate = dist_to_boundary[1];

// When a pin is equally distant from two or more edges (i.e. in the
// corner) the pin's layer direction is used to choose between
// candidates
if (isEquidistantDifferentDirections(candidate, second_candidate)) {
auto direction
= (mpin->getGeometry().begin())->getTechLayer()->getDirection();
if (direction == odb::dbTechLayerDir::VERTICAL) {
closest = isVertical(candidate.second) ? second_candidate.second
: candidate.second;
} else {
closest = isVertical(candidate.second) ? candidate.second
: second_candidate.second;
}
}

switch (closest) {
case Boundary::B:
halo.bottom = full_halo.bottom;
break;
case Boundary::L:
halo.left = full_halo.left;
break;
case Boundary::T:
halo.top = full_halo.top;
break;
case Boundary::R:
halo.right = full_halo.right;
break;
}
Comment thread
joaomai marked this conversation as resolved.
Resolved
}
}
}

// Adjust halo orientation for fixed macros here, since those
// are skipped during orientation improve and thus never properly adjusted
if (inst->getPlacementStatus().isFixed()) {
auto orient = inst->getOrient();
if (orient == odb::dbOrientType::MX || orient == odb::dbOrientType::R180) {
std::swap(halo.bottom, halo.top);
}
if (orient == odb::dbOrientType::MY || orient == odb::dbOrientType::R180) {
std::swap(halo.left, halo.right);
}
}

return halo;
}

int ClusteringEngine::getMinimumSpacing() const
{
int spacing = 0;

for (odb::dbInst* inst : block_->getInsts()) {
if (inst->isBlock()) {
odb::dbMaster* master = inst->getMaster();

for (odb::dbBox* obs : master->getObstructions()) {
if (auto layer = obs->getTechLayer()) {
spacing = std::max(spacing, layer->getSpacing());
}
}

for (odb::dbMTerm* mterm : master->getMTerms()) {
for (odb::dbMPin* mpin : mterm->getMPins()) {
for (odb::dbBox* geom : mpin->getGeometry()) {
if (auto layer = geom->getTechLayer()) {
spacing = std::max(spacing, layer->getSpacing());
}
}
}
}
}
}
return spacing;
}
Comment thread
AcKoucher marked this conversation as resolved.
Resolved

bool ClusteringEngine::isEquidistantDifferentDirections(
std::pair<int, Boundary> candidate,
std::pair<int, Boundary> second_candidate) const
{
return (candidate.first == second_candidate.first)
&& ((isVertical(candidate.second)
&& !isVertical(second_candidate.second))
|| (!isVertical(candidate.second)
&& isVertical(second_candidate.second)));
}

///////////////////////////////////////////////

void ClusteringEngine::reportThresholds() const
Expand Down
8 changes: 8 additions & 0 deletions src/mpl/src/clusterEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class ClusteringEngine

void setTree(PhysicalHierarchy* tree);
void setHalos(const HardMacro::Halo& base_halo,
bool use_full_halo,
const odb::PtrMap<odb::dbInst, HardMacro::Halo>& macro_to_halo);

// Methods to update the tree as the hierarchical
Expand Down Expand Up @@ -227,6 +228,12 @@ class ClusteringEngine

bool isValidNet(odb::dbNet* net);

HardMacro::Halo buildMacroHalo(odb::dbInst* inst, int minimum_spacing) const;
int getMinimumSpacing() const;
bool isEquidistantDifferentDirections(
std::pair<int, Boundary> candidate,
std::pair<int, Boundary> second_candidate) const;

odb::dbBlock* block_;
utl::Logger* logger_;
par::PartitionMgr* triton_part_;
Expand Down Expand Up @@ -255,6 +262,7 @@ class ClusteringEngine
std::unordered_set<odb::dbInst*> ignorable_macros_;

HardMacro::Halo base_halo_;
bool use_full_halo_{false};
odb::PtrMap<odb::dbInst, HardMacro::Halo> macro_to_halo_;
};

Expand Down
Loading
Loading