dpl: prune negotiation site search with diamond-order branch and bound#10949
Conversation
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
There was a problem hiding this comment.
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.
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>
|
@gudeh I had Fable code up the idea I suggested to you. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
secure CI passes |
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
findBestLocationscores 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
findBestLocationnow 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.targetCostis 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 iswidth * height, valid because pixel capacity is 0/1 andhist_costonly grows from 1.0, and it makes the bound stop the scan right after the first overlap/DRC-free location.Supporting changes:
tryLocation(before theisValidRowsite-orientation lookup), and the DRC count is skipped for candidates that already lose on displacement + congestion.abort_boundchecks innegotiationCost(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.targetCostis split sotargetCostFromDispcan bound a wavefront before any concrete candidate exists.targetCostis 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_placementwall time vs master (which already includes the #10936 runtime improvements), 3 runs each: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.