Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion src/mpl/src/SimulatedAnnealingCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,8 @@ void SimulatedAnnealingCore<T>::fastSA()
cost_list_.push_back(pre_cost);
T_list_.push_back(temperature);

if ((num_restart <= max_num_restart)
if (best_valid_result_.macro_id_to_width.empty()
&& (num_restart <= max_num_restart)
&& (step == std::floor(max_num_step_ / max_num_restart)
&& (outline_penalty_ > 0.0))) {
shrink();
Expand Down
32 changes: 30 additions & 2 deletions src/mpl/src/hier_rtlmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,21 @@ void HierRTLMP::calculateChildrenTilings(Cluster* parent)
for (auto& cluster : parent->getChildren()) {
if (cluster->getNumMacro() > 0) {
SoftMacro macro = SoftMacro(cluster.get());
macro.setShapes(cluster->getMacroTilings(), true); // force_flag = true
if (macro.isMacroCluster()) {
macro.setShapes(cluster->getMacroTilings(), true /* force */);
} else { /* Mixed */
const std::vector<std::pair<float, float>> tilings
= cluster->getMacroTilings();

// We can use any shape to compute the area.
const std::pair<float, float> shape = tilings.front();
const float area = shape.first * shape.second;
std::vector<std::pair<float, float>> width_curves
= computeWidthCurves(tilings);

macro.setShapes(width_curves, area);
}

macros.push_back(macro);
}
}
Expand Down Expand Up @@ -609,6 +623,20 @@ void HierRTLMP::calculateChildrenTilings(Cluster* parent)
}
}

std::vector<std::pair<float, float>> HierRTLMP::computeWidthCurves(
const std::vector<std::pair<float, float>>& tilings)
{
std::vector<std::pair<float, float>> width_curves;
width_curves.reserve(tilings.size());
for (const std::pair<float, float>& tiling : tilings) {
width_curves.emplace_back(tiling.first, tiling.first);
}

std::sort(width_curves.begin(), width_curves.end(), isFirstSmaller);

return width_curves;
}

void HierRTLMP::calculateMacroTilings(Cluster* cluster)
{
if (cluster->getClusterType() != HardMacroCluster) {
Expand Down Expand Up @@ -2086,7 +2114,7 @@ bool HierRTLMP::runFineShaping(Cluster* parent,
width = std::sqrt(area / min_ar_);
}
std::vector<std::pair<float, float>> width_list;
width_list.emplace_back(width, area / width);
width_list.emplace_back(area / width /* min */, width /* max */);
macros[soft_macro_id_map[cluster->getName()]].setShapes(width_list, area);
} else if (cluster->getClusterType() == HardMacroCluster) {
macros[soft_macro_id_map[cluster->getName()]].setShapes(
Expand Down
2 changes: 2 additions & 0 deletions src/mpl/src/hier_rtlmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class HierRTLMP
void setRootShapes();
void calculateChildrenTilings(Cluster* parent);
void calculateMacroTilings(Cluster* cluster);
std::vector<std::pair<float, float>> computeWidthCurves(
const std::vector<std::pair<float, float>>& tilings);
void setTightPackingTilings(Cluster* macro_array);
void setPinAccessBlockages();
std::vector<Cluster*> getClustersOfUnplacedIOPins();
Expand Down
20 changes: 12 additions & 8 deletions src/mpl/src/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <utility>
#include <vector>

#include "util.h"
#include "utl/Logger.h"

namespace mpl {
Expand Down Expand Up @@ -47,13 +48,6 @@ Boundary opposite(const Boundary& pin_access)
}
}

// Compare two intervals according to starting points
static bool comparePairFirst(const std::pair<float, float>& p1,
const std::pair<float, float>& p2)
{
return p1.first < p2.first;
}

///////////////////////////////////////////////////////////////////////
// Metrics Class
Metrics::Metrics(unsigned int num_std_cell,
Expand Down Expand Up @@ -1094,6 +1088,16 @@ void SoftMacro::shrinkArea(float percent)
return;
}

for (std::pair<float, float>& width_curve : width_list_) {
width_curve.first *= percent;
width_curve.second *= percent;
}

for (std::pair<float, float>& height_curve : height_list_) {
height_curve.first *= percent;
height_curve.second *= percent;
}

width_ = width_ * percent;
height_ = height_ * percent;
area_ = width_ * height_;
Expand Down Expand Up @@ -1170,7 +1174,7 @@ void SoftMacro::setShapes(
height_list_.clear();
// sort width list based
height_list_ = width_list;
std::sort(height_list_.begin(), height_list_.end(), comparePairFirst);
std::sort(height_list_.begin(), height_list_.end(), isFirstSmaller);
for (auto& shape : height_list_) {
if (width_list_.empty()
|| shape.first > width_list_[width_list_.size() - 1].second) {
Expand Down
6 changes: 6 additions & 0 deletions src/mpl/src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@ struct PenaltyData
float normalization_factor{0.0f};
};

inline bool isFirstSmaller(const std::pair<float, float>& p1,
const std::pair<float, float>& p2)
{
return p1.first < p2.first;
}

} // namespace mpl
Loading