Skip to content

rsz: Fix VT swap for flows that change dont_use VTs - #12236

Open
jhkim-pii wants to merge 13 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:secure-rsz-fastest-vt-only
Open

jhkim-pii wants to merge 13 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:secure-rsz-fastest-vt-only

Conversation

@jhkim-pii

Copy link
Copy Markdown
Contributor

Summary

  • Fixes two VT swap issues that block a flow that repairs timing with the fastest VT only (the slower VTs on dont_use) and lifts the slower VTs later in the same session.

Why this PR is needed

  • Use case: A design team wants an LVT-only flow, so every HVT cell is put on dont_use and the tool builds and repairs the design with LVT cells only.
  • Catch: Some HVT cells are already in the netlist before the flow starts, for example cells instantiated by hand in the RTL or latches that a platform map always creates as HVT.
  • What goes wrong today: With only one usable VT, the tool turns VT swap off completely, so these HVT cells stay slow for the whole flow and can end up setting the worst timing path.
  • What this PR allows: During timing repair, a cell that sits on a dont_use VT may swap to its equivalent in the usable VT (HVT -> LVT). The tool still never moves a cell onto a dont_use VT.
  • Second half of the same flow: Such a flow often lifts the HVT dont_use later (e.g. to recover power). The tool then has to forget the VT choices it cached earlier, otherwise it still acts as if HVT were forbidden.

Problem

# Problem Symptom
1 getVTEquivCells() caches its result per cell, and set_dont_use / unset_dont_use / reset_dont_use do not clear the cache After unset_dont_use, VT swap still uses the VT list of the earlier repair and cannot reach the lifted VT
2 VT swap is disabled when fewer than two VTs are usable A cell that synthesis mapped to a dont_use VT (e.g. a latch from a platform latch map) stays on the slower VT and can set WNS
3 The library VT data is rebuilt only by findBuffers() with buffer pruning Without pruning, or when getVTEquivCells() runs first, the VT count of the old dont_use list stays and VT swap finds no equivalent
4 getVTEquivCells() caches the list of a dont_use source cell for every cell in it A usable cell can swap to a dont_use VT (RVT cells moved to SLVT under set_dont_use SLVT)
  • Symptom of problem 1 on ASAP7 gcd (repair_setup_vt_swap_unset_dont_use): second repair_timing after unset_dont_use of SLVT.
Before: SLVT cells 144 -> 158 in the second repair (WNS -36.067)
After:  SLVT cells 125 -> 168 in the second repair (WNS -34.293); SLVT stays at 125 while it is dont_use
  • Symptom of problem 2 on ASAP7 gcd with only SLVT usable (repair_setup_parallel_eval_vt_swap_dont_use): no VT swap before; RVT and LVT cells on violating paths move to SLVT after.

Changes

Area Before After
Resizer::setDontUse(), Resizer::resetDontUse() Clear every dont_use dependent cache except the VT equivalent cache Also clear vt_equiv_cells_cache_
Resizer::getVTEquivCells() Empty list when fewer than two VT categories are usable A dont_use source cell keeps its equivalents in the usable VT
VT swap gate vtCategoryCount() < 2 disables the move Resizer::canVtSwap(cell): two or more usable VTs, or a dont_use cell with a usable VT equivalent; used by VtSwapMtGenerator and VtSwapGenerator
SetupLegacyBase::hasVtSwapCells() Counts the usable VTs only, so LEGACY drops VtSwap with one usable VT Uses Resizer::vtCategoryCountWithDontUse() as PARALLEL_EVAL does
Library VT data refresh Only in findBuffers() with pruning Also in findBuffersNoPruning() and getVTEquivCells() when buffer_cells_ is empty
VT list sharing in getVTEquivCells() The list of any source cell is cached for all its equivalents Shared only when the source cell is usable
SetupParallelEvalPolicy Drops VtSwapMt when fewer than two VTs are usable Keeps VtSwapMt when the library has two or more VTs with the dont_use ones included (Resizer::vtCategoryCountWithDontUse(), counted once with the library data, no instance scan); a single-VT library still drops it

Impact

  • Flows that do not change dont_use between repairs and have no instance on a dont_use VT are unchanged: no existing golden changes.
  • A design with instances on a dont_use VT and one usable VT now gets VT swaps to the usable VT during setup repair.
