Skip to content

grt, rsz: automatic ODB-callback wiring for CUGR and CI log fix#10683

Open
sparsh-karna wants to merge 3 commits into
The-OpenROAD-Project:masterfrom
sparsh-karna:auto-odb-callback-cugr
Open

grt, rsz: automatic ODB-callback wiring for CUGR and CI log fix#10683
sparsh-karna wants to merge 3 commits into
The-OpenROAD-Project:masterfrom
sparsh-karna:auto-odb-callback-cugr

Conversation

@sparsh-karna

Copy link
Copy Markdown
Contributor

This PR implements full automatic ODB-callback wiring for the CUGR incremental routing flow, bringing it to feature parity with FastRoute's incremental state management. Structural changes in the database (instance moves, master swaps, connectivity updates) now automatically trigger topology refreshes and re-routing in CUGR without requiring manual Tcl interventions.

Key Changes

  • Automatic Topology Refresh: Updated GlobalRouter::addDirtyNet to call cugr_->updateNet(net). This ensures that any event marking a net as dirty (like moving an instance) also refreshes CUGR's internal pin and obstruction maps.
  • Fallback for Net Merging: Added a CUGR hook in GlobalRouter::mergeNetsRouting that marks affected nets as dirty, ensuring they are re-routed during the next incremental update.
  • Robust Initialization: Added defensive checks in CUGR's incremental API (addDirtyNet, updateNet, removeNet) to gracefully handle database callbacks that occur before the global router is fully initialized.
  • API Cleanup: Removed the redundant and temporary grt::add_dirty_net and grt::update_cugr_net Tcl/SWIG functions, as they are no longer needed with automatic wiring.
  • CI Fix: Suppressed non-deterministic Runtime: {:.2f}s log messages in RSZ Python tests to resolve Jenkins CI failures caused by golden file mismatches.

Verification

  • Updated incremental_deleted_net.tcl and incremental_update_net.tcl to remove manual update calls, confirming the flow is now fully automatic.
  • Verified all GRT and RSZ tests pass via ctest.

Prerequisites

  • Clang-format has been run.
  • Commits follow DCO compliance (git commit -s).

       * Removed explicit grt::add_dirty_net calls from src/grt/test/incremental_deleted_net.tcl.
       * Removed explicit grt::update_cugr_net calls from src/grt/test/incremental_update_net.tcl.
       * Automatic ODB callbacks now handle all necessary topology refreshes and re-routing triggers.
   2. SWIG Interface Cleanup:
       * Deleted the exported add_dirty_net and update_cugr_net functions from src/grt/src/GlobalRouter.i.
   3. C++ Refactoring:
       * Removed the redundant GlobalRouter::updateCUGRNet method from GlobalRouter.cpp and GlobalRouter.h as it was only used by the removed SWIG function.
   4. Verification:
       * Regenerated golden .ok files for the affected tests to align with the new automatic flow.
       * Verified that all related integration tests (incremental_deleted_net, and incremental_update_net) pass successfully via ctest.

Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
@sparsh-karna sparsh-karna requested a review from a team as a code owner June 17, 2026 23:19
@sparsh-karna sparsh-karna requested a review from jfgava June 17, 2026 23:19

@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 refactors the incremental global routing flow when using CUGR, automating net updates and dirty net marking internally instead of relying on manual SWIG interface calls. The review feedback highlights a potential segmentation fault in addDirtyNet if a net is missing from db_net_map_, and points out an unused variable warning in startIncremental when CUGR is disabled.

Comment thread src/grt/src/GlobalRouter.cpp
Comment thread src/grt/src/GlobalRouter.cpp Outdated
Comment on lines +368 to +375
std::vector<Net*> nets = initFastRoute(min_layer, max_layer);
if (use_cugr_) {
odb::PtrSet<odb::dbNet> clock_nets;
findClockNets(nets, clock_nets);

cugr_->setCongestionIterations(congestion_iterations_);
cugr_->init(min_layer, max_layer, clock_nets);
}

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

The variable nets is only used when use_cugr_ is true. If use_cugr_ is false, nets is unused, which can trigger compiler warnings or errors (e.g., -Wunused-variable) under strict build configurations. Consider restructuring the block to only declare nets when use_cugr_ is enabled.

    if (use_cugr_) {
      std::vector<Net*> nets = initFastRoute(min_layer, max_layer);
      odb::PtrSet<odb::dbNet> clock_nets;
      findClockNets(nets, clock_nets);

      cugr_->setCongestionIterations(congestion_iterations_);
      cugr_->init(min_layer, max_layer, clock_nets);
    } else {
      initFastRoute(min_layer, max_layer);
    }

@eder-matheus eder-matheus requested review from eder-matheus and removed request for jfgava June 17, 2026 23:39
Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
Comment on lines -179 to -191
void
add_dirty_net(odb::dbNet* net)
{
if (net != nullptr) {
getGlobalRouter()->addDirtyNet(net);
}
}

void
update_cugr_net(odb::dbNet* net)
{
getGlobalRouter()->updateCUGRNet(net);
}

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.

Great to see them gone!

Comment on lines +68 to +79
Routing statistics
Wire length: 889
Total via count: 30
Total congestion: 0
Min resource: 1.5
Bottleneck: (6, 0, 0)
Routing statistics
Wire length: 889
Total via count: 30
Total congestion: 0
Min resource: 1.5
Bottleneck: (6, 0, 0)

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.

This log seems duplicated. Please check what's exactly going on here. Is CUGR running twice for the same subset of dirty nets?

getMinMaxLayer(min_layer, max_layer);
initFastRoute(min_layer, max_layer);
if (use_cugr_) {
std::vector<Net*> nets = initFastRoute(min_layer, max_layer);

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.

Calling initFastRoute here is awkward, since you're in the CUGR branch. What you really need is the part of CUGR that initializes the netlist:

std::vector<Net*> nets = findNets(true);
  check_pin_placement_ = check_pin_placement;
  if (check_pin_placement) {
    checkPinPlacement();
  }
  initNetlist(nets);

You can refactor this piece of code out of initFastRoute into an individual function and use it here instead of calling the full initFastRoute function.

Comment on lines +5405 to +5408
if (use_cugr_) {
addDirtyNet(db_net1);
return;
}

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.

Add a comment explaining why we just add the merged nets to the dirty nets list. This can be a TODO comment, explaining that we intend to give full support for merging nets in the future.

Comment on lines +6216 to +6220
if (use_cugr_) {
cugr_->routeIncremental();
routes_ = cugr_->getRoutes();
return {};
}

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.

This looks correct, as the CUGR APIs seems easier and cleaner to use to update the dirty nets. I'd like to see other tests with more transformations in the design, to see how it behaves.

Look at the global_route.tcl script from ORFS for a reference on how to create a unit test with repair_timing/design calls: https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts/blob/master/flow/scripts/global_route.tcl#L51-L90

Notice that repair_design and repair_timing have internal wiring to the incremental GRT, so you don't need to call global_route -start_incremental/-end_incremental before/after them.

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