Skip to content

gpl: replace BiCGSTAB with double-prec ConjugateGradient in InitialPlace - #12397

Open
mikesinouye wants to merge 4 commits into
The-OpenROAD-Project:masterfrom
mikesinouye:gpl
Open

mikesinouye wants to merge 4 commits into
The-OpenROAD-Project:masterfrom
mikesinouye:gpl

Conversation

@mikesinouye

Copy link
Copy Markdown
Contributor

Summary

For designs that have no PLACED or FIXED pins or instances, the matrix for InitialPlace is singular. The cells are all clumped at the origin without anything pulling them outward. This happens in practice when using the new global_placement -place_ios mode. In certain designs, when UBSan is enabled, this causes a crashe as we have failing float/int casts. This is because the existing BiCGSTAB solver handles this case poorly, producing coords exceeding int max.

If InitialPlace can complete, core Nesterov is able to spread the cells even if all cells remain overlapping at the center (effectively no InitialPlace), so this issue does not actually cause QoR issues for most designs in -c opt.

This PR replaces the BiCGSTAB solver with a double-precision ConjugateGradient solver to address the issue. The PR also tightens the conditional check to prevent cases like these and add a test.

Type of Change

  • Bug fix

Impact

Prevents crashes in fastbuild for designs using global_placement -place_ios.

Verification

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

Signed-off-by: Mike Inouye <mikeinouye@google.com>
Signed-off-by: Mike Inouye <mikeinouye@google.com>
@mikesinouye
mikesinouye requested review from a team as code owners November 20, 2026 02:54
@mikesinouye

Copy link
Copy Markdown
Contributor Author

Hi @calewis , would you mind reviewing this PR (again? 🙂)

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

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.

Code Review

This pull request replaces the BiCGSTAB solver with a Conjugate Gradient solver using double-precision arithmetic and regularization, updates coordinate clamping to handle non-finite values before float-to-int conversion, and adds a test for unanchored initial placement. Feedback suggests avoiding potential dangling reference issues in the custom clamp lambda by using direct comparisons instead of std::clamp with mixed types, and improving solver efficiency by modifying diagonal elements in-place rather than performing sparse matrix addition.

Comment thread openroad/gpl/src/initialPlace.cpp Resolved
Comment thread openroad/gpl/src/solver.cpp Resolved
Signed-off-by: Mike Inouye <mikeinouye@google.com>
@gudeh

gudeh commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Hi @mikesinouye, have you performed any experiments? I understand you may be more interested in solving an error more than improving QoR?

Signed-off-by: Mike Inouye <mikeinouye@google.com>

@calewis calewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A bit hacky for something that needs redoing but should be okay IMO. LGTM.

}

if (std::isnan(error.x) || std::isnan(error.y)) {
if (!std::isfinite(error.x) || !std::isfinite(error.y)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we just check inf and nan?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Aren't those the same? but isfinite() is a single conditional

@mikesinouye

Copy link
Copy Markdown
Contributor Author

Hi @mikesinouye, have you performed any experiments? I understand you may be more interested in solving an error more than improving QoR?

For our internal designs and PDK, the results were not affected beyond the noise threshold. You are correct, the intent here is the crash fix by using a more suited solver, than improving QoR.

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.

3 participants