Skip to content

rsz, gpl: Fold duplicate ports before swapping arithmetic modules and update the GPL incremental mode - #12391

Open
LucasYuki wants to merge 10 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:r2_swap_fix_unl_nop2_rtall
Open

LucasYuki wants to merge 10 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:r2_swap_fix_unl_nop2_rtall

Conversation

@LucasYuki

@LucasYuki LucasYuki commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

replace_arith_modules refuses to swap a module instance that has ports the replacement module lacks (ODB-0453). Hierarchical buffering adds such ports, for example during timing-driven global placement. This PR removes them before the swap when each one only carries a copy of a signal that already crosses a port the replacement has. On the public designs this removes all 16 swaps master refuses.

It also changes incremental global placement, which places the swapped modules' new cells, to keep those cells in the space the replaced cells left.

Type of Change

  • New feature
  • Documentation update

Impact

rsz

  • Before each swap, an extra port of the instance is removed (RSZ-0171) if it is a scalar input and its outside net, traced upstream through buffers, has the same root as a port both modules have. That port can be an input (the same signal entering twice) or an output (one of the module's own outputs brought back in, directly or through a buffer in the parent). If any extra port carries another signal, or the replacement has a port the instance lacks, nothing is changed and the swap is refused as before.
  • Buffers that drove only the removed ports are then removed with removeBufferIfPossible, along with the buffers feeding them while those are left without loads (RSZ-0172).
  • replace_arith_modules returns 1 if any module was swapped and 0 otherwise (documented in the rsz README).

gpl: incremental placement

  • Phase 1 measures overflow over the unlocked instances only. The overflow locked instances already cause in a bin is a fixed baseline, and the total is normalized by the unlocked area. Before, the locked instances' overflow counted too, and phase 1 cannot reduce it.
  • Before phase 1, the fillers are handed out around the space the new cells need. The new cells' density footprints are first spread over their module's hole on the bin grid, then each filler goes to the lowest-density bin. The new cells themselves don't move. The Nesterov state is re-initialized if any filler moved.
  • Phase 1's first step length is scaled by 0.1 so the first step doesn't push the new cells out of the hole.
  • After phase 1, the overflow is re-measured over all instances (GPL-0196). If it is still above the target, phase 2 runs as before, now after handing out the fillers again.
  • New options, documented in the gpl README:
    • -skip_incremental_phase2 keeps the existing instances where they are and leaves any remaining overflow to detailed placement (GPL-0197).
    • -incremental_phase2_overflow sets a separate overflow target for phase 2, so phase 1 can stop at a looser one.
    • GPL-0198 to GPL-0200 reject invalid combinations and values.
  • On GPU builds, the locked flags are uploaded again after unlocking. While instances are locked, density uses the host path, which accounts for locked area.

QoR

Run with the ORFS branch of the same name (companion PR under Related Issues) against master at the same base, OpenROAD 4543b6b and ORFS 25331f78fe. That is OpenROAD-flow-scripts-Private » r2_swap_fix_unl_nop2_rtall #7 vs Nightly-Public #7774, all 62 public designs. All designs finish, and the Jenkins QoR check passes.

The 55 designs that swap nothing end with identical WS and TNS. The 7 that swap (master → branch):

Design Unit Swapped Refused WS TNS
asap7/cva6 ps 1 → 2 1 → 0 -51.1 → -8.7 -2424 → -15
asap7/mock-alu ps 0 → 1 1 → 0 -291.2 → -265.0 -18250 → -17992
ihp-sg13g2/riscv32i ns 1 → 1 0 → 0 -1.689 → -1.745 -1604 → -1597
nangate45/cva6 ns 0 → 2 2 → 0 -1.333 → -1.315 -4649 → -4140
nangate45/swerv ns 2 → 3 1 → 0 -0.497 → -0.500 -282 → -329
nangate45/swerv_wrapper ns 0 → 2 2 → 0 -0.252 → -0.258 -255 → -227
sky130hs/jpeg ns 54 → 63 9 → 0 -0.083 → -0.050 -1.92 → -0.20
  • TNS improves on 6 of the 7. nangate45/swerv gets worse.
  • Step 3_4 summed over all designs goes from 0.28 h to 0.34 h (nangate45/cva6: 36 s → 140 s). Total flow time stays 6.1 h. Most of the increase is the setup repair the ORFS PR adds after a swap. On the 7 swap designs it takes 234 s, and repair_timing in CTS gets 156 s faster.
  • Private designs are running on the rebased branch; results will follow.

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

At 9b1585a, with Bazel, all gpl and rsz tests pass (402 passed, 4 GPU tests skipped), and so does odb/replace_hier_mod1. //test:flow_tests passes (14 designs). clang-format 23.1.2 and tclfmt/tclint 0.7.0, the versions CI uses, report nothing on the changed files.

New and updated tests:

  • rsz/replace_arith_modules4: extra inputs that duplicate existing inputs are removed. Of the buffers that drove them, the one left without loads is removed and the one with another load is kept. A port carrying another signal still refuses the swap.
  • rsz/replace_arith_modules5: extra inputs that bring the module's own outputs back in, directly and through a buffer in the parent, are removed, along with the buffer left without loads. A module whose looped-back signal leaves through an extra output port the replacement lacks still refuses the swap.
  • gpl/incremental04 and gpl/incremental05 (pass/fail) cover phase 2 after a missed target, the separate phase 2 target, and the option checks. gpl/incremental03 now covers the divergence path with -skip_incremental_phase2.
  • odb/replace_hier_mod1.ok is updated for the new phase 1 overflow.
  • gpl/incremental02.ok and .defok are regenerated. incremental02 is a pass/fail test, so CI compares neither file. They are most of this PR's line count.

Related Issues

Should be merged at the same time as ORFS PR: The-OpenROAD-Project/OpenROAD-flow-scripts#4861

Signed-off-by: LucasYuki <lucasyuki@yahoo.com.br>
Signed-off-by: LucasYuki <lucasyuki@yahoo.com.br>
Signed-off-by: LucasYuki <lucasyuki@yahoo.com.br>
Signed-off-by: LucasYuki <lucasyuki@yahoo.com.br>
Signed-off-by: LucasYuki <lucasyuki@yahoo.com.br>
Signed-off-by: LucasYuki <lucasyuki@yahoo.com.br>
… phase 2

Signed-off-by: LucasYuki <lucasyuki@yahoo.com.br>
Signed-off-by: LucasYuki <lucasyuki@yahoo.com.br>
Signed-off-by: LucasYuki <lucasyuki@yahoo.com.br>
Signed-off-by: LucasYuki <lucasyuki@yahoo.com.br>
@LucasYuki LucasYuki self-assigned this Nov 19, 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.

@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 enhancements to the global placement (gpl) and resizer (rsz) modules, including options to skip phase 2 of incremental placement, set a separate phase 2 overflow target, and fold duplicate ports during arithmetic module swapping. The review feedback identifies two key issues in the cell-spreading search logic: an integer division truncation when computing grid step sizes, and the lack of a search iteration limit, which can lead to severe runtime regressions.

Comment thread openroad/gpl/src/nesterovBase.cpp Resolved
Comment thread openroad/gpl/src/nesterovBase.cpp Resolved
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