Skip to content

grt: add incremental deleted-net cleanup for CUGR#10578

Open
sparsh-karna wants to merge 13 commits into
The-OpenROAD-Project:masterfrom
sparsh-karna:grt-cugr-delete-net-handling
Open

grt: add incremental deleted-net cleanup for CUGR#10578
sparsh-karna wants to merge 13 commits into
The-OpenROAD-Project:masterfrom
sparsh-karna:grt-cugr-delete-net-handling

Conversation

@sparsh-karna
Copy link
Copy Markdown
Contributor

Implements CUGR::removeNet so that when a net is destroyed during ECO (buffer removal, gate downsizing), its routing tree demand is synchronously decremented from the GridGraph and all internal CUGR mappings are cleaned up before the next -end_incremental call. Wires the existing inDbNetDestroy ODB callback in GlobalRouter behind the use_cugr_ flag. Adds regression test incremental_deleted_net.tcl.

NOTE: The test suite for this functionality is not added in this pr, and will be added after the changes are finalized and approved for testing.

All 122 GRT regression tests pass locally.

@sparsh-karna sparsh-karna requested a review from a team as a code owner June 2, 2026 03:49
@sparsh-karna sparsh-karna requested a review from jfgava June 2, 2026 03:49
@github-actions github-actions Bot added the size/M label Jun 2, 2026
Copy link
Copy Markdown
Contributor

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

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 implements net removal support in the CUGR global router by adding removeNet methods to the CUGR and Design classes and tracking deleted nets. The review feedback highlights a critical dangling pointer hazard caused by deferring net deletion via pending_deleted_nets_, recommending synchronous removal instead. Additionally, the feedback suggests several performance optimizations, such as replacing std::map with std::unordered_map to reduce lookup overhead and using std::move to avoid expensive copies of pin vectors during net deletion.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/grt/src/GlobalRouter.cpp Outdated
Comment thread src/grt/src/GlobalRouter.cpp Outdated
Comment thread src/grt/include/grt/GlobalRouter.h Outdated
Comment thread src/grt/src/GlobalRouter.cpp Outdated
Comment thread src/grt/src/cugr/src/CUGR.cpp Outdated
Comment thread src/grt/src/cugr/src/CUGR.cpp Outdated
Comment thread src/grt/src/cugr/src/Design.cpp Outdated
@eder-matheus eder-matheus self-requested a review June 2, 2026 13:12
@eder-matheus
Copy link
Copy Markdown
Member

@sparsh-karna Please resolve the conflicts. Merge the latest master into your branch.

@sparsh-karna sparsh-karna requested a review from a team as a code owner June 2, 2026 14:01
@sparsh-karna sparsh-karna force-pushed the grt-cugr-delete-net-handling branch from 070df87 to ad1e1a5 Compare June 2, 2026 14:02
@sparsh-karna
Copy link
Copy Markdown
Contributor Author

@sparsh-karna Please resolve the conflicts. Merge the latest master into your branch.

updated

@sparsh-karna sparsh-karna force-pushed the grt-cugr-delete-net-handling branch from ad1e1a5 to 1d08380 Compare June 2, 2026 14:08
Comment thread src/grt/src/GlobalRouter.cpp Outdated
Comment thread src/grt/src/cugr/src/Design.cpp Outdated
Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
- Remove pending_deleted_nets_ to process net removal synchronously in inDbNetDestroy, avoiding dangling pointer issues during ECO.
- Switch from std::map to std::unordered_map in CUGR for O(1) net lookups.
- Use std::move for pin vectors in Design::removeNet to avoid expensive deep copies.

Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
@sparsh-karna sparsh-karna force-pushed the grt-cugr-delete-net-handling branch from 1d08380 to 5c7983d Compare June 2, 2026 14:47
- Move CUGR net removal logic from GRouteDbCbk into GlobalRouter::removeNet.
- Centralize net deletion handling for both FastRoute and CUGR engines.
- Ensure null safety in GlobalRouter::removeNet.

Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
- Switch to a simpler net removal approach by invalidating nets in vectors instead of rebuilding the entire vector (matching FastRoute behavior).
- Add isValid() checks to CUGR and Design loops to handle invalidated nets.
- Remove const from CUGRNet/CUGRPin index_ to support move/assignment during reallocation.

Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
@github-actions github-actions Bot added size/S and removed size/M labels Jun 2, 2026
@eder-matheus
Copy link
Copy Markdown
Member

@codex review

Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
@github-actions github-actions Bot added size/M and removed size/S labels Jun 2, 2026
Copy link
Copy Markdown

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

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: 7c5aa82a8b

ℹ️ 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/grt/src/cugr/src/CUGR.cpp Outdated
Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
Comment thread src/grt/src/GlobalRouter.cpp Outdated
- Encapsulate FastRoute-specific net removal logic in an else block inside GlobalRouter::removeNet.
- Prevents unnecessary lookups and processing of db_net_map_ when CUGR is active.

Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
Copy link
Copy Markdown
Member

@eder-matheus eder-matheus left a comment

Choose a reason for hiding this comment

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

The remaining changes look good. Please look at my last request.

Comment thread src/grt/src/cugr/src/CUGR.cpp Outdated

GRNet* gr_net = it->second;
if (gr_net->getRoutingTree()) {
grid_graph_->removeTreeUsage(gr_net->getRoutingTree());
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.

The NDR costs pointed by Codex weren't fixed yet. Please update the removeTreeUsage call with the suggested getNdrCosts

Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
- Replace find() != end() and find() == end() with contains() where applicable to satisfy readability-container-contains.
- Replace count() with contains() for boolean membership checks.
- Run clang-format on modified files.

Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
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