-
Notifications
You must be signed in to change notification settings - Fork 867
dpl: fix topological sort cycle with multi-height cells in shift lega… #10137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Divinesoumyadip
wants to merge
3
commits into
The-OpenROAD-Project:master
Choose a base branch
from
Divinesoumyadip:fix/dpl-topological-sort-cycle
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+12
−1
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
dc6dc6d
dpl: fix topological sort cycle with multi-height cells in shift lega…
Divinesoumyadip 7b5d315
dpl: fix non-deterministic sort in compareNodesX with cell ID tie-bre…
Divinesoumyadip 39a00e7
dpl: fix clang-format braces warning in compareNodesX
Divinesoumyadip File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -265,7 +265,10 @@ class DetailedMgr | |||||||||
| // Needs cell centers. | ||||||||||
| bool operator()(Node* p, Node* q) const | ||||||||||
| { | ||||||||||
| return p->getCenterX() < q->getCenterX(); | ||||||||||
| if (p->getCenterX() != q->getCenterX()) { | ||||||||||
| return p->getCenterX() < q->getCenterX(); | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: statement should be inside braces [google-readability-braces-around-statements]
Suggested change
|
||||||||||
| } | ||||||||||
| return p->getId() < q->getId(); | ||||||||||
| } | ||||||||||
| bool operator()(Node*& s, DbuX i) const { return s->getCenterX() < i; } | ||||||||||
| bool operator()(DbuX i, Node*& s) const { return i < s->getCenterX(); } | ||||||||||
|
|
||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic introduced here to avoid cycles by only adding edges when both cells' bottom matches the current row's bottom is problematic for correctness. It effectively ignores dependency constraints between cells of different heights or cells that start at different rows.
For example, if a multi-height cell$M$ (spanning rows 0 and 1) is to the left of a single-height cell $S$ (in row 1), the edge $M \to S$ will never be added:
rowBottom(Row 1), so the edge is skipped.This lack of constraints can lead to overlaps during the shifting process, as the legalizer will not maintain the required relative ordering of these cells.
The root cause of the topological sort cycles is likely the non-deterministic sorting in
DetailedMgr::compareNodesX(indetailed_manager.h). When two cells have the same X center,std::sortmay produce different relative orders in different row segments, creating a cycle. A more robust fix would be to make the cell comparison deterministic by adding a tie-breaker, such as the cell ID:Additionally, note that this PR only modifies the first loop that builds the dependency graph for the topological sort check, but leaves the second loop in
ShiftLegalizer::shift(lines 273-282) unchanged. This inconsistency means theclumplogic will still operate on the original, potentially cyclic/inconsistent graph.References