TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Creating invariant floating-point accumulators

40 点作者 Pathogen-David9 个月前

6 条评论

boulos8 个月前
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 未加载
kardos8 个月前
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 未加载
waynecochran8 个月前
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).
someguydave8 个月前
Seems crazy to try to paper over hardware implementation differences in software. Some org should be standardizing floating point intrinsics
评论 #41442445 未加载
baq8 个月前
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>
modulovalue8 个月前
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 未加载