Repository navigation
Add portable applyMMat fallback for OpenBLAS and other BLAS vendors - #15
Merged
Merged
Conversation
applyMMat only performed the multiplication for ACML, MKL, and Apple BLAS. With OpenBLAS (the default, and what Linux CI uses), the function did nothing while __LAU was still defined, so callers read uninitialized output buffers and PBSAM produced NaN or ~1e306 energies. Add a column-major fallback used when no vendor-specific branch applies, and a unit test that fails without it. Co-authored-by: Copilot <[email protected]> Copilot-Session: 3eaf20ea-3ac0-4701-958f-28527bf641fc
sobolevnrm
pushed a commit
to Electrostatics/apbs
that referenced
this pull request
Oct 25, 2026
pb_solvers 8d254e5 makes PBSAM's matrix multiply work with OpenBLAS (Electrostatics/pb_solvers#15), which fixes the Linux PBSAM results. Refs #321 Co-authored-by: Copilot <[email protected]> Copilot-Session: 3eaf20ea-3ac0-4701-958f-28527bf641fc
sobolevnrm
added a commit
to Electrostatics/apbs
that referenced
this pull request
Oct 26, 2026
* Fix PBAM/PBSAM regression tests and test them in CI Restore the salt concentrations that were commented out in 2021, replace the obsolete pbsam-auto keyword with pbsam, and update the PBSAM reference energies for the solvent-dielectric scaling that pb_solvers 5671943 (2017) applied to energies to match forces. Add a PR-triggered Linux job that builds with PBAM/PBSAM enabled and runs their regression tests. Refs #321 Co-authored-by: Copilot <[email protected]> Copilot-Session: 3eaf20ea-3ac0-4701-958f-28527bf641fc * Fix out-of-bounds read in PBAM/PBSAM write parsing NOsh_parsePBAM and NOsh_parsePBSAM read writefmt[numwrite - 1] and writestem[numwrite - 1] even when the input had no write statement, indexing element -1. Only check the write format when a write exists. Refs #321 Co-authored-by: Copilot <[email protected]> Copilot-Session: 3eaf20ea-3ac0-4701-958f-28527bf641fc * Pin pb_solvers with the BaseSystem type-count fix pb_solvers cef00d7 fixes a heap-buffer-overflow in BaseSystem that made PBSAM results platform dependent (Electrostatics/pb_solvers#14). Refs #321 Co-authored-by: Copilot <[email protected]> Copilot-Session: 3eaf20ea-3ac0-4701-958f-28527bf641fc * Pin pb_solvers with the OpenBLAS applyMMat fix pb_solvers 8d254e5 makes PBSAM's matrix multiply work with OpenBLAS (Electrostatics/pb_solvers#15), which fixes the Linux PBSAM results. Refs #321 Co-authored-by: Copilot <[email protected]> Copilot-Session: 3eaf20ea-3ac0-4701-958f-28527bf641fc --------- Co-authored-by: Nathan Baker <[email protected]> Co-authored-by: Copilot <[email protected]> Copilot-Session: 3eaf20ea-3ac0-4701-958f-28527bf641fc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Makes PBSAM work with OpenBLAS (and any BLAS vendor other than ACML, MKL, or Apple) by adding a portable fallback to
applyMMat.Problem
applyMMatinpbsam/src/Solvmat.cppcomputesY = alpha*A*X + beta*Yonly inside#ifdef __ACML,#ifdef __MKL, or#if defined(__MACOS) || defined(__XCODE).cmake/Dependencies.cmakedefines none of those for OpenBLAS, the default vendor, but always defines__LAU.So on OpenBLAS builds,
applyMMatdoes nothing, and callers inSolvmat.cppandGradsolvmat.cppread uninitializednew double[]buffers.Effects:
pbsamon the APBS gly example gives NaN energies and forces with OpenBLAS, and the correct values with Apple Accelerate.applyMMat, so pb_solvers CI stayed green on Ubuntu.Fix
It does not read
Ywhenbetais zero, because callers pass uninitialized output buffers.SolverUTest.ApplyMMat, which fails without the fix on OpenBLAS.Testing
On macOS with both
-DBLA_VENDOR=Appleand-DBLA_VENDOR=OpenBLAS(Homebrew):pbsamtest(103 tests, including the new one) andpbamtest(160 tests) pass.pbsamon the APBS gly pair gives identical energies and forces with both vendors (0.00494129 and 0.00496847 kT) and similar runtime (about 1 s).