Skip to content

Commit 495194f

Browse files
authored
Merge pull request #10842 from The-OpenROAD-Project-staging/cts_improve_level_creating_threshold
Cts: improve level creating threshold
2 parents 90a8f98 + 45b07af commit 495194f

27 files changed

Lines changed: 2678 additions & 1191 deletions

src/cts/src/HTreeBuilder.cpp

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,12 +1268,29 @@ void HTreeBuilder::run()
12681268
computeLevelTopology(level, regionWidth, regionHeight);
12691269

12701270
if (isNumberOfSinksTooSmall(numSinksPerSubRegion)) {
1271-
logger_->info(CTS,
1272-
32,
1273-
" Stop criterion found. Max number of sinks is {}.",
1274-
options_->getMaxFanout() ? options_->getMaxFanout()
1275-
: numMaxLeafSinks_);
1276-
break;
1271+
if (options_->getMaxWl()) {
1272+
double maxHPWL = topologyForEachLevel_.back().getLargestSinkRegionHPWL(
1273+
wireSegmentUnit_);
1274+
if (maxHPWL < options_->getMaxWl()) {
1275+
logger_->info(CTS,
1276+
38,
1277+
" Stop criterion found. Sink region hpwl "
1278+
"is smaller than max wirelength ({:.3f} um) and max "
1279+
"number of sinks is {}.",
1280+
static_cast<double>(options_->getMaxWl())
1281+
/ options_->getDbUnits(),
1282+
options_->getMaxFanout() ? options_->getMaxFanout()
1283+
: numMaxLeafSinks_);
1284+
break;
1285+
}
1286+
} else {
1287+
logger_->info(CTS,
1288+
32,
1289+
" Stop criterion found. Max number of sinks is {}.",
1290+
options_->getMaxFanout() ? options_->getMaxFanout()
1291+
: numMaxLeafSinks_);
1292+
break;
1293+
}
12771294
}
12781295
}
12791296

@@ -1825,6 +1842,33 @@ void HTreeBuilder::initSecondLevelSinks(
18251842
}
18261843
}
18271844

1845+
double HTreeBuilder::LevelTopology::getLargestSinkRegionHPWL(
1846+
const unsigned wireSegmentUnit) const
1847+
{
1848+
double bestHpwl = 0.0;
1849+
for (unsigned i = 0; i < branchSinkLocs_.size(); ++i) {
1850+
const auto& sinks = branchSinkLocs_[i];
1851+
if (sinks.size() < 2) {
1852+
continue;
1853+
}
1854+
double minX = sinks[0].getX();
1855+
double maxX = minX;
1856+
double minY = sinks[0].getY();
1857+
double maxY = minY;
1858+
for (unsigned j = 1; j < sinks.size(); ++j) {
1859+
minX = std::min(minX, sinks[j].getX());
1860+
maxX = std::max(maxX, sinks[j].getX());
1861+
minY = std::min(minY, sinks[j].getY());
1862+
maxY = std::max(maxY, sinks[j].getY());
1863+
}
1864+
const double hpwl = ((maxX - minX) + (maxY - minY));
1865+
if (hpwl > bestHpwl) {
1866+
bestHpwl = hpwl;
1867+
}
1868+
}
1869+
return bestHpwl * wireSegmentUnit;
1870+
}
1871+
18281872
void HTreeBuilder::computeBranchSinks(
18291873
const LevelTopology& topology,
18301874
const unsigned branchIdx,

src/cts/src/HTreeBuilder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ class HTreeBuilder : public TreeBuilder
128128
return branchSinkLocs_[branchIdx];
129129
}
130130

131+
double getLargestSinkRegionHPWL(unsigned wireSegmentUnit) const;
132+
131133
void setOutputSlew(unsigned slew) { outputSlew_ = slew; }
132134
unsigned getOutputSlew() const { return outputSlew_; }
133135
void setOutputCap(unsigned cap) { outputCap_ = cap; }

src/cts/src/TritonCTS.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ void TritonCTS::runTritonCts()
122122
sinkBuffers_.clear();
123123
regTreeRootBufIndex_ = 0;
124124
delayBufIndex_ = 0;
125+
options_->setMaxWl(0);
125126
options_->removeOwner();
126127
logger_->info(CTS, 500, "Runtime: {:.2f}s", timer.elapsed());
127128
}
@@ -244,7 +245,9 @@ void TritonCTS::setupCharacterization()
244245

245246
double maxWlMicrons
246247
= resizer_->findMaxWireLength(/* don't issue error */ false) * 1e+6;
247-
options_->setMaxWl(block_->micronsToDbu(maxWlMicrons));
248+
if (maxWlMicrons > 0) {
249+
options_->setMaxWl(block_->micronsToDbu(maxWlMicrons));
250+
}
248251

249252
// A new characteriztion is always created.
250253
techChar_ = std::make_unique<TechChar>(

0 commit comments

Comments
 (0)