Repository navigation
Conversation
The test builds its drivers as LOCKED, and rebuffering does not resize fixed instances, so -rebuffer_size_driver could never resize them. Unlock the drivers after repair_design in the driver-sizing variant, and check after each rebuffering step that no driver moved, which the lock was there to prevent. Rebuffering now resizes 22 drivers. The mean gap to the reference (rebuffer_reference/run_reference.py --size-driver) drops from 23.9 ps to 21.4 ps; the worst gap is unchanged at 41.4 ps. Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
With -rebuffer_size_driver, slackWithDriverCell() checked the driver cell's output slew and load slew but not its max capacitance. The candidate trees are built against the capacitance limits of their buffers, so a tree could be chosen with a driver cell whose limit it exceeds, leaving max capacitance violations for repair_design to fix again. Reject such combinations, with the same margin as the buffers. fully_rebuffer alone, sizing on, before -> after: - black_parrot (nangate45, 4.5 ns clock): max capacitance violations 445 -> 0, TNS -655 -> -670 ns, failing endpoints 3616 -> 3953, area +0.5%, runtime +8% - swerv_wrapper (asap7): max capacitance violations 19 -> 0, TNS unchanged at -284 ps - gcd and the rsz unit tests: unchanged Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
upstreamSideLoadsOk() checked only the other loads of the net driving the input on the timed path. Upsizing a multi-input cell raises the capacitance of every input, slowing the nets on the other inputs and the paths through them. Check those nets' loads too. With the current area-first selection this rejects a few upsizes (15 instead of 19 on rebuffer_size_driver) and leaves TNS unchanged. It is needed for slack-first selection: without it, upsizing on gcd worsens TNS at every clock period tried. Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
With -rebuffer_size_driver, sizeDriverWithTree() picks the smallest (tree + driver) area that meets slack_target. That target is the slack of the timing-optimized tree with the current driver, less the relaxation fullyRebuffer() allows for area recovery (about 1% of the path delay when slack is negative). Because it is anchored to the current driver, any resize that gains slack competes with cheaper combinations that only match the current driver, and loses on area: on a failing path sizing could trade slack for area but not area for slack. When slack_target is negative, anchor it instead to the best slack any candidate tree reaches with any driver cell that passes the side-load check, less the same relaxation. The selection is unchanged: the smallest area meeting the target wins, but only among combinations within the relaxation of the best. For example, with the current driver at -100 ps, a relaxation of 2 ps, and an upsized driver reaching -80 ps, the target moves from -102 ps to -82 ps. Passing paths are unchanged. Sizing on, before -> after: - rebuffer_size_driver (gcd, 0.5 ns): TNS -1.43 -> -1.15 ns, area +3.2% - swerv_wrapper (asap7): TNS -284 -> -93 ps (sizing off: -126 ps) - black_parrot (nangate45, 4.5 ns clock): TNS -678 -> -585 ns, failing endpoints 4145 -> 1947 - buffer_varying_lengths_size_driver: mean gap to the reference 21.4 -> 15.5 ps, worst 41.4 -> 26.3 ps Rebuffer runtime is unchanged on swerv_wrapper and +5% on black_parrot. Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
Rebuffering often places a buffer right at a weak driver, which does the job of a larger driver. Driver sizing only re-timed the trees built for the current driver, so it never saw the same tree without that buffer and could not replace the buffer with an upsized driver. For each candidate tree whose first node below the driver is a buffer reached through wires only, also offer the tree with that buffer removed and the driver wired straight to the buffer's load. Sizing on, before -> after: - buffer_varying_lengths_size_driver: mean gap to the reference 15.5 -> 11.6 ps - swerv_wrapper (asap7): TNS unchanged at -93 ps, 8% fewer buffers - black_parrot (nangate45, 4.5 ns clock): TNS -585 -> -576 ns, failing endpoints 1947 -> 1876, 8% fewer buffers - rebuffer_size_driver (gcd): unchanged Rebuffer runtime is unchanged on swerv_wrapper and +2% on black_parrot. Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
The sizing leakage limit filters swappable cells by the ratio of their leakage to the current cell's. For a driver this refuses an upsize even when it replaces buffers and lowers the net's leakage. With the default 4x limit it also bars BUF_X1 from growing to BUF_X4 in Nangate45, whose leakage ratio is 4.02. In rebuffer's driver sizing, consider every swappable cell except those only the leakage limit excludes, and instead limit the leakage of the driver and its buffers together to the limit times that of the current driver with the timing tree. getSwappableCells() keeps the per-cell limit for all other callers; its cache now holds both lists. Sizing on, before -> after: - buffer_varying_lengths_size_driver: mean gap to the reference 11.6 -> 2.0 ps, worst 25.4 -> 8.2 ps; leakage of drivers and buffers +7% (the extra comes from buffer choices, not drivers) - black_parrot (nangate45, 4.5 ns clock): TNS -576 -> -554 ns, failing endpoints 1876 -> 1810 - swerv_wrapper (asap7), rebuffer_size_driver (gcd): unchanged Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
Add buffer_varying_lengths_asap7 and buffer_varying_lengths_asap7_size_driver so rebuffering is measured on a second PDK. The PDK-specific settings (libraries, buffers, layers, length step, clock period, and the reference search seeds) move to buffer_varying_lengths_pdk.tcl, shared by the tests and rebuffer_reference/; the nangate45 tests' output is unchanged. On asap7 the paths are 3.75 um * i long (up to 375 um, about five buffer spacings on M3) and the clock period is 1000 ps. run_reference.py takes --pdk; references are now reference_<pdk>_<case>.txt, with new asap7 references. Gaps to the reference with this branch: - asap7 fixed driver: mean 0.81 ps (0.6%), worst 5.9 ps - asap7 driver sizing: mean 0.68 ps (0.5%), worst 3.2 ps (master: mean 9.1 ps, worst 15.8 ps) Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
fully_rebuffer let area recovery give up about 1% of the path delay on
every net, so on the most critical nets a smaller tree that the model
rated only slightly slower won over the fastest one. A failing net
whose slack before rebuffering is within 10% of the design's worst
slack now gets no relaxation. Other failing nets keep it: removing it
on every failing net doubled the rebuffer area in timing-driven global
placement on sky130hs/gcd (+21% -> +47%), and detailed placement then
failed after CTS repair_timing at 99.9% utilization.
Gap to the buffer_varying_lengths reference (mean / worst):
nangate45 fixed driver 3.17 / 18.9 ps -> 3.09 / 18.9 ps
nangate45 sized driver 1.96 / 8.2 ps -> unchanged
asap7 fixed driver 0.81 / 5.9 ps -> 0.76 / 5.8 ps
asap7 sized driver 0.68 / 3.2 ps -> 0.52 / 2.7 ps
Each length is its own path, so only the longest are near the worst
slack.
fully_rebuffer alone on placed designs, before -> after:
swerv_wrapper asap7, sizing on:
WNS -31.7 -> -28.4 ps, TNS -93.3 -> -83.0 ps
black_parrot nangate45 at 4.5 ns, sizing on:
WNS -5.06 -> -4.99 ns, TNS unchanged at -554 ns
swerv_wrapper, black_parrot, and gcd, sizing off: unchanged
gcd 0.40-0.60 ns, sizing on: unchanged
sky130hs/gcd through CTS: rebuffer area in global placement unchanged
(+21%); after CTS repair_timing, utilization 76.6% -> 76.5%, WNS
-0.208 -> -0.216 ns, TNS -5.2 -> -5.8 ns.
Runtime and area are within noise.
Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
Long-wire stepping places buffers back from the load end at the
asymptotic spacing, leaving the remainder on the upstream stage. On a
weak driver that stage should be shorter than the others, and on some
lengths one more buffer fits. For each buffer size, also offer the
stepped buffer count and one more, evenly spaced, with the upstream
stage 1, 0.5 or 0.25 of the others. Only segments longer than one
spacing build these chains. The long-wire stepping timer is now
accumulated.
Gap to the buffer_varying_lengths reference (mean / worst):
nangate45 fixed driver 3.09 / 18.9 ps -> 2.02 / 5.6 ps
nangate45 sized driver 1.96 / 8.2 ps -> 2.10 / 9.2 ps
asap7 fixed driver 0.76 / 5.8 ps -> 0.23 / 1.8 ps
asap7 sized driver 0.52 / 2.7 ps -> 1.08 / 3.2 ps
With driver sizing, the short upstream stage suits only the current
driver; planning per driver cell recovers it in the next commit.
fully_rebuffer alone on placed designs, before -> after:
black_parrot nangate45 at 4.5 ns, sizing on:
TNS -554 -> -541 ns, failing endpoints 1810 -> 1803
black_parrot, sizing off:
TNS -720 -> -741 ns, failing endpoints 4595 -> 4715
swerv_wrapper asap7, sizing off: TNS -126.5 -> -123.8 ps
swerv_wrapper, sizing on: unchanged
gcd: unchanged
Runtime +2-3%, area within 0.05%.
repair_timing -setup is unchanged on gcd, swerv_wrapper, and
black_parrot. In the unit tests its rebuffer move shifts results both
ways: repair_setup2 WNS -0.12 -> -0.11 ns, repair_fanout7/8 and
clone_flat WNS 0.01-0.06 ns worse.
Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
With -rebuffer_size_driver, every candidate tree was planned for the
current driver cell and only retimed with the others. With the evenly
spaced chains of the previous commit, the tree planned for a weak
driver starts with a short stage that a larger driver does not need.
On a failing path, also buffer the net from scratch (timing and area
recovery) as though the driver were each allowed cell that speeds up
the timing tree, and offer those trees to driver sizing. Driver timing
for another cell is shared with slackWithDriverCell() through
cellArcTiming().
Gap to the buffer_varying_lengths reference, driver sized
(mean / worst):
nangate45 2.10 / 9.2 ps -> 1.66 / 5.3 ps
asap7 1.08 / 3.2 ps -> 0.53 / 3.1 ps
Fixed-driver results are unchanged.
fully_rebuffer alone on placed designs, sizing on, before -> after:
black_parrot nangate45 at 4.5 ns:
TNS -541 -> -508 ns, failing endpoints 1803 -> 1754,
runtime 39.6 -> 42.7 s (+8%)
swerv_wrapper asap7: unchanged
gcd: unchanged
Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
On a failing path, bestSlackWithDriver() accepted a driver cell whose upstream side loads stayed above the original slack target, then raised the target to that cell's slack. chooseTreeAndDriver() checks the side loads against the raised target, so the cell that set it could be rejected there. When no other combination met the target, sizing fell back to the unsized area tree. upstreamSideLoadsOk() becomes upstreamSideLoadSlack(), which returns the worst slack the resize leaves on a side load it slows. bestSlackWithDriver() now accepts a candidate only when that slack meets the target the candidate would set (its slack less the relaxation), so the cell that sets the best slack always passes the second check. Sizing on, before -> after: - black_parrot (nangate45): TNS -508.11 -> -503.50 ns, failing endpoints 1754 -> 1761, area -0.002% - swerv_wrapper (asap7), rebuffer_size_driver (gcd sweep), and the buffer_varying_lengths tests: unchanged Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
…river-slack Signed-off-by: Matt Liberty <mliberty@precisioninno.com> # Conflicts: # openroad/rsz/test/buffer_varying_lengths_asap7.ok # openroad/rsz/test/buffer_varying_lengths_asap7.tcl # openroad/rsz/test/buffer_varying_lengths_asap7_size_driver.ok # openroad/rsz/test/buffer_varying_lengths_asap7_size_driver.tcl # openroad/rsz/test/buffer_varying_lengths_pdk.tcl # openroad/rsz/test/rebuffer_reference/common.tcl # openroad/rsz/test/rebuffer_reference/reference_asap7_fixed.txt # openroad/rsz/test/rebuffer_reference/reference_asap7_size_driver.txt # openroad/rsz/test/rebuffer_reference/reference_fixed.txt # openroad/rsz/test/rebuffer_reference/reference_nangate45_fixed.txt # openroad/rsz/test/rebuffer_reference/reference_nangate45_size_driver.txt # openroad/rsz/test/rebuffer_reference/reference_size_driver.txt # openroad/rsz/test/rebuffer_reference/rsz_solution.tcl # openroad/rsz/test/rebuffer_reference/sweep.tcl # src/rsz/test/rebuffer_reference/reference_fixed.txt # src/rsz/test/rebuffer_reference/reference_size_driver.txt
…river-slack Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
|
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. |
There was a problem hiding this comment.
Code Review
This pull request integrates driver sizing with buffer tree generation during rebuffering in the Resizer tool, enabling timing, area, and leakage budget evaluations for driver resizes. It also optimizes long wire buffering by offering evenly spaced buffer chains. The review feedback suggests using .value() instead of .value_or() to avoid silently hiding impossible states with default values, and adding a guard in stepToward to prevent a potential division by zero when the distance is zero.
| const CellArcTiming timing = cellArcTiming(rf, plan_cell_, bnet->cap()) | ||
| .value_or(CellArcTiming{}); |
There was a problem hiding this comment.
Using .value_or(CellArcTiming{}) here silently defaults to a zero-valued CellArcTiming if cellArcTiming returns std::nullopt. Since planForDriverCell only plans for cells with matching arcs, cellArcTiming returning std::nullopt represents an impossible state. According to the OpenROAD code-review guidance, we should avoid guards that hide impossible states with silent defaults. Using .value() instead will ensure a loud failure if this invariant is ever broken.
const CellArcTiming timing = cellArcTiming(rf, plan_cell_, bnet->cap()).value();References
- Never suggest a guard that hides an impossible state: a null check, an empty, zero or negative check, or a missing-key check that returns a default, skips, clamps, continues or logs a warning and carries on. A null dereference that is reachable is reported with its triggering input; the fix is logger_->error(...) or an assert, never a silent default. (link)
| static odb::Point stepToward(const odb::Point& from, | ||
| const odb::Point& to, | ||
| const int distance) | ||
| { | ||
| int dx = to.x() - from.x(); | ||
| int dy = to.y() - from.y(); |
There was a problem hiding this comment.
If from and to are the same point (i.e., dx == 0 and dy == 0) and distance is 0, the condition abs(dx) + abs(dy) >= distance evaluates to 0 >= 0 (true). This leads to a division by zero when calculating ratio. Adding a guard to return from immediately when distance <= 0 prevents this potential division by zero and makes the utility function more robust.
static odb::Point stepToward(const odb::Point& from,
const odb::Point& to,
const int distance)
{
if (distance <= 0) {
return from;
}
int dx = to.x() - from.x();
int dy = to.y() - from.y();
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
I've been looking at the CI failures and they are mostly noise amplifying (ie bad luck). |
With -rebuffer_size_driver, bestSlackWithDriver() and chooseTreeAndDriver() each timed every candidate tree with every candidate driver cell, and the trees planned per driver cell grow with the cell count. Each evaluation recomputed the driver's input slew and the previous stage's drive resistance, looked up the cell's arc, and walked the tree for its buffer leakage. Now the input slew and previous-stage drive resistance are cached per net and the equivalent arc per cell, each tree's buffer leakages are collected once, and a tree/cell slack and a cell's side-load slack are computed on first use and shared by both passes. The leakage sum keeps its order, so results are unchanged. Global placement with -rebuffer_size_driver true on rapidus2hp (3_3_place_gp.odb bit-identical before and after): jpeg 7:09 -> 3:35 (master 1:20) cva6 5:15 -> 3:34 (master 2:12) hercules_idecode 19:13 -> 10:34 (master 4:42) Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
Improves
fully_rebuffertoward minimum-delay buffering, measured against thebuffer_varying_lengthsreference harness (openroad/rsz/test/rebuffer_reference/) on Nangate45 and asap7, with the driver fixed and with-rebuffer_size_driver. Each commit message gives its own results.Commits
buffer_varying_lengths_size_driver. The test locked its drivers, so driver sizing could never resize them.fully_rebufferwith sizing leaves 445 max capacitance violations on black_parrot and 19 on swerv_wrapper; with this commit, none.buffer_varying_lengthstests and references; PDK settings move tobuffer_varying_lengths_pdk.tcl.Results
Gap to the reference, mean / worst:
"Before" is master (for asap7, master with the tests of commit 7).
fully_rebufferalone on placed designs, sizing on: swerv_wrapper (asap7) TNS -284 -> -83 ps; black_parrot (Nangate45, 4.5 ns) TNS -655 -> -504 ns, failing endpoints 3616 -> 1761, max capacitance violations 445 -> 2 (2 before rebuffering). With sizing off, commit 9 costs black_parrot 21 ns of TNS (-720 -> -741 ns) while improving the reference gaps and swerv_wrapper. Runtime changes are within +8% per commit; see the commit messages. sky130hs/gcd passes through CTS.repair_timing -setupis unchanged on gcd, swerv_wrapper, and black_parrot.Golden updates follow from the rebuffer changes: the
buffer_varying_lengthstests,rebuffer_size_driver*, and, through therepair_timingrebuffer move,clone_flat,repair_fanout7*,repair_fanout8*,repair_setup2*,repair_setup_invalid_phase, andrepair_setup_path4; and, through timing-driven placement (commit 8), the gpl testssimple01-td-repair,simple01-td-scan-net, andsimple01-vcts-clamp.