Skip to content

dpl: prune negotiation site search with diamond-order branch and bound#10949

Merged
maliberty merged 4 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:dpl-negotiation-early-exit
Jul 19, 2026
Merged

dpl: prune negotiation site search with diamond-order branch and bound#10949
maliberty merged 4 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:dpl-negotiation-early-exit

Conversation

@maliberty

Copy link
Copy Markdown
Member

Motivation

For designs that are not hard to legalize, the old diamond search wins on runtime because it stops at the first acceptable location, while findBestLocation scores every site in its search window before picking one. This PR gives the negotiation legalizer the same early-exit property without giving up its cost model: the full window effort is only spent where sites are actually contended.

Approach

findBestLocation now visits the init-position window in wavefronts of increasing Manhattan displacement (the diamond-search order) and stops once the next wavefront's displacement cost plus a congestion floor exceeds the incumbent cost. targetCost is monotone in displacement and the congestion/DRC terms are non-negative, so no remaining candidate can win or tie: the pruning is lossless, not heuristic. The floor is width * height, valid because pixel capacity is 0/1 and hist_cost only grows from 1.0, and it makes the bound stop the scan right after the first overlap/DRC-free location.

Supporting changes:

  • Per-candidate O(1) lower-bound prune in tryLocation (before the isValidRow site-orientation lookup), and the DRC count is skipped for candidates that already lose on displacement + congestion.
  • Cost ties are broken by the row-major rank the exhaustive scan would visit candidates in, so the chosen location is identical to the exhaustive scan. All dpl tests pass against unchanged golden files.
  • The abort_bound checks in negotiationCost (from dpl: runtime improvements #10936) are changed from >= to strict >: partial sums only grow, so a candidate whose true cost is <= the bound is never aborted and ties return exact values, which the rank tie-breaking requires. Costs at most one extra pixel per aborted candidate; documented above the function.
  • targetCost is split so targetCostFromDisp can bound a wavefront before any concrete candidate exists.
  • The current-position window keeps its full scan (targetCost is anchored at the init position, so no wavefront bound applies there) but benefits from the O(1) prune.

Results

Identical placements to master on the full dpl suite (120/120 on unchanged goldens).

detailed_placement wall time vs master (which already includes the #10936 runtime improvements), 3 runs each:

design master this PR speedup
ibex (easy) 1.12 s 0.42 s 2.7x
aes (easy) 0.62 s 0.20 s 3.1x
cell_on_block2 (contended) 0.80 s 0.74 s ~7%

The gain concentrates on easy designs because the wavefront bound stops enumerating candidates entirely, while the #10936 in-loop abort already covers most of the pruning in contended windows.

findBestLocation scanned every site in the search window before picking
one, while the old diamond search stops at the first acceptable location
and easily wins on runtime for designs that are not hard to legalize.

Visit the init-position window in wavefronts of increasing Manhattan
displacement (the diamond-search order) and stop once the displacement
cost of the next wavefront, plus a congestion floor of width * height
(every placeable pixel contributes at least 1.0 to negotiationCost),
exceeds the incumbent cost. Since targetCost is monotone in displacement
and the congestion/DRC terms are non-negative, no remaining candidate can
win, so the pruning is lossless. In an uncontended region the scan ends
right after the first overlap/DRC-free location; under contention the
bound never triggers and the full window is searched, where the effort
is justified.

The current-position window keeps its full scan (targetCost is anchored
at the init position, so no wavefront bound applies) but candidates are
now pruned in O(1) by the same lower bound, and the DRC count - the most
expensive term - is skipped for candidates that already lose on
displacement plus congestion.

Cost ties are broken by the row-major rank the plain scan would visit
candidates in, so results are identical to the exhaustive search; all
dpl regression tests pass against unchanged golden files.

detailed_placement runtime (Nangate45/sky130hd test designs):
  ibex (easy):                3.19s -> 0.55s  (5.8x)
  aes (easy):                 2.02s -> 0.29s  (6.9x)
  cell_on_block2 (contended): 1.79s -> 0.84s  (2.1x)

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
…ly-exit

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
…ly-exit

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>

# Conflicts:
#	src/dpl/src/NegotiationLegalizerPass.cpp
@maliberty maliberty self-assigned this Jul 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 optimizes the candidate location search in NegotiationLegalizer::findBestLocation by implementing a wavefront-based diamond search with branch-and-bound pruning, a congestion floor, and a scan rank tie-breaking mechanism. Feedback suggests a further performance optimization in tryLocation to prune early on cost ties with a worse rank, avoiding expensive DRC violation checks.

Comment thread src/dpl/src/NegotiationLegalizerPass.cpp Outdated
A candidate whose displacement + congestion cost exactly ties the
incumbent cannot win unless its scan rank is smaller: the DRC term only
adds cost, so a nonzero count disqualifies it and a zero count leaves a
tie the rank comparison rejects. Return before countDRCViolations - the
most expensive term - in that case. Exact pre-DRC ties are common in
uncontended regions (free sites at equal displacement over uniform
history), and wavefront visit order equals rank order, so every tie
after the first in a wavefront now skips its DRC evaluation.

Addresses review feedback on the pull request.

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
@maliberty
maliberty marked this pull request as ready for review July 19, 2026 03:17
@maliberty
maliberty requested a review from a team as a code owner July 19, 2026 03:17
@maliberty
maliberty requested a review from gudeh July 19, 2026 03:17
@maliberty

Copy link
Copy Markdown
Member Author

@gudeh I had Fable code up the idea I suggested to you.

@maliberty

Copy link
Copy Markdown
Member Author

@codex review

@maliberty

Copy link
Copy Markdown
Member Author

@QuantamHD @mikesinouye FYI

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 31f478ce2f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@maliberty

Copy link
Copy Markdown
Member Author

secure CI passes

@maliberty
maliberty merged commit 566a2df into The-OpenROAD-Project:master Jul 19, 2026
16 checks passed
@maliberty
maliberty deleted the dpl-negotiation-early-exit branch July 19, 2026 06:07
@gudeh gudeh mentioned this pull request Jul 20, 2026
4 tasks
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