Details

Commits

  • rsz: Clear the VT equivalent cache when dont_use changes: The cache fix and its test.
  • rsz: Let VT swap move dont_use VT cells to the usable VT: The single-usable-VT swap and its test.
  • rsz: Gate VtSwapMt on the library VT count instead of an instance scan: Replaces the per-run leaf instance scan with a library-level VT count.
  • rsz: Cover LEGACY VT swap and stale VT data after dont_use changes: The LEGACY gate, the library VT data refresh and the unshared list of a dont_use cell, with two tests.

Testing

  • bazelisk test //src/rsz/test/... with the Tcl format and lint tests: 330 pass.
  • New tests: repair_setup_vt_swap_unset_dont_use, repair_setup_vt_swap_unset_dont_use_no_pruning, repair_setup_vt_swap_dont_use (LEGACY), repair_setup_parallel_eval_vt_swap_dont_use.

What: set_dont_use, unset_dont_use and reset_dont_use now clear the VT
equivalent cell cache of getVTEquivCells().

Why: getVTEquivCells() skips dont_use cells but caches its result per
cell, and the dont_use commands cleared every other dont_use dependent
cache except this one. A flow that keeps some VTs on dont_use during one
repair and lifts them later in the same session kept the VT lists of the
first repair, so VT swap could not reach the lifted VTs.

How:
- Clear vt_equiv_cells_cache_ in Resizer::setDontUse() and
  Resizer::resetDontUse().
- New test repair_setup_vt_swap_unset_dont_use (ASAP7 gcd): VT swap with
  SLVT on dont_use, then again after unset_dont_use. The second repair
  moved 24 cells and ended at WNS -36.1 ps before, 37 cells and -30.7 ps
  now.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
What: with only one usable VT (e.g. a flow that puts every VT but the
fastest on dont_use), VT swap now moves an instance whose cell is in a
dont_use VT to its equivalent in the usable VT.

Why: synthesis can map cells outside DONT_USE_CELLS. A platform latch
map that always makes latches of one slower VT left clock-enable
latches on that VT in a fastest-VT-only flow, and their clock gating
checks set the WNS. VtSwap was disabled because vtCategoryCount()
counts only the usable buffer VTs, and SizeUpMt keeps the VT of the
cell, so no repair move could leave the slower VT cell.

How:
- Resizer::getVTEquivCells keeps the usable-VT equivalents of a
  dont_use source cell when fewer than two VT categories are usable.
- Resizer::canVtSwap(cell) allows a swap with two or more usable VTs, or
  for a dont_use cell with a usable-VT equivalent;
  VtSwapMtGenerator::isApplicable and VtSwapGenerator::selectPathBestCell
  use it instead of vtCategoryCount().
- SetupParallelEvalPolicy keeps VtSwapMt in a single-VT library when
  Resizer::hasDontUseVtSwapInstances() finds such an instance.
- New test repair_setup_parallel_eval_vt_swap_dont_use: ASAP7 gcd with
  only SLVT usable; RVT and LVT cells on violating paths move to SLVT
  (previously no move).

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
What: PARALLEL_EVAL keeps VtSwapMt when the library has two or more VT
categories with the dont_use ones included, and
Resizer::hasDontUseVtSwapInstances() is removed.

Why: the policy scanned every leaf instance at its start to find one on
a dont_use VT. The question only decides whether VtSwapMt is in the move
set; Resizer::canVtSwap() already decides per cell, so a library level
answer is enough and costs nothing per run.

How:
- getBufferList() counts the VT categories of the buffers before the
  dont_use filter into LibraryAnalysisData::vt_category_count_with_dont_use.
- SetupParallelEvalPolicy::moveEnabled() uses
  Resizer::vtCategoryCountWithDontUse() > 1.
- A library with a single VT still drops VtSwapMt. No golden changes.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
What:
- LEGACY setup repair keeps VtSwap when the library has two or more VTs
  with the dont_use ones included, as PARALLEL_EVAL does.
- The library VT data is rebuilt after a dont_use change also without
  buffer pruning and when getVTEquivCells() runs before findBuffers().
- The VT list of a dont_use cell is no longer shared with its
  equivalents.

Why:
- SetupLegacyBase::hasVtSwapCells() still counted the usable VTs only, so
  the default flow never moved a cell off a dont_use VT.
- set_dont_use clears buffer_cells_, but the library VT data was rebuilt
  only by findBuffers() with pruning. Without pruning, or for a caller
  that asks getVTEquivCells() first, the VT count of the old dont_use
  list stayed and VT swap found no equivalent.
- getVTEquivCells() cached the list of a source cell for every cell in
  it. The list of a dont_use source holds that cell, so a usable cell
  could swap to a dont_use VT (RVT cells moved to SLVT under
  set_dont_use SLVT).

How:
- hasVtSwapCells() uses Resizer::vtCategoryCountWithDontUse().
- findBuffersNoPruning() and getVTEquivCells() rebuild the library data
  when buffer_cells_ is empty.
- getVTEquivCells() caches the list for the equivalents only when the
  source cell is usable.
- New tests repair_setup_vt_swap_dont_use (LEGACY, one usable VT) and
  repair_setup_vt_swap_unset_dont_use_no_pruning; the golden of
  repair_setup_vt_swap_unset_dont_use changes (SLVT stays at 125 cells
  while it is dont_use).

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
@jhkim-pii jhkim-pii self-assigned this Nov 11, 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 enables VT swapping when only one usable VT is available by allowing cells mapped to a dont_use VT to be swapped to the usable VT. It introduces helper methods to track VT categories including dont_use ones and adds corresponding test cases. The reviewer pointed out a critical performance bottleneck in findBuffersNoPruning and getVTEquivCells where using a local buffer_list instead of populating the member variable buffer_cells_ leaves it empty, causing redundant and expensive rebuilds of the library data.

Comment thread openroad/rsz/src/Resizer.cc Resolved
Comment thread openroad/rsz/src/Resizer.cc Resolved
@jhkim-pii
jhkim-pii marked this pull request as ready for review November 11, 2026 05:31
@jhkim-pii
jhkim-pii requested a review from a team as a code owner November 11, 2026 05:31

@precisionmoon precisionmoon 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.

Please resolve the merge conflicts first.

…vt-only

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>

# Conflicts:
#	src/rsz/src/policy/SetupParallelEvalPolicy.cc
…ter merge

The relative leakage cost that master added to the PARALLEL_EVAL cell
swaps changes which VT the second repair_timing picks once SLVT is
usable again (SLVT 125 -> 147 instead of 125 -> 168). The first repair,
where SLVT is dont_use, is unchanged and SLVT still stays at 125.
Regenerate the golden log from the merged build.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
@jhkim-pii

Copy link
Copy Markdown
Contributor Author

@precisionmoon Resolved the conflict.

Bring in master at bc2631a after the OpenROAD source tree move.
Place the four VT swap regression scripts and golden logs in the new
openroad/rsz/test directory while preserving the PR's VT swap logic.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
}
vt_categories_with_dont_use.insert(cellVTType(master));
if (dontUse(buffer)) {
continue;

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.

What happens when cellVTType is "-" (no obstruction layers)? Does this skew the VT count?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. It is considered as another Vt type. But it does not incur any functional error.

Comment thread openroad/rsz/src/Resizer.cc Outdated
{
if (!lib_data_) {
// A dont_use change clears buffer_cells_; the library data is stale then.
if (!lib_data_ || buffer_cells_.empty()) {

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.

It's not safe to use buffer_cells_.emptyI() as proxy for stale library data. Hold fixing can modify buffer_cells_ also.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll fix it.
In the repair hold, the current buffer_cells_ modification to allow CLKBUF usage for hold fixing looks problematic.
I handled it in another PR: #12360

Comment thread openroad/rsz/src/Resizer.cc Outdated
if (!lib_data_) {
// A dont_use change clears buffer_cells_; rebuild the library data when a
// caller asks before findBuffers() does.
if (!lib_data_ || buffer_cells_.empty()) {

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.

It's not safe to use buffer_cells_.emptyI() as proxy for stale library data. Hold fixing can modify buffer_cells_ also.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll fix it.
In the repair hold, the current buffer_cells_ modification to allow CLKBUF usage for hold fixing looks problematic.
I handled it in another PR: #12360

@precisionmoon precisionmoon 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.

Please fix two issues in the comment.

  1. cellVTType == "-" impacting VT count
  2. unsafe use of buffer_cells_.empty() for stale lib data

Track the clock-buffer filter used to build library VT data and invalidate it when dont_use changes. Hold repair temporarily includes clock buffers and restores only the selected buffer list, so list emptiness cannot establish whether the analysis matches the current filter.

Exclude buffers without an implant-defined VT from the new all-buffer VT count while preserving existing usable-VT analysis. Clear filter-dependent fast-buffer and equivalent-cell caches on refresh, and add C++ regressions for hold, no-pruning and VT lookup paths.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Replace the clock-buffer filter tracking of the previous commit with an
explicit reset of lib_data_ in setDontUse() and resetDontUse(), and
restore the original !lib_data_ checks in findBuffersNoPruning() and
getVTEquivCells().

The library analysis data is built from the usable buffers only, so a
dont_use change is what makes it stale. Hold repair no longer swaps the
buffer list or the clock-buffer filter (rsz: Use data buffers only for
hold repair), so a dont_use change is the only remaining trigger, and
buffer_cells_ emptiness is no longer used as a staleness proxy. A reset
lib_data_ is rebuilt once by the next getBufferList() call, whereas the
proxy rebuilt it on every uncached VT lookup while buffer_cells_ stayed
empty.

Keep the all-buffer VT count consistent with vtCategoryCount() for
cells without implant layers; their handling moves to a separate change.
Remove the hold-specific C++ regressions. The unset_dont_use Tcl
regressions cover the pruned and unpruned refresh paths, and
repair_setup_vt_swap_unset_dont_use_no_pruning fails without the reset.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
A cell without IMPLANT obstructions gets vt_index 0 ("-") from
cellVTType(). It was used as a VT category of its own: vtCategoryCount()
and vtCategoryCountWithDontUse() counted it, findBuffers() and
RepairHold could pick it as the best VT, and VT swap used it as a source
and a target. In a library that mixes implant-defined and implant-less
cells, this adds a VT that does not exist and lets VT swap move cells
between identified VTs and an unknown one.

Name the sentinel VTCategory::kUnclassifiedVtIndex and add
VTCategory::isClassified(). getBufferList() builds the VT categories and
the all-buffer VT count from identified VTs only. getVTEquivCells()
returns no alternatives for an unclassified source cell and skips
unclassified candidates.

With no identified VT, the existing best_vt_index == -1 path in
findBuffers() and RepairHold turns the VT filter off, so a library
without implant layers selects the same buffers as before and
report_buffers reports 0 VT types. A fully identified library is
unchanged. Keep-VT checks in sizing still compare vt_index, so an
unclassified cell sizes only among unclassified cells.

Give BUF_X2 an explicit RVT implant in the VT deduplication test, which
relied on "-" as RVT, and add tests for a library without implant layers
and for a mixed library.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
The kUnclassifiedVtIndex initializers in cellVTType() span two lines, so
clang-tidy readability-trailing-comma flags them in the PR diff. Add the
trailing commas; clang-format then puts each designator on its own line.
No functional change.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
vtCategoryCount() and vtCategoryCountWithDontUse() return different counts,
but the header did not say what vtCategoryCount() counts, and the comment of
vtCategoryCountWithDontUse() said "in the library" although only buffers are
counted.

Document both as buffer VT counts: the usable buffers for vtCategoryCount()
and all buffers with an identified VT, dont_use ones included, for
vtCategoryCountWithDontUse(). Comment-only change.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
…vt-only

Resolve the TestResizer.cc conflict by keeping both test sets: the VT
category tests of this branch and the report_vt_usage tests from master.

getBufferList() keeps the unclassified VT exclusion of this branch on top
of master's unconditional clock buffer exclusion. report_vt_usage keeps
reporting implant-less cells as "-" because cellVTType() still names them so.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
@jhkim-pii

jhkim-pii commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author
  1. cellVTType == "-" impacting VT count
  • Fixed. Now "-" Vt type does not increase Vt count and swapping to "-" Vt type is not allowed.
  1. unsafe use of buffer_cells_.empty() for stale lib data

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