@@ -1267,28 +1267,29 @@ void HTreeBuilder::run()
12671267
12681268 computeLevelTopology (level, regionWidth, regionHeight);
12691269
1270- if (options_->getMaxWl ()) {
1271- double maxHPWL = topologyForEachLevel_.back ().getLargestSinkRegionHPWL (
1272- wireSegmentUnit_);
1273- if (maxHPWL < options_->getMaxWl ()
1274- && isNumberOfSinksTooSmall (numSinksPerSubRegion)) {
1270+ if (isNumberOfSinksTooSmall (numSinksPerSubRegion)) {
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 ({}) and max number of "
1279+ " sinks is {}." ,
1280+ options_->getMaxWl () / options_->getWireSegmentUnit (),
1281+ options_->getMaxFanout () ? options_->getMaxFanout ()
1282+ : numMaxLeafSinks_);
1283+ break ;
1284+ }
1285+ } else {
12751286 logger_->info (CTS ,
1276- 38 ,
1277- " Stop criterion found. Sink region hpwl "
1278- " is smaller than max wirelength ({}) and max number of "
1279- " sinks is {}." ,
1280- options_->getMaxWl () / options_->getWireSegmentUnit (),
1287+ 32 ,
1288+ " Stop criterion found. Max number of sinks is {}." ,
12811289 options_->getMaxFanout () ? options_->getMaxFanout ()
1282- : numMaxLeafSinks_);
1290+ : numMaxLeafSinks_);
12831291 break ;
12841292 }
1285- } else if (isNumberOfSinksTooSmall (numSinksPerSubRegion)) {
1286- logger_->info (CTS ,
1287- 32 ,
1288- " Stop criterion found. Max number of sinks is {}." ,
1289- options_->getMaxFanout () ? options_->getMaxFanout ()
1290- : numMaxLeafSinks_);
1291- break ;
12921293 }
12931294 }
12941295
@@ -1840,6 +1841,33 @@ void HTreeBuilder::initSecondLevelSinks(
18401841 }
18411842}
18421843
1844+ double HTreeBuilder::LevelTopology::getLargestSinkRegionHPWL (
1845+ const unsigned wireSegmentUnit) const
1846+ {
1847+ double bestHpwl = 0.0 ;
1848+ for (unsigned i = 0 ; i < branchSinkLocs_.size (); ++i) {
1849+ const auto & sinks = branchSinkLocs_[i];
1850+ if (sinks.size () < 2 ) {
1851+ continue ;
1852+ }
1853+ double minX = sinks[0 ].getX ();
1854+ double maxX = minX;
1855+ double minY = sinks[0 ].getY ();
1856+ double maxY = minY;
1857+ for (unsigned j = 1 ; j < sinks.size (); ++j) {
1858+ minX = std::min (minX, sinks[j].getX ());
1859+ maxX = std::max (maxX, sinks[j].getX ());
1860+ minY = std::min (minY, sinks[j].getY ());
1861+ maxY = std::max (maxY, sinks[j].getY ());
1862+ }
1863+ const double hpwl = ((maxX - minX) + (maxY - minY));
1864+ if (hpwl > bestHpwl) {
1865+ bestHpwl = hpwl;
1866+ }
1867+ }
1868+ return bestHpwl * wireSegmentUnit;
1869+ }
1870+
18431871void HTreeBuilder::computeBranchSinks (
18441872 const LevelTopology& topology,
18451873 const unsigned branchIdx,
0 commit comments