Skip to content

mpl: Fixes MPL-45 can't split cluster error#10520

Open
QuantamHD wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
QuantamHD:mpl_large_macro_small_std_cell
Open

mpl: Fixes MPL-45 can't split cluster error#10520
QuantamHD wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
QuantamHD:mpl_large_macro_small_std_cell

Conversation

@QuantamHD
Copy link
Copy Markdown
Collaborator

This error seems to occur when you have a macro dominated block with just a few standard cells. Added a test case that I validated failed with HEAD and passes with my change.

Verification

  • [ x ] I have verified that the local build succeeds (./etc/Build.sh).
  • [ x ] I have run the relevant tests and they pass.
  • [ x ] My code follows the repository's formatting guidelines.
  • [ x ] I have included tests to prevent regressions.
  • [ x ] I have signed my commits (DCO).

@QuantamHD QuantamHD requested a review from a team as a code owner May 27, 2026 00:42
@QuantamHD QuantamHD requested a review from joaomai May 27, 2026 00:42
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a "Rocks vs Sand Check" in the clustering engine to detect when a single macro dominates the total standard cell area. When macro domination is detected, macro weights are dynamically normalized to the average standard cell area to prevent knapsack partition failures. A new test case mpl_dominated has been added to verify this behavior. The reviewer identified a critical bug where macro-only clusters (with zero standard cells) would incorrectly trigger this domination logic, leading to suboptimal weight normalization. A code suggestion was provided to ensure standard cells are present before flagging macro domination.

// 2. The Rocks vs Sand Check
// If a single macro dwarfs the entire standard cell cloud, area-balancing
// is structurally impossible against a min-cut objective.
const bool discrete_macro_domination = (max_macro_area > total_std_cell_area);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

If there are no standard cells in the cluster (num_std_cells == 0), total_std_cell_area will be 0.0f. If there is at least one macro, max_macro_area will be greater than 0.0f, which makes discrete_macro_domination evaluate to true.

This triggers macro weight normalization to 1.0f (since avg_std_cell_area defaults to 1.0f when num_std_cells == 0). For a macro-only cluster, normalizing all macro weights to 1.0f prevents the partitioner from balancing the actual physical areas of the macros, leading to poor partitioning results.

We should only consider the cluster macro-dominated if there are actually standard cells present to be balanced against.

Suggested change
const bool discrete_macro_domination = (max_macro_area > total_std_cell_area);
const bool discrete_macro_domination = (num_std_cells > 0) && (max_macro_area > total_std_cell_area);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a block contains only macros this method is never called.

@QuantamHD QuantamHD force-pushed the mpl_large_macro_small_std_cell branch from 98cc178 to 72e3e19 Compare May 27, 2026 00:54
@QuantamHD
Copy link
Copy Markdown
Collaborator Author

The review dog clang tidy seems to not be posting comments

This error seems to occur when you have a macro dominated
block with just a few standard cells. Added a test case
that I validated failed with HEAD and passes with my change.

B:513351985
Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>

clang-format

Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
@joaomai
Copy link
Copy Markdown
Contributor

joaomai commented May 29, 2026

What's your opinion on simply splitting the cluster into [giant_macro, everyting else] when there's a macro that area is more than half of the total area of a given cluster (and checking if everyting else still is a large cluster). Could you test this approach on your failing design?

I did some testing on the current behavior of TritonPart using the mpl_dominated testcase provided and it seems like it is basically random once we have the 1 macro with 20 std cells cluster: changing the seed when a solution is fully unbalanced "solves the issue" after some retries.

Also, I think something more descriptive like macro_dominated_break_cluster for the test name works best.

@QuantamHD
Copy link
Copy Markdown
Collaborator Author

QuantamHD commented May 29, 2026

In my prod design it's six identical macros of roughly 1 million cells and 90,000 cells connecting them. Would your proposed solution work for something like that? My worry with the 50% check is that it wouldn't trigger when we have many macros, but only a small standard cell area.

Also I could use a pointer on the mechanics of implementing what you suggested. Where should I put that code?

@joaomai
Copy link
Copy Markdown
Contributor

joaomai commented Jun 2, 2026

@QuantamHD
Can you try the approach from PR #10581? It uses the idea I mentioned above.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants