Merged
Conversation
fb822e6 to
b5484d2
Compare
b5484d2 to
ee9509e
Compare
b5e30ae to
7ef49f5
Compare
4 tasks
exopoiesis
pushed a commit
to exopoiesis/COSMA
that referenced
this pull request
Apr 7, 2026
…al_multiply_cpu When beta=0, the BLAS specification states that matrix C may be uninitialized and its contents must not be read. COSMA violated this in two places: 1. multiply.cpp split_k path: iterations K>0 set beta=1 to accumulate partial results, but the C buffer from the memory pool was never initialized. With NaN/Inf in uninitialized memory, this produces garbage results (0*NaN=NaN per IEEE 754, and 1*NaN=NaN for K>0). 2. local_multiply_cpu: `Cvalue *= beta` reads C even when beta=0. Per IEEE 754, 0.0 * NaN = NaN, so this corrupts the output. Fix: (1) zero-fill C before the split_k loop when beta=0 and divisor>1, (2) use conditional assignment in local_multiply_cpu. Add regression tests (BetaZero/FloatUninitialized, DoubleUninitialized) that fill C with NaN and verify beta=0 produces correct, NaN-free results. Found while debugging sporadic segfaults in CP2K AIMD with GPU-accelerated COSMA (parallel_gemm called with beta=0 from make_basis_lowdin). PR eth-cscs#159 (v2.8.0) partially addressed this in multiply_using_layout but did not cover the internal split_k accumulation or local_multiply_cpu. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Ref #158
Accept unitialized matrix C for case beta==0, fill with zeros on entry to call to
multiplyNeed to wait for a new release of COSTA, with a routine to fill matrix with given value.