Improve region intersect function #1778
Merged
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.
The intersection function belonging to the Region class was modified to also consider cases where one region has no subtile specified and the other region has a subtile specified.
Description
Previously, the region intersection function would only calculate the intersection when the two regions passed in both had no subtiles specified, or both had the same subtiles specified. However, this meant that the routine would miss out on some cases.
For example, if region r1 was constrained from region (0,0) to (10,10) with subtile 0 specified, and region r2 was constrained from region (0,0) to (10,10) with no subtile specified, the previous intersection function would say that there is no intersection between these two regions. The new intersection function would return (0,0) to (10,10) with subtile 0 as the intersection between r1 and r2.
Related Issue
This pull request is related to adding floorplanning placement constraints to VPR, as described in this issue #932
Motivation and Context
The missing of some intersecting regions becomes an issue especially when trying to intersect a region with the grid dimensions, to ensure that the region does not fall outside of the grid dimensions. If a PartitionRegion is created to match grid dimensions, it does not have a subtile specified since different areas of the grid can have different subtile dimensions. If a region with subtile specified is intersected with the grid PartitionRegion, the old Region intersection will return no intersection, even when the region is within the grid dimensions. The new Region intersection function solves this problem.
Another thing that should be considered is whether there is a way to check that the subtile dimensions of the region are within the subtile dimensions of the grid at the specified x, y values.