Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
f6ff33a
Revert "Merge pull request #9029 from eder-matheus/revert_cts"
luis201420 Feb 25, 2026
d561944
cts: use buffer max cap in macro clustering
luis201420 Dec 22, 2025
85248b4
cts: Fix variable name missed during revert
luis201420 Feb 25, 2026
fc9bbab
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Feb 26, 2026
fe3ea35
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Feb 27, 2026
527288b
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Mar 2, 2026
dc5c1c1
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Mar 3, 2026
711d6d9
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Mar 5, 2026
af95cf1
cts: update unit test
luis201420 Mar 5, 2026
3aa83c6
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Mar 10, 2026
4fe28a6
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Mar 11, 2026
d1f91b6
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Mar 16, 2026
5903385
dbSta: update unit tests
luis201420 Mar 16, 2026
fe89716
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Mar 18, 2026
dd6d360
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Mar 18, 2026
1303f48
update unit tests
luis201420 Mar 18, 2026
949ac02
cts: add suggested modifications to improve readability
luis201420 Mar 18, 2026
86737a8
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Mar 21, 2026
f631b4f
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Mar 23, 2026
8032fa2
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Mar 24, 2026
b156bfe
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Mar 25, 2026
6a4b8d3
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Mar 26, 2026
f6b49d9
cts: save the cluster size and diameter
luis201420 Mar 26, 2026
3cc8c9a
cts: add max size and diameter to log when these are not defined
luis201420 Mar 26, 2026
66192bb
cts: update unit tests
luis201420 Mar 26, 2026
0afbac6
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Mar 26, 2026
4777515
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Mar 27, 2026
66df401
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Mar 30, 2026
12fc345
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Mar 31, 2026
e64c478
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Apr 2, 2026
e8b32b3
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Apr 6, 2026
750e146
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Apr 8, 2026
daa4bfa
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Apr 13, 2026
ccffe27
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Apr 15, 2026
f8d5fc0
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Apr 16, 2026
43647c1
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Apr 20, 2026
d8a3150
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Apr 21, 2026
4788a64
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Apr 21, 2026
c44d51b
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Apr 22, 2026
231cc36
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Apr 23, 2026
41a954a
cts: update unit tests
luis201420 Apr 23, 2026
092643d
update unit tests
luis201420 Apr 23, 2026
097a090
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Apr 24, 2026
a982840
update unit tests
luis201420 Apr 24, 2026
7d697eb
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Apr 27, 2026
e5e9bc0
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Apr 28, 2026
ebd7c1e
update unit test
luis201420 Apr 28, 2026
6fdc816
rsz: update unit test
luis201420 Apr 28, 2026
0b6ac17
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Apr 29, 2026
399989e
Merge remote-tracking branch 'origin' into cts_fix_improve_clustering
luis201420 Apr 30, 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
8 changes: 3 additions & 5 deletions src/cts/src/CtsOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ void CtsOptions::inDbInstCreate(odb::dbInst* inst)

void CtsOptions::limitSinkClusteringSizes(unsigned limit)
{
unsigned new_size = limit;
if (sinkClustersSizeSet_) {
setSinkClusteringSize(std::min(limit, sinkClustersSize_));
return;
new_size = std::min(new_size, sinkClustersSize_);
}
auto lowerBound = std::ranges::lower_bound(sinkClusteringSizes_, limit);
sinkClusteringSizes_.erase(lowerBound, sinkClusteringSizes_.end());
sinkClusteringSizes_.push_back(limit);
setSinkClusteringSize(new_size);
}

void CtsOptions::recordBuffer(odb::dbMaster* master, MasterType type)
Expand Down
24 changes: 2 additions & 22 deletions src/cts/src/CtsOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ class CtsOptions : public odb::dbBlockCallBackObj

void setSinkClustering(bool enable) { sinkClusteringEnable_ = enable; }
bool getSinkClustering() const { return sinkClusteringEnable_; }
void setSinkClusteringUseMaxCap(bool useMaxCap)
{
sinkClusteringUseMaxCap_ = useMaxCap;
}
bool getSinkClusteringUseMaxCap() const { return sinkClusteringUseMaxCap_; }
void setNumMaxLeafSinks(unsigned numSinks) { numMaxLeafSinks_ = numSinks; }
unsigned getNumMaxLeafSinks() const { return numMaxLeafSinks_; }
void setMaxSlew(unsigned slew) { maxSlew_ = slew; }
Expand Down Expand Up @@ -211,38 +206,26 @@ class CtsOptions : public odb::dbBlockCallBackObj
void setMaxDiameter(double distance)
{
maxDiameter_ = distance;
sinkClusteringUseMaxCap_ = false;
maxDiameterSet_ = true;
}
void resetMaxDiameter()
{
maxDiameter_ = 50;
sinkClusteringUseMaxCap_ = true;
maxDiameterSet_ = false;
}
bool isMaxDiameterSet() const { return maxDiameterSet_; }
const std::vector<unsigned>& getSinkClusteringDiameters()
{
return sinkClusteringDiameters_;
}
unsigned getSinkClusteringSize() const { return sinkClustersSize_; }
void setSinkClusteringSize(unsigned size)
{
sinkClustersSize_ = size;
sinkClusteringUseMaxCap_ = false;
sinkClustersSizeSet_ = true;
}
void resetSinkClusteringSize()
{
sinkClustersSize_ = 20;
sinkClusteringUseMaxCap_ = true;
sinkClustersSize_ = 30;
sinkClustersSizeSet_ = false;
}
bool isSinkClusteringSizeSet() const { return sinkClustersSizeSet_; }
const std::vector<unsigned>& getSinkClusteringSizes()
{
return sinkClusteringSizes_;
}
void limitSinkClusteringSizes(unsigned limit);
unsigned getSinkClusteringLevels() const { return sinkClusteringLevels_; }
void setSinkClusteringLevels(unsigned levels)
Expand Down Expand Up @@ -364,7 +347,6 @@ class CtsOptions : public odb::dbBlockCallBackObj
unsigned wireSegmentUnit_ = 0;
bool plotSolution_ = false;
bool sinkClusteringEnable_ = true;
bool sinkClusteringUseMaxCap_ = true;
bool simpleSegmentsEnable_ = false;
bool vertexBuffersEnable_ = false;
std::unique_ptr<CtsObserver> observer_;
Expand Down Expand Up @@ -392,10 +374,8 @@ class CtsOptions : public odb::dbBlockCallBackObj
int sinks_ = 0;
double maxDiameter_ = 50;
bool maxDiameterSet_ = false;
std::vector<unsigned> sinkClusteringDiameters_ = {50, 100, 200};
unsigned sinkClustersSize_ = 20;
unsigned sinkClustersSize_ = 30;
bool sinkClustersSizeSet_ = false;
std::vector<unsigned> sinkClusteringSizes_ = {10, 20, 30};
double macroMaxDiameter_ = 50;
bool macroMaxDiameterSet_ = false;
unsigned macroSinkClustersSize_ = 4;
Expand Down
115 changes: 47 additions & 68 deletions src/cts/src/HTreeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,70 +93,31 @@ void HTreeBuilder::preSinkClustering(

unsigned bestClusterSize = 0;
float bestDiameter = 0.0;
if (clusterSizeSet && maxDiameterSet) {
// clang-format off
debugPrint(logger_, CTS, "clustering", 1, "**** match.run({}, {}, {}) ****",
clusterSize, maxDiameter, wireSegmentUnit_);
// clang-format on
matching.run(clusterSize,
maxDiameter,
wireSegmentUnit_,
bestClusterSize,
bestDiameter);
} else if (!clusterSizeSet && maxDiameterSet) {
// only diameter is set, try clustering sizes of 10, 20 and 30
for (unsigned clusterSize2 : options_->getSinkClusteringSizes()) {
// clang-format off
debugPrint(logger_, CTS, "clustering", 1, "**** match.run({}, {}, {}) ****",
clusterSize2, maxDiameter, wireSegmentUnit_);
// clang-format on
matching.run(clusterSize2,
maxDiameter,
wireSegmentUnit_,
bestClusterSize,
bestDiameter);
}
} else if (clusterSizeSet && !maxDiameterSet) {
// only clustering size is set, try diameters of 50, 100 and 200 um
for (unsigned clusterDiameter2 : options_->getSinkClusteringDiameters()) {
// clang-format off
debugPrint(logger_, CTS, "clustering", 1, "**** match.run({}, {}, {}) ****",
clusterSize, clusterDiameter2, wireSegmentUnit_);
// clang-format on
float maxDiameter2 = clusterDiameter2 * (float) options_->getDbUnits()
/ wireSegmentUnit_;
matching.run(clusterSize,
maxDiameter2,
wireSegmentUnit_,
bestClusterSize,
bestDiameter);
}
} else { // neighther clustering size nor diameter is set
// try diameters of 50, 100 and 200 um
for (unsigned clusterDiameter2 : clusterDiameters()) {
// try clustering sizes of 10, 20 and 30
for (unsigned clusterSize2 : options_->getSinkClusteringSizes()) {
// clang-format off
debugPrint(logger_, CTS, "clustering", 1, "**** match.run({}, {}, {}) ****",
clusterSize2, clusterDiameter2, wireSegmentUnit_);
// clang-format on
float maxDiameter2 = clusterDiameter2 * (float) options_->getDbUnits()
/ wireSegmentUnit_;
matching.run(clusterSize2,
maxDiameter2,
wireSegmentUnit_,
bestClusterSize,
bestDiameter);
}
}
// clang-format off
debugPrint(logger_, CTS, "clustering", 1, "**** match.run({}, {}, {}) ****",
clusterSize, maxDiameter, wireSegmentUnit_);
// clang-format on
matching.run(clusterSize,
maxDiameter,
wireSegmentUnit_,
bestClusterSize,
bestDiameter);
std::string size_log, diameter_log;
size_log = diameter_log = "";
if (!maxDiameterSet) {
diameter_log = "max ";
bestDiameter = matching.getMaxDiameter();
}
if (!clusterSizeSet) {
size_log = "max ";
bestClusterSize = matching.getMaxSize();
}

if (clusterSizeSet || maxDiameterSet) {
logger_->info(
CTS,
204,
"A clustering solution was found from clustering size of {} "
"and clustering diameter of {:0.0f}.",
"A clustering solution was found from " + size_log + "clustering size of {} "
"and " + diameter_log + "clustering diameter of {:0.0f}.",
bestClusterSize,
std::round(bestDiameter / options_->getDbUnits() * wireSegmentUnit_));
logger_->info(CTS,
Expand All @@ -168,8 +129,8 @@ void HTreeBuilder::preSinkClustering(
logger_->info(
CTS,
206,
"Best clustering solution was found from clustering size of {} "
"and clustering diameter of {:0.0f}.",
"Best clustering solution was found from max clustering size of {} "
"and max clustering diameter of {:0.0f}.",
bestClusterSize,
std::round(bestDiameter / options_->getDbUnits() * wireSegmentUnit_));
}
Expand Down Expand Up @@ -1237,18 +1198,19 @@ void HTreeBuilder::run()
unsigned clusterSize = (type_ == TreeType::MacroTree)
? options_->getMacroSinkClusteringSize()
: options_->getSinkClusteringSize();
bool useMaxCap = (type_ == TreeType::MacroTree)
? false
: options_->getSinkClusteringUseMaxCap();
bool use_max_diameter = (type_ == TreeType::MacroTree)
? options_->isMacroMaxDiameterSet()
: options_->isMaxDiameterSet();
bool use_max_size = (type_ == TreeType::MacroTree)
? options_->isMacroSinkClusteringSizeSet()
: options_->isSinkClusteringSizeSet();
bool useMaxCap = !(use_max_size && use_max_diameter);

logger_->info(
CTS, 27, "Generating H-Tree topology for net {}.", clock_.getName());
logger_->info(CTS, 28, " Total number of sinks: {}.", clock_.getNumSinks());
if (options_->getSinkClustering()) {
if (useMaxCap) {
logger_->info(
CTS, 90, " Sinks will be clustered based on buffer max cap.");
} else {
if (!useMaxCap) {
logger_->info(
CTS,
29,
Expand All @@ -1257,6 +1219,23 @@ void HTreeBuilder::run()
type_ == TreeType::MacroTree ? "Macro " : "Register",
clusterSize,
clusterDiameter);
} else if (use_max_diameter && !use_max_size) {
logger_->info(CTS,
59,
" {} sinks will be clustered with maximum cluster diameter "
"of {:.1f} um and based on buffer max cap.",
type_ == TreeType::MacroTree ? "Macro " : "Register",
clusterDiameter);
} else if (!use_max_diameter && use_max_size) {
logger_->info(CTS,
60,
" {} sinks will be clustered in groups of up to {} and "
"based on buffer max cap.",
type_ == TreeType::MacroTree ? "Macro " : "Register",
clusterSize);
} else {
logger_->info(
CTS, 90, " Sinks will be clustered based on buffer max cap.");
}
}
logger_->info(
Expand Down
42 changes: 34 additions & 8 deletions src/cts/src/SinkClustering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ SinkClustering::SinkClustering(const CtsOptions* options,
techChar_(techChar),
maxInternalDiameter_(10),
capPerUnit_(0.0),
useMaxCapLimit_((HTree->getTreeType() == TreeType::MacroTree)
? false
: options->getSinkClusteringUseMaxCap()),
use_max_diameter_((HTree->getTreeType() == TreeType::MacroTree)
? options->isMacroMaxDiameterSet()
: options->isMaxDiameterSet()),
use_max_size_((HTree->getTreeType() == TreeType::MacroTree)
? options->isMacroSinkClusteringSizeSet()
: options->isSinkClusteringSizeSet()),
useMaxCapLimit_(!(use_max_size_ && use_max_diameter_)),
scaleFactor_(1),
HTree_(HTree)
{
Expand Down Expand Up @@ -203,6 +207,10 @@ bool SinkClustering::findBestMatching(const unsigned groupSize)
// Keeps track of the total cost of each solution.
vector<double> costs(groupSize, 0);
vector<double> previousCosts(groupSize, 0);
// Has the max diameter of each solution.
vector<double> max_diameter(groupSize, 0);
// Has the max size of each solution.
vector<unsigned> max_size(groupSize, 0);
// Has the points for each cluster of each solution.
vector<vector<vector<Point<double>>>> solutionPoints;
// Has the points index for each cluster of each solution.
Expand Down Expand Up @@ -269,6 +277,9 @@ bool SinkClustering::findBestMatching(const unsigned groupSize)
solutionPoints[j][clusters[j]].size(),
distanceCost,
capCost);
max_diameter[j] = std::max(max_diameter[j], previousCosts[j]);
max_size[j] = std::max(
max_size[j], (unsigned) solutionPoints[j][clusters[j]].size());
// The cost is computed as the highest cost found on the current
// cluster
if (previousCosts[j] == 0) {
Expand Down Expand Up @@ -339,6 +350,9 @@ bool SinkClustering::findBestMatching(const unsigned groupSize)
solutionPoints[j][clusters[j]].size(),
distanceCost,
capCost);
max_diameter[j] = std::max(max_diameter[j], previousCosts[j]);
max_size[j] = std::max(
max_size[j], (unsigned) solutionPoints[j][clusters[j]].size());
if (previousCosts[j] == 0) {
previousCosts[j] = maxInternalDiameter_;
}
Expand Down Expand Up @@ -385,6 +399,19 @@ bool SinkClustering::findBestMatching(const unsigned groupSize)
// Save the solution for the Tree Builder.
if (bestSolutionFound) {
bestSolution_ = solutions[bestSolution];
// Calculate max diameter to save
double span;
if (xSpan_ == 0 && ySpan_ == 0) {
span = 1; // arbitrary
} else if (xSpan_ == 0) {
span = ySpan_;
} else if (ySpan_ == 0) {
span = xSpan_;
} else {
span = std::min(xSpan_, ySpan_);
}
max_diameter_ = max_diameter[bestSolution] * span;
max_size_ = max_size[bestSolution];
// clang-format off
debugPrint(logger_, CTS, "clustering", 1, "Best solution from group "
"{} has cost of {:0.3f} and size of {}", bestSolution,
Expand Down Expand Up @@ -412,11 +439,10 @@ bool SinkClustering::isLimitExceeded(const unsigned size,
const double capCost,
const unsigned sizeLimit)
{
if (useMaxCapLimit_) {
return (capCost > options_->getSinkBufferInputCap() * kMaxCapFactor);
}

return (size >= sizeLimit || cost > maxInternalDiameter_);
return (useMaxCapLimit_
&& (capCost > options_->getSinkBufferInputCap() * kMaxCapFactor))
|| (use_max_size_ && (size >= sizeLimit))
|| (use_max_diameter_ && (cost > maxInternalDiameter_));
}

void SinkClustering::writePlotFile(unsigned groupSize)
Expand Down
6 changes: 6 additions & 0 deletions src/cts/src/SinkClustering.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class SinkClustering

double getWireLength(const std::vector<Point<double>>& points) const;
int getScaleFactor() const { return scaleFactor_; }
double getMaxDiameter() const { return max_diameter_; }
double getMaxSize() const { return max_size_; }

private:
void normalizePoints(float maxDiameter = 10);
Expand Down Expand Up @@ -85,13 +87,17 @@ class SinkClustering
std::vector<std::vector<unsigned>> bestSolution_;
float maxInternalDiameter_;
float capPerUnit_;
bool use_max_diameter_;
bool use_max_size_;
bool useMaxCapLimit_;
int scaleFactor_;
static constexpr double kMaxCapFactor = 10;
HTreeBuilder* HTree_;
bool firstRun_ = true;
double xSpan_ = 0.0;
double ySpan_ = 0.0;
double max_diameter_ = 0.0;
double max_size_ = 0.0;
double bestSolutionCost_ = std::numeric_limits<double>::max();
};

Expand Down
Loading
Loading