gpl: vertically merge unusable site dummy instances - #11085
Conversation
OpenROAD creates a dummy Instance for every single row a blocked region intersects. On macro-heavy designs with extensive macro arrays or floorplan blockages, this generates tens of thousands of single-row dummy instances. During Nesterov global placement density calculations, iterating over these fragmented dummies causes an O(N * Bins) CPU time explosion. Vertically merge contiguous blocked site segments across rows into a single taller dummy instance and mark the merged site grid locations as SiteInfo::FixedInst so they are not double-processed. This reduces dummy instance count by orders of magnitude and drastically speeds up initial Nesterov iterations on macro-heavy designs. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
There was a problem hiding this comment.
Code Review
This pull request updates PlacerBase::initInstsForUnusableSites in src/gpl/src/placerBase.cpp to vertically merge adjacent blocked sites into a single larger dummy instance. The reviewer suggested a cleaner implementation that defers marking the grid until after the vertical merge search is complete, which simplifies the logic and avoids duplicating the grid marking loops.
Address review comment from gemini-code-assist by deferring grid marking until after the vertical merge search completes. Also format with clang-format to satisfy Clang-Format CI check. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces vertical merging logic for unusable sites in PlacerBase::initInstsForUnusableSites() to combine adjacent blocked sites vertically into larger dummy instances. The reviewer suggests optimizing and simplifying this merging logic by hoisting 1D index calculations out of the inner loops to avoid redundant multiplications and refactoring the loop control for better readability.
Hoist row base index calculations out of inner loops and replace the while loop with a standard for loop as recommended in review. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates PlacerBase::initInstsForUnusableSites to group blocked sites vertically across multiple rows, creating larger dummy gcells. The reviewer suggested simplifying the nested loops and manual flag management by utilizing standard library algorithms like std::all_of and std::fill to improve code readability and maintainability.
Use std::all_of and std::fill for cleaner, idiomatically C++ STL grid slice checks and updates as recommended in review. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request optimizes the handling of unusable sites in PlacerBase::initInstsForUnusableSites by merging vertically adjacent blocked sites into larger single dummy instances, rather than creating individual instances per row. The reviewer suggested using the explicit enum scope SiteInfo::Blocked instead of Blocked for consistency with SiteInfo::FixedInst and to improve robustness.
Use explicit SiteInfo::Blocked scope in lambda check for consistency with SiteInfo::FixedInst as suggested in code review. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates PlacerBase::initInstsForUnusableSites in src/gpl/src/placerBase.cpp to merge vertically contiguous blocked sites into a single larger dummy instance instead of creating individual instances per row. It scans vertically to find matching blocked spans, fills the grid with SiteInfo::FixedInst, and instantiates the merged cell. There are no review comments, so we have no feedback to provide.
Updates regression tests to match the new placement output with vertically merged dummy instances. Fixes The-OpenROAD-Project#11085 Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
|
@gudeh @maliberty Please retrigger: |
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
We only check the movable cells during The fixed instances (such as the dummy instances) are used in |
|
This has an enormous impact on runtime in my case, GPL simply gets stuck, why could that be? I have provided a confidential BYO openroad reproducer to @maliberty if the answer is in debugging this rather than code-analysis. |
|
@LucasYuki The reason this PR has such an enormous impact (and why GPL stalls without it) is due to the While you are correct that
By vertically merging the dummies, the blockage becomes a single, tall dummy instance. For the bins it overlaps, This avoids millions of expensive rectangle union operations, changing the initialization runtime from hours to a fraction of a second. |
|
@LucasYuki You raise two great points, but let me clarify the profiling data from our end because the stall did happen at initialization!
This change in density smoothing is what slightly alters the positioning results in the regression tests. It is mathematically cleaner (and infinitely faster) to treat a contiguous blockage as a single block rather than hundreds of fragmented slivers. |
|
In general I think the idea is good. |
Sounds good! I was just very confused by all this and having trouble separating concerns. |
|
@gudeh @osamahammad21 Do you need anything more from me? I've been stuck with gpl running for hours and I've been grinding down bugs and O(n^something) problems. This is the last big algorithmic improvement for the use-case/design I'm struggling with now near as I know. |
|
I think that I found the source of the changes. I isolated the source of the changes in a separate PR (#11123), and I'm running the secure PR for both (they should have the same results). |
|
@LucasYuki Sounds encouraging, but I'm not sure what it means for this PR. Does it mean that this PR is moot or that we need both? |
|
We need both. |
|
/gemini please suggest a change to resolve the conflicts, probably trivial |
|
As an AI, I don't have direct access to your local repository to see the specific conflict markers, but resolving them is usually straightforward. Please follow these steps:
If you can paste the content of the conflicting sections here, I would be happy to provide a specific code suggestion to resolve them! |
|
@LucasYuki can you take this off my hands? If you can't merge it, close it and re-create it with your own user? I'll ask the AI to merge with origin/master, but now it is picking up conflicts because time passes. Thanks! |
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
47b48ee to
8bbd249
Compare
|
@LucasYuki This used to work, now it doesn't anymore. Please carry this optimization forward at your leisure. @maliberty I've been kindling this fire for a while now... can you take it from here? |
|
I was a bit quick. This one is the algorithmic problem that would help us the most. There were some other improvements in gpl that are more incremental. This one affects a design I'm working on disproportionately. |
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
|
Updated the "working as implemented" .ok files after a merge gaffe. |
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
|
@gudeh please launch a secure CI for this and let's try to get it in soon. |
|
I remember trying to do this some time ago to attempt to remove instances from on top of macros and I recall not helping too much, I wasn't expecting for runtime improvements back then. I will try to investigate both the effect it has on removing instances from macros and the runtime. |
|
@gudeh @maliberty Can you fix it? I dont know what I am doing here and I dont have the test case. |
|
OFC! please don't worry about it, I will look into the fatal also, it's probably unrelated. |
😌 |
|
Talking to @LucasYuki he was working on this already. So I will leave for him to solve the issue. |
|
The fatal was identified in issue #11192. |


OpenROAD creates a dummy Instance for every single row a blocked region intersects. On macro-heavy designs (e.g. large RISC-V cores / MegaBoom-style configurations with large macro arrays) or complex floorplan blockages, this generates tens of thousands of single-row dummy instances if the chicken bones fall awkwardly.
During Nesterov global placement density calculations ($O(N \times \text{Bins})$ CPU time explosion that can stall global placement for hours.
updateBinsGCellDensityArea), iterating over these fragmented dummies causes anThis patch vertically merges contiguous blocked site segments across rows into a single taller dummy instance and marks the merged site grid locations as
SiteInfo::FixedInstso they are not double-processed. This reduces dummy instance count by orders of magnitude (e.g. from hundreds of thousands down to hundreds of instances) and drastically speeds up initial Nesterov iterations on macro-heavy designs.Signed-off-by: Øyvind Harboe oyvind.harboe@zylin.com