Skip to content

grt: make rudy consider linear nets - #12228

Open
gudeh wants to merge 18 commits into
The-OpenROAD-Project:masterfrom
gudeh:grt-rudy-line-net
Open

gudeh wants to merge 18 commits into
The-OpenROAD-Project:masterfrom
gudeh:grt-rudy-line-net

Conversation

@gudeh

@gudeh gudeh commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Currently RUDY does not increase demand for nets which are perfectly aligned. Such as when its pins have all the same x or y (dbNet::getTermBBox returns zero area for such nets).

Now we add demand to the tile based on the RUDY calculated wire width and its overlap with the tile.

Toy example with 4 IO pins and RUDY heatmap:

Before, and after:
image image

Type of Change

  • Refactoring

Impact

Minor. Metrics within chance level.
image
image
image

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).

…dy demand

Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
@gudeh
gudeh requested a review from a team as a code owner November 11, 2026 01:03
@gudeh
gudeh requested a review from jfgava November 11, 2026 01:03
@gudeh
gudeh requested a review from maliberty November 11, 2026 01:03

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request updates the RUDY congestion estimation to correctly handle zero-area nets (where terminals are aligned horizontally or vertically on a line) instead of skipping them. It calculates the demand for these line nets using a length-based ratio rather than an area-based ratio. Additionally, comprehensive unit tests have been added to TestGlobalRouter.cpp to verify the wire area distribution for line and rectangular nets, ensuring that a line net behaves as the limit of an infinitely thin rectangle. There are no review comments, and I have no feedback to provide.

@gudeh
gudeh requested a review from a team as a code owner November 11, 2026 14:39
@github-actions github-actions Bot added size/XL and removed size/M labels Nov 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@gudeh gudeh changed the title grt: rudy and linear nets grt: make rudy consider linear nets Nov 11, 2026
@gudeh
gudeh requested a review from LucasYuki November 12, 2026 14:23
Comment thread src/grt/include/grt/Rudy.h Outdated
@@ -134,9 +135,16 @@ class Rudy
if (!net_rect.overlaps(tile_box)) {

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.

  • src/grt/include/grt/Rudy.h:135 bug: a line net that lies exactly on a tile boundary still gets zero demand. odb::Rect::overlaps() uses strict comparisons. For a horizontal line at y == tile.yMin(), the tile above fails tile.ylo < net.yhi and the tile below fails tile.yhi > net.ylo. Both tiles skip the net, so it is dropped silently, which is the bug this PR is meant to fix. The same happens for a vertical line on a column boundary, and for a line on the grid's top or right edge. Suggestion: for is_line, use intersects() plus a half-open rule so each line goes to exactly one row or column (e.g. tile.ylo <= y < tile.yhi, with the last row taking y == grid.yMax). Using intersects() alone would count the line in both

With the fix, RUDY assigns a line net on a tile boundary to the tile above or to the right. That's the same floor-division rule grt uses to place pins in gcells (Grid::getPositionOnGrid), and intersects lets the net add its demand to that tile.

Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
@gudeh

gudeh commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Code review addressed.

Green pins are aligned and on top of RUDY tile borders. Here is the test without the fix:
image

And with the fix, notice the tiles on top of green pins with slightly higher values.
image

@gudeh
gudeh requested a review from maliberty November 16, 2026 21:05
Comment thread openroad/grt/include/grt/Rudy.h Outdated
/ static_cast<float>(tile_box.area());
const odb::Rect intersect = net_rect.intersect(tile_box);
const auto tile_area = static_cast<float>(tile_box.area());
if (is_line) {

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.

Wouldn't it be easier to set the net_rect's minimum height or width to wire_width_ at the beginning of this method?
Then this if would be unnecessary, the result would be the same, and I think that the code would be cleaner.

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.

Sounds reasonable

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.

Following @LucasYuki's suggestion, a net whose bounding box is narrower than wire_width_ in x or y is now treated as at least wire_width_ wide in that direction, instead of using its actual, near-zero, dimension.

I see this as a bug fix, RUDY should use wire_width_ for adding demand!

gudeh and others added 4 commits November 17, 2026 00:14
Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
@jhkim-pii

Copy link
Copy Markdown
Contributor

AI review summary

  1. [low] Nets that start inside the last tile's top/right remainder strip, and line nets on the top/right die edge, get zero RUDY demand (openroad/grt/include/grt/Rudy.h:126)
    In visitNetTiles(), min_x_index and min_y_index are clamped only from below with std::max(0, ...). Rudy::makeGrid() adds the die-size remainder (x_extra, y_extra) to the last column and row, so a terminal box that starts at or beyond tile_cnt * tile_size gives min_x_index > max_x_index or min_y_index > max_y_index. The loop then runs zero times and deposits no demand. Positive-area nets inside the strip are dropped too. The merge-base already dropped all of these nets, so this is not a regression, but they are still missing after this PR. Clamping the min indices alone does not fix a line exactly on the top/right die edge. The line is grown outward to [xMax, xMax + wire_width_], so its intersection with the last tile has zero area. A line within wire_width_ of the edge is only half counted. On the Nangate45 test fixture (35x35 tiles of 5700 DBU, remainders 760 and 2100 DBU), the PR head deposits 0 for: a vertical line in the right strip, on the right edge, or 50 DBU inside it; a horizontal line on the top edge or in the top strip; and a positive-area net inside the right strip.

    Suggested fix: Pull a line that was grown past the top/right die edge back inside the die, and clamp the min indices to the last tile:

    net_rect.set_xhi(std::max(net_rect.xMax(), net_rect.xMin() + wire_width_));
    net_rect.set_yhi(std::max(net_rect.yMax(), net_rect.yMin() + wire_width_));
    // A line on the top/right die edge grows outside the grid; keep it inside.
    net_rect.moveDelta(std::min(0, grid_block_.xMax() - net_rect.xMax()),
                       std::min(0, grid_block_.yMax() - net_rect.yMax()));
    const auto net_congestion = (hpwl * wire_width_) / net_rect.area();
    
    const int min_x_index = std::clamp(
        (net_rect.xMin() - grid_block_.xMin()) / tile_size_, 0, tile_cnt_x_ - 1);
    const int min_y_index = std::clamp(
        (net_rect.yMin() - grid_block_.yMin()) / tile_size_, 0, tile_cnt_y_ - 1);

- Nets starting past the last full tile got an out-of-range start
  index. Clamp it to the last tile.
- Line nets on the die edge were grown outside the die. Move them
  back inside.

Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
@gudeh

gudeh commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

I included your suggested fix @jhkim-pii, here is the before and after images:

imageimage

Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
@gudeh
gudeh requested a review from a team as a code owner November 19, 2026 14:14
@gudeh
gudeh requested a review from Logikable November 19, 2026 14:14
@gudeh

gudeh commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

@maliberty tests are passing. I just restarted another secure-CI to reassess the QoR impact

@Logikable Logikable left a comment

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.

GPL changes LGTM.

Comment thread test/ibex_sky130hs.metrics_limits Outdated
Comment on lines +19 to +20
,"DRT::max_slew_slack" : "-56.72679662704468"
,"DRT::max_capacitance_slack" : "-65.76353516509255"

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.

Is it OK that we loosened the test limits so much?

@gudeh gudeh Nov 19, 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.

We usually spend more attention observing metrics for ORFS designs with our internal secure-CI. Results there look stable.

Fmax:
image

tns:
image

wns:
image

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.

6 participants