TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Creating invariant floating-point accumulators

40 pointsby Pathogen-David9 months ago

6 comments

boulos9 months ago
This seems to keep coming up, and I see confusion in the comments. There is a standard: IEEE 754-2008. There are <i>additional</i> things people add like approximate reciprocals and approximate sqrt. But if you don&#x27;t use those, and you don&#x27;t make an association error, you get consistent results.<p>The question here with association for summation is what you want to match. OP chose to match the <i>scalar</i> for-loop equivalent. You can just as easily make an 8-wide or 16-wide &quot;virtual vector&quot; and use that instead.<p>I suspect that an 8-wide virtual vector is the right <i>default</i> for people currently, since systems since Haswell support it, all recent AMD, and if you&#x27;re using vectorization, you can afford to pay some overhead on Arm with a double-width virtual vector. You don&#x27;t often gain enough from AVX512 to make the default 16-wide, but if you wanted to focus on Skylake+ (really Cascadelake+) or Genoa+ systems, it would be a fine choice.
评论 #41439593 未加载
评论 #41441183 未加载
kardos9 months ago
Exact floating point accumulating is more or less solved with xsum [1] -- would it work in this context?<p>[1] <a href="https:&#x2F;&#x2F;gitlab.com&#x2F;radfordneal&#x2F;xsum" rel="nofollow">https:&#x2F;&#x2F;gitlab.com&#x2F;radfordneal&#x2F;xsum</a>
评论 #41441127 未加载
waynecochran9 months ago
Invariance w floating point arithmetic seems like a fool&#x27;s errand. If the numbers one is working with are roughly on the same order of magnitude than I would consider integer &#x2F; fixed point instead. You get the same results in this case (as long as you are careful).
someguydave9 months ago
Seems crazy to try to paper over hardware implementation differences in software. Some org should be standardizing floating point intrinsics
评论 #41442445 未加载
baq9 months ago
see also streflop (2006)<p><a href="https:&#x2F;&#x2F;nicolas.brodu.net&#x2F;en&#x2F;programmation&#x2F;streflop&#x2F;" rel="nofollow">https:&#x2F;&#x2F;nicolas.brodu.net&#x2F;en&#x2F;programmation&#x2F;streflop&#x2F;</a>
modulovalue9 months ago
I&#x27;m still wondering if there could exist an alternative world where efficient addition over decimal numbers that we developers use on a day to day basis is associative. Is that even possible or is there perhaps some fundamental limit that forces us to trade associativity for performance?<p>It seems to me that non associative floating point operations force us into a local maximum. The operation itself might be efficient on modern machines, but could it be preventing us from applying other important high level optimizations to our programs due to its lack of associativity? A richer algebraic structure should always be amenable to a richer set of potential optimizations.<p>---<p>I&#x27;ve asked a question that is very much related to that topic on the programming language subreddit:<p>&quot;Could numerical operations be optimized by using algebraic properties that are not present in floating point operations but in numbers that have infinite precision?&quot;<p><a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;ProgrammingLanguages&#x2F;comments&#x2F;145kps7&#x2F;could_numerical_operations_be_optimized_by_using&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;ProgrammingLanguages&#x2F;comments&#x2F;145kp...</a><p>The responses there might be interesting to some people here.
评论 #41434840 未加载
评论 #41440081 未加载
评论 #41435340 未加载
评论 #41435084 未加载