Conversation
The call is the last one to DCABS1 in the library, and it costs more than twice the loop it sits in unless the build uses LTO. Writing it out with the inner parentheses kept returns bit-identical results. That leaves SCABS1 and DCABS1 with no caller at all, so xBLAT1 gains a case of its own for each, and both say in their documentation that they are kept for the callers outside this library. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ACSimon33
force-pushed
the
blas-dzasum-inlines-dcabs1
branch
from
September 15, 2026 15:21
19d5602 to
4e5b091
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1421 +/- ##
=======================================
Coverage 69.36% 69.36%
=======================================
Files 6122 6122
Lines 486711 486725 +14
Branches 23268 23268
=======================================
+ Hits 337584 337601 +17
+ Misses 148689 148686 -3
Partials 438 438
Continue to review full report in Codecov by Harness.
|
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.
Description
DZASUMaccumulates withSTEMP = STEMP + DCABS1(ZX(I)). That is the last call toDCABS1anywhere in the library, and on a build without link-time optimization it is the whole cost of the loop: the helper lives in its own translation unit, so the compiler cannot inline it and the accumulation runs at one call per element. This PR writes the call out asSTEMP + (ABS(DBLE(ZX(I))) + ABS(DIMAG(ZX(I)))).The outer parentheses are important.
DCABS1adds the two parts to each other and returns one value, whichDZASUMthen folds intoSTEMP: one rounding for the pair and one into the accumulator. Parenthesised, the inline form does exactly that, so every resultDZASUMreturns is unchanged, bit for bit. Without the parentheses it would become(STEMP + |re|) + |im|, two roundings into the accumulator, which is the groupingSCASUMuses and a different answer.This PR replaces #1418, which went the other way: it made
SCASUMcallSCABS1and so movedSCASUMontoDZASUM's grouping, which changed 95% of its results by about 6.8 ulp.We keep
?CABS1for backwards compatibility and because basically all vendor BLAS libraries export it as well. I added a small test in the test suite to cover it.