Skip to content

Comments

DPL: Remove the use of unordered_set in searchNearestSite#8248

Open
calewis wants to merge 5 commits intoThe-OpenROAD-Project:masterfrom
calewis:remove_unordered_set
Open

DPL: Remove the use of unordered_set in searchNearestSite#8248
calewis wants to merge 5 commits intoThe-OpenROAD-Project:masterfrom
calewis:remove_unordered_set

Conversation

@calewis
Copy link
Contributor

@calewis calewis commented Sep 5, 2025

By carefully picking which direction nodes can expand we can avoid needing to keep track of already visited nodes. This avoids the overhead of keeping track of where we've already visited.

Also a minor optimization of not adding the center to the PQ, if the center is a match we can exit early and avoid PQ construction.

The expansion strategy goes as follows:

The center naturally expands in all 4 directions.

Nodes in the same column as the center expand in 3 directions

  • Up for nodes above the row of the center
  • Down for nodes below the row of the center
  • Left and right

Assume we are on the y-axis above the center, then we know the only way we could have reached this point is from below so we don't need to add our neighbor below us to the queue, opposite goes for the y-axis nodes below the center, they don't need to add the node directly above them.

Finally we get to off center off y-axis nodes, expanding only to the left or right.

Because we are expanding on a structured grid instead of an arbitrary graph we can avoid keeping track of visited nodes saving us the overhead of using the unordered_set.

By carefully picking which direction nodes can expand we can avoid
needing to keep track of already visited nodes.  This avoids the
overhead of keeping track of where we've already visited.

Signed-off-by: Drew Lewis <cannada@google.com>
Signed-off-by: Drew Lewis <cannada@google.com>
@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2025

clang-tidy review says "All clean, LGTM! 👍"

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2025

clang-tidy review says "All clean, LGTM! 👍"

@maliberty maliberty enabled auto-merge September 5, 2025 15:58
@maliberty
Copy link
Member

test failures need addressing

Signed-off-by: Drew Lewis <cannada@google.com>
auto-merge was automatically disabled September 8, 2025 22:50

Head branch was pushed to by a user without write access

@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2025

clang-tidy review says "All clean, LGTM! 👍"

Signed-off-by: Drew Lewis <cannada@google.com>
@calewis calewis force-pushed the remove_unordered_set branch from 15fa584 to 0ff4613 Compare September 8, 2025 23:09
@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2025

clang-tidy review says "All clean, LGTM! 👍"

@maliberty
Copy link
Member

I thought the goal here is to do the same search as would have done previously with better efficiency. From the test failures it is apparent that we are not. Is it possible to make this equivalent and avoid the need to do a big validation cycle?

@maliberty
Copy link
Member

(Also DCO needs fixing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants