Skip to content

grt/cugr: implement support for guides restoration#10944

Open
eder-matheus wants to merge 9 commits into
The-OpenROAD-Project:masterfrom
eder-matheus:pr3-cugr_restore_guides
Open

grt/cugr: implement support for guides restoration#10944
eder-matheus wants to merge 9 commits into
The-OpenROAD-Project:masterfrom
eder-matheus:pr3-cugr_restore_guides

Conversation

@eder-matheus

Copy link
Copy Markdown
Member

Summary

Completes CUGR's incremental global-routing path to move it closer to FastRoute parity and fixes a pin-access mapping bug that broke guide restoration on congested designs.

Four commits:

  • grt/cugr: restore routing from guides on journal restore for FastRoute parity — on an ECO journal restore, rebuild a net's prior routing from its odb guides (with pin-coverage verification) instead of forcing a full reroute, matching
    the FastRoute incremental path.
  • grt/cugr: honor NDR costs on incremental reroute and restore — apply non-default-rule costs when rerouting/restoring dirty nets, not just on the full route.
  • grt/cugr: add demand-consistency verify (set_debug_level GRT verify_demand) — optional oracle that round-trips the full grid to confirm incremental demand bookkeeping stays consistent with a from-scratch computation.
  • grt/cugr: map DRT access points to gcells via gridline search — the core bug fix (see Impact).

Type of Change

  • Bug fix
  • New feature

Impact

The primary fix corrects how CUGR maps DRT access points to gcells. It previously used a fixed-pitch integer division (x / (die_width / grid_size)) that drifts off the real gridlines as coordinates grow, placing the router's pin terminals
one gcell off for pins past the drift crossover; it also dropped the access-point layer interval when a pin shared a gcell with APs on another layer. Because selectAccessPoints short-circuits to these odb APs whenever DRT pin access ran first (always, in a normal flow), the router's terminals disagreed with every consumer that needs true DRT-AP coverage — guide restoration and the resizer's BufferedNet construction — while staying invisible to the normal flow (DRT redoes
local pin access). The fix maps APs with the same rangeSearchCells gridline search used everywhere else and merges the layer interval for co-located APs.

Behavior changes (all CUGR-only; CUGR is opt-in via -use_cugr / GLOBAL_ROUTE_USE_CUGR, so the default FastRoute flow is unaffected):

  • sky130hd/aes: incremental guide restore ~5% → 100% (GRT-0304 warnings 1001+ → 0).
  • asap7/riscv32i: repair_design no longer crashes with RSZ-0074 (0 → clean).
  • sky130hd/jpeg: unchanged (already 100%; its die divides evenly and never hit the drift).
  • Routing targets are now correct, so CUGR wirelength/via/congestion shift slightly (goldens updated accordingly).
  • New opt-in debug: set_debug_level GRT verify_demand 1.

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 signed my commits (DCO).

…e parity

Signed-off-by: Eder Monteiro <emrmonteiro@precisioninno.com>
Signed-off-by: Eder Monteiro <emrmonteiro@precisioninno.com>
…emand)

Signed-off-by: Eder Monteiro <emrmonteiro@precisioninno.com>
Signed-off-by: Eder Monteiro <emrmonteiro@precisioninno.com>
@eder-matheus

Copy link
Copy Markdown
Member Author

@codex review

@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 introduces incremental routing and journal-restored routing capabilities for CUGR, aligning its behavior with FastRoute. Key changes include rebuilding routing trees from ODB guides, updating access point mapping to prevent boundary pin drift, and adding a demand consistency verification mechanism. The code review identified several critical issues: potential out-of-bounds array accesses in buildTreeFromRoute due to missing layer bounds checks, unsafe in-place modification of set elements when merging co-located access points in GridGraph.cpp, and an initialization bug in verifyDemandConsistency where min_base is set to 0.0, rendering the minimum tracking ineffective.

Comment on lines +1400 to +1401
const int init_layer = segment.init_layer - 1;
const int final_layer = segment.final_layer - 1;

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.

high

In buildTreeFromRoute, init_layer and final_layer are computed by subtracting 1 from segment.init_layer and segment.final_layer. If these layers are invalid or out of bounds (e.g., < 0 or >= grid_graph_->getNumLayers()), subsequent calls like grid_graph_->getLayerDirection(init_layer) or constructing GRPoint will result in out-of-bounds array accesses or undefined behavior. Adding a bounds check here prevents potential crashes.

    const int init_layer = segment.init_layer - 1;
    const int final_layer = segment.final_layer - 1;
    if (init_layer < 0 || init_layer >= grid_graph_->getNumLayers() ||
        final_layer < 0 || final_layer >= grid_graph_->getNumLayers()) {
      return nullptr;
    }

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

constexpr double tol = 1e-6;
double max_diff = 0.0;
double min_base = 0.0;

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.

medium

In verifyDemandConsistency, min_base is initialized to 0.0. Since demand values are non-negative, std::min(min_base, base[l][x][y]) will always evaluate to 0.0, making the minimum tracking ineffective. Initializing min_base to std::numeric_limits<double>::max() ensures the actual minimum base demand is correctly captured.

  double min_base = std::numeric_limits<double>::max();

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Unknown error
ℹ️ 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".

@eder-matheus

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 2140c9afd7

ℹ️ 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".

Signed-off-by: Eder Monteiro <emrmonteiro@precisioninno.com>
…l route

Signed-off-by: Eder Monteiro <emrmonteiro@precisioninno.com>
Signed-off-by: Eder Monteiro <emrmonteiro@precisioninno.com>
@eder-matheus
eder-matheus marked this pull request as ready for review July 17, 2026 22:01
@eder-matheus
eder-matheus requested a review from a team as a code owner July 17, 2026 22:01
@eder-matheus
eder-matheus requested a review from jfgava July 17, 2026 22:01
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.

1 participant