Skip to content

Double monotone chains for PDR - #11351

Closed
gzz2000 wants to merge 8 commits into
The-OpenROAD-Project:masterfrom
gzz2000:master
Closed

gzz2000 wants to merge 8 commits into
The-OpenROAD-Project:masterfrom
gzz2000:master

Conversation

@gzz2000

@gzz2000 gzz2000 commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Hi OpenROAD maintainers,

This PR integrates the double monotone chains algorithm described in "Provably Optimal Planar Pareto Nearest Neighbor Search with Double Monotone Chains" (Guo et al, DATE'26) for Prim-Dijkstra in OpenROAD.

The algorithm is output-optimal, 39x faster than brute force and 1.3x faster than the lossy Guibas-Stolfi algorithm.

Type of Change

  • New feature (new algorithm)

Impact

No behavior is expected to change. The algorithm is a drop-in replacement. Speed-up can be observed in large net Steiner tree generation.

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

N/A

@gzz2000
gzz2000 requested a review from a team as a code owner September 7, 2026 16:00
@gzz2000
gzz2000 requested a review from maliberty September 7, 2026 16:00
@github-actions github-actions Bot added the size/M label Sep 7, 2026

@github-actions github-actions 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.

Welcome to OpenROAD! Thanks for opening your first PR.
Before we review:

Please ensure:

  • CI passes
  • Code is properly formatted
  • Tests are included where applicable
    A maintainer will review shortly!

Signed-off-by: Zizheng Guo <gzz_2000@126.com>

@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 replaces the nearest neighbor search algorithm in pd.cpp with the double monotone chains algorithm to improve performance. The review feedback focuses on ensuring deterministic sorting by using std::tie with secondary coordinate keys, improving vector initialization readability by avoiding double resizing, and replacing the non-standard bitwise NOT operator (~j) with standard index checks (j >= 0).

Comment thread src/stt/src/pdr/src/pd.cpp
Comment thread src/stt/src/pdr/src/pd.cpp Outdated
Comment thread src/stt/src/pdr/src/pd.cpp Outdated
Comment thread src/stt/src/pdr/src/pd.cpp Outdated
Comment thread src/stt/src/pdr/src/pd.cpp Outdated
Comment thread src/stt/src/pdr/src/pd.cpp Outdated
gzz2000 and others added 6 commits September 8, 2026 00:06
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Zizheng Guo <19143357+gzz2000@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Zizheng Guo <19143357+gzz2000@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Zizheng Guo <19143357+gzz2000@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Zizheng Guo <19143357+gzz2000@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Zizheng Guo <19143357+gzz2000@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Zizheng Guo <19143357+gzz2000@users.noreply.github.com>
@maliberty

Copy link
Copy Markdown
Member

Fails to compile

[2026-09-07T16:38:56.048Z] src/stt/src/pdr/src/pd.cpp:67:12: error: no matching function for call to 'tie'
[2026-09-07T16:38:56.048Z]    67 |     return std::tie(pts[i].getX(), pts[i].getY()) < std::tie(pts[j].getX(), pts[j].getY());

Is the 39X improvement measured against the current code?

Signed-off-by: Zizheng Guo <gzz_2000@126.com>
@gzz2000

gzz2000 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

@maliberty The error was introduced by Gemini code review. It should be fixed now. Sorry about that!

39X is measured against the current get_nearest_neighbors implementation on 10K degree nets.

@maliberty

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-08T04:56:33.134858Z 9342d14 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@maliberty

Copy link
Copy Markdown
Member

There are various test failures you can see in pr-head or pr-merge. Apparently this isn't just a speed up. Perhaps it affects the structure of the returned result?

@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: 9342d14df5

ℹ️ 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 on lines +79 to +80
while (j >= 0 && pts[j].getX() > xi) {
j = yprev_w_smallx[j];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Batch equal-x terminals before walking the chains

When many terminals share an x coordinate, this comparison retains every equal-x predecessor, and the sweep processes those terminals individually. The subsequent chain walks consequently connect every pair on that vertical line—for four aligned terminals this emits six edges instead of the three Pareto-neighbor edges—making both neighbor storage and buildSpanningTree work Θ(k²). Large aligned high-fanout nets can therefore consume excessive memory or stall, defeating the output-optimal replacement; equal-x terminals need explicit degeneracy handling rather than entering the sweep one by one.

Useful? React with 👍 / 👎.

@gzz2000

gzz2000 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

I will look into them.

@maliberty

Copy link
Copy Markdown
Member

Any update?

@gzz2000

gzz2000 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Hi @maliberty, sorry for the long delay (I was busy for a conference deadline). I will look into the bugs as well as your new PR.

@maliberty

Copy link
Copy Markdown
Member

Replaced by #11602

@maliberty maliberty closed this Oct 1, 2026
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.

2 participants