Skip to content

place: size incremental placement to the swapped modules and enable repair setup after a swap - #4861

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

LucasYuki wants to merge 4 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

Flow side of the arithmetic module swap changes in OpenROAD PR The-OpenROAD-Project/OpenROAD#12391. This PR doesn't change tools/OpenROAD. It needs the OpenROAD PR for the return value of replace_arith_modules and for global_placement -incremental_phase2_overflow, so it can only be merged after #12391 is merged and ORFS's tools/OpenROAD pin is updated past it. Until then, step 3_4 fails on designs with SWAP_ARITH_OPERATORS=1. The QoR below comes from a run with tools/OpenROAD at #12391's head, 9b1585a2b4. Both branches are based on OpenROAD 4543b6b65b and ORFS 25331f7.

Changes

In resize.tcl (step 3_4), when SWAP_ARITH_OPERATORS=1:

  • The phase 1 overflow target of global_placement -incremental grows with the area the swapped modules add. It is 0.1 plus the share of the new modules' area that does not fit in the area of the cells they replaced, max(0, (new - old) / new), capped at 1. Phase 2 then brings the whole design to 0.1 (-incremental_phase2_overflow 0.1). The log reports both areas and the target.
  • If any module was swapped, setup is repaired with placement parasitics (repair_timing_helper -setup -skip_last_gasp). Hold is left to CTS.

ENABLE_PLACE_REPAIR_TIMING=1 now runs this setup-only repair instead of setup and hold repair. It still defaults to 0, and no design in the repo sets it. FlowVariables.md and variables.yaml are updated to match.

util.tcl adds instance_area_um2 [-unplaced], which returns the total instance area in um^2.

QoR

All 62 public designs: OpenROAD-flow-scripts-Private » r2_swap_fix_unl_nop2_rtall #7 against master at the same base (Nightly-Public #7774). 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 refuse none; master refuses 16. Master → branch:

Design Unit Swapped WS TNS
asap7/cva6 ps 1 → 2 -51.1 → -8.7 -2424 → -15
asap7/mock-alu ps 0 → 1 -291.2 → -265.0 -18250 → -17992
ihp-sg13g2/riscv32i ns 1 → 1 -1.689 → -1.745 -1604 → -1597
nangate45/cva6 ns 0 → 2 -1.333 → -1.315 -4649 → -4140
nangate45/swerv ns 2 → 3 -0.497 → -0.500 -282 → -329
nangate45/swerv_wrapper ns 0 → 2 -0.252 → -0.258 -255 → -227
sky130hs/jpeg ns 54 → 63 -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. Total flow time stays 6.1 h. On the 7 swap designs, the new setup repair in 3_4 takes 234 s, and repair_timing in CTS gets 156 s faster (323 → 167 s). On asap7/cva6 alone, CTS repair drops from 119 s to 8 s.
  • On nangate45/cva6, phase 1 stops at the 600-iteration limit (GPL-1010).

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

@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 updates the placement resize stage to dynamically adjust the incremental placement overflow target when SWAP_ARITH_OPERATORS swaps modules, and ensures setup repair timing is run afterward. It also introduces a helper procedure instance_area_um2 to calculate the total area of instances. The review feedback suggests optimizing this new procedure by performing the area summation in DBUs inside the loop and converting to microns once at the end, which avoids a significant performance bottleneck from repeated Tcl-to-C++ SWIG calls.

Comment thread flow/scripts/util.tcl
Comment on lines +305 to +320
proc instance_area_um2 { args } {
sta::parse_key_args "instance_area_um2" args keys {} flags {-unplaced}
set unplaced_only [info exists flags(-unplaced)]
set area 0.0
foreach inst [[ord::get_db_block] getInsts] {
if { $unplaced_only && [$inst isPlaced] } {
continue
}
set master [$inst getMaster]
set area [expr {
$area + [ord::dbu_to_microns [$master getWidth]]
* [ord::dbu_to_microns [$master getHeight]]
}]
}
return $area
}

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

Calling ord::dbu_to_microns twice per instance inside the loop introduces a significant performance bottleneck for large designs with millions of instances due to the overhead of Tcl-to-C++ SWIG calls.

We can optimize this by summing the area in DBUs (integers) inside the loop, and then converting the total sum to square microns once at the end using a single conversion factor. This avoids millions of SWIG calls and speeds up the procedure significantly.

proc instance_area_um2 { args } {
  sta::parse_key_args "instance_area_um2" args keys {} flags {-unplaced}
  set unplaced_only [info exists flags(-unplaced)]
  set area_dbu 0
  foreach inst [[ord::get_db_block] getInsts] {
    if { $unplaced_only && [$inst isPlaced] } {
      continue
    }
    set master [$inst getMaster]
    set area_dbu [expr { $area_dbu + [$master getWidth] * [$master getHeight] }]
  }
  set dbu_factor [ord::dbu_to_microns 1]
  return [expr { $area_dbu * $dbu_factor * $dbu_factor }]
}

@openroad-ci

Copy link
Copy Markdown
Member

🔍 QoR check

Metrics reflect the PR merge build — i.e. what will land on the target branch.

Commit 96c293c · Jenkins build #1 · Baseline: build · View build on dashboard

62 design(s) checked — 0 with regression(s), 26 without a comparable baseline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants