-
Notifications
You must be signed in to change notification settings - Fork 422
[AP][MassLegalizer] Resolved Issues in Partitioner #3199
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
[AP][MassLegalizer] Resolved Issues in Partitioner #3199
Conversation
Found some low-hanging fruit in the partial legalizer regarding how we merge the windows and how we partition the blocks. I found that the windows were not being fully merged (i.e. there still existed overlap between windows). I updated the algorithm to iteratively retry to merge if the bounding box of the window changes. To maintain good performance, I added a spatial lookup to narrow down the region where overlap can occur. The partitioning of blocks had a major bug in it where it was not actually moving blocks over most of the time. This was causing the partial legalizer to struggle to resolve of a legal solution. To resolve this, I completely rewrote the partitioning algorithm to make it more stable. The new algorithm starts by putting the blocks on the side they want (if their solved position is on the left of the partition, the will go into the left partition). It then moves the blocks closest to the partition line until the overfill of both partitions is as balanced as can be. These two optimizations together seem to have improved WL by around 2% and CPD by around 1%.
Results on Titan compared to Baseline AP (no fixed blocks):
Overall a healthy improvement across the board. This shows that the full legalizer is doing its job well, since improving the partial legalizer improved the overall QoR. |
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.
A few possible changes and a commenting clarification (or maybe a change to xmax behaviour, depending on what the answer is).
// Get the lower and upper bounds in the spatial lookup. This will | ||
// give a list of all windows which could possibly overlap right now | ||
// (at least in the x dimension). | ||
// NOTE: There may be diplicates; but thats ok since these checks |
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.
diplicates -> duplicates
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.
Why don't you inert region.xmax into the map, and make upper a function of region.xmax, instead of using region.xmax-1 on both insertion and checking for the bound? Aren't the regions inclusive where they include their xmax too?
If there's a reason you're not including the xmax boundary you should comment what it is.
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.
Ill improve the comments. It is correct to subtract the 1 here. You are correct that the regions are inclusive (they spill right over to the crust from xmin to xmax); however we do not consider two windows to overlap if the xmax of one window is the same as the xmin of another window (i.e. they are touching on one side). Hence, for this map, we can exclude searching for any windows that begin at the xmax coordinate since we do not care if any windows are found there.
Thinking about this more though, this only works if the windows are always at integer locations (which they are right now, but I would like to keep this general if I can). So really this should be xmax - epsilon, where epsilon is some reasonably small number.
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.
This was a really good point. Looking at my code, this was very unclear. I have used a more general way of handling this which is much better now. We now exclude the border from being included in this map.
Made the window merging boundary condition a bit more obvious. Outlined common code into helper methods.
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.
LGTM. Just one typo ...
Found some low-hanging fruit in the partial legalizer regarding how we merge the windows and how we partition the blocks.
I found that the windows were not being fully merged (i.e. there still existed overlap between windows). I updated the algorithm to iteratively retry to merge if the bounding box of the window changes. To maintain good performance, I added a spatial lookup to narrow down the region where overlap can occur.
The partitioning of blocks had a major bug in it where it was not actually moving blocks over most of the time. This was causing the partial legalizer to struggle to resolve of a legal solution. To resolve this, I completely rewrote the partitioning algorithm to make it more stable. The new algorithm starts by putting the blocks on the side they want (if their solved position is on the left of the partition, the will go into the left partition). It then moves the blocks closest to the partition line until the overfill of both partitions is as balanced as can be.
These two optimizations together seem to have improved WL by around 2% and CPD by around 1%.