[VPR][Pack] Breaking Ties When Placing Primitives #3118
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.
Description
In the packer, when attempting to place a primitive block within a cluster, the algorithm iterates over all compatible blocks, assigns a cost to each, and selects the one with the lowest cost.
If multiple blocks have the same lowest cost, the current behavior is to choose the one that appears more frequently in the cluster. However, there is no further mechanism to break ties when the frequency is also the same.
Since the list being iterated over is an unordered map, the iteration order can change depending on the order of blocks or modes in the architecture file. This means that even adding a new mode (which may not be used by the netlist) or simply reordering existing modes can impact the packing results.
In this PR, I resolve this by using the hierarchical block name (which is unique for each primitive within a cluster) as a tie-breaker. This ensures consistent packing results even when new modes are added or the mode order is modified.