Skip to content

Cts: improve level creating threshold - #10842

Merged
maliberty merged 14 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:cts_improve_level_creating_threshold
Jul 13, 2026
Merged

maliberty merged 14 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:cts_improve_level_creating_threshold

Conversation

@arthurjolo

Copy link
Copy Markdown
Contributor

Summary

This PR improves the H-tree level creation stop criterion in CTS by using the actual sink region geometry, preventing shallow trees.

The existing stop criterion for H-tree level creation relied solely on the number of sinks per subregion (isNumberOfSinksTooSmall). This could cause the tree to stop building levels too early or too late, depending on sink distribution — particularly for designs with max_wirelength set or macro trees.

Type of Change

  • New feature

Impact

  • Combined H-tree level stop criterion: When max_wirelength is set, level creation now stops only when both the largest sink region HPWL is smaller than max_wirelength and the number of sinks per subregion is too small. Previously, the sink-count check alone could stop the tree prematurely when sinks were still geometrically spread out. When max_wirelength is not set, the original sink-count-only criterion is preserved.

  • Guard against invalid maxWl (TritonCTS.cpp:247-249): setMaxWl is now only called when resizer_->findMaxWireLength() returns a positive value, preventing a zero/negative max wirelength from disabling the geometric check

Verification

  • I have verified that the local build succeeds (./etc/Build.sh).
  • I have run the relevant tests and they pass.
  • My code follows the repository's formatting guidelines.
  • I have included tests to prevent regressions.
  • I have signed my commits (DCO).

Related Issues

…gion

Signed-off-by: arthurjolo <arthurjl@precisioninno.com>
…creation threshold

Signed-off-by: arthurjolo <arthurjl@precisioninno.com>
Signed-off-by: arthurjolo <arthurjl@precisioninno.com>
Signed-off-by: arthurjolo <arthurjl@precisioninno.com>
Signed-off-by: arthurjolo <arthurjl@precisioninno.com>
Signed-off-by: arthurjolo <arthurjl@precisioninno.com>
@arthurjolo arthurjolo self-assigned this Jul 8, 2026
@github-actions github-actions Bot added the size/S label Jul 8, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@arthurjolo
arthurjolo marked this pull request as ready for review July 9, 2026 12:45
@arthurjolo
arthurjolo requested a review from a team as a code owner July 9, 2026 12:45
@arthurjolo
arthurjolo requested a review from luis201420 July 9, 2026 12:45
@arthurjolo

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@maliberty

Copy link
Copy Markdown
Member

This needs empirical justification. On what ORFS design does this PR result in an improvement?

@arthurjolo

Copy link
Copy Markdown
Contributor Author

For most designs with clock gaters or macros. mempool_group, ariane136 and cva6 show skew improvements (although not tns improvements for all as cva6 and ariane136 are coling timing). But also private designs show significant tns and skew improvements.

Comment thread src/cts/src/HTreeBuilder.h Outdated
return branchSinkLocs_[branchIdx];
}

double getLargestSinkRegionHPWL(unsigned wireSegmentUnit) const

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Large methods like this should be in the .cpp

Comment thread src/cts/src/HTreeBuilder.h Outdated
minY = std::min(minY, sinks[j].getY());
maxY = std::max(maxY, sinks[j].getY());
}
const double hpwl = ((maxX - minX) + (maxY - minY)) * wireSegmentUnit;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can hoist * wireSegmentUnit to the final return statement.

@maliberty

Copy link
Copy Markdown
Member

Is it pure improvements or will we need any metrics update?

@jhkim-pii

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cc4454542a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cts/src/TritonCTS.cpp
Comment on lines +247 to +249
if (maxWlMicrons > 0) {
options_->setMaxWl(block_->micronsToDbu(maxWlMicrons));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reset stale max wire length

When a previous clock_tree_synthesis run computed a positive maxWl_, this branch leaves that value in options_ if a later run/design has no positive findMaxWireLength result (for example, no clock wire RC; runTritonCts clears builders/state but does not recreate CtsOptions). HTreeBuilder will then still see getMaxWl() as enabled and apply an obsolete geometric/wirelength threshold to the new run instead of the intended no-max-WL behavior, so the non-positive case should explicitly clear/set maxWl_ to 0.

Useful? React with 👍 / 👎.

Comment thread src/cts/src/HTreeBuilder.cpp Outdated
" Stop criterion found. Sink region hpwl "
"is smaller than max wirelength ({}) and max number of "
"sinks is {}.",
options_->getMaxWl() / options_->getWireSegmentUnit(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the log, max wirelength unit is unclear.
How about using um?
Or it is better to specify the max wirelength unit.

@arthurjolo arthurjolo Jul 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max wl is in DBUs. I didn't use um because in CTS um is barely used. I don't have strong opinion on what should the units be, so I am ok with changing to um

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For user facing messages um is better. Internally we should use dbu

: numMaxLeafSinks_);
break;
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor if-statement structure modification. How about this?

  • isNumberOfSinksTooSmall(numSinksPerSubRegion) is called once.
  • Do not call topologyForEachLevel_.back().getLargestSinkRegionHPWL() if number of sinks is large.
if (isNumberOfSinksTooSmall(numSinksPerSubRegion)) {
  if (options_->getMaxWl()) {
     const double maxHPWL = ...
     if (maxHPWL < options_->getMaxWl() ) {
        logger_->into(CTS, 38, ...);
     }
  } else {
    logger_->info(CTS, 32, ...);
  }
}

Signed-off-by: arthurjolo <arthurjl@precisioninno.com>
Signed-off-by: arthurjolo <arthurjl@precisioninno.com>
Signed-off-by: arthurjolo <arthurjl@precisioninno.com>
@arthurjolo

Copy link
Copy Markdown
Contributor Author

I addressed all the reviews and made a PR to update one failing metric (The-OpenROAD-Project/OpenROAD-flow-scripts#4350).

@maliberty
maliberty merged commit 495194f into The-OpenROAD-Project:master Jul 13, 2026
16 checks passed
@maliberty
maliberty deleted the cts_improve_level_creating_threshold branch July 13, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants