[ https://issues.apache.org/jira/browse/LUCENE-9679?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17268895#comment-17268895 ]
Uwe Schindler commented on LUCENE-9679: --------------------------------------- Math.fma() is especially slow for doublearguments if the CPU does not support it. In that case the non-intrinsified version is using BigDecimal to work around the precision loss by the two double operations. A bit better is Math.fma() with float agruments, because it is casting everything to double first and rounding at end. Actually without CPU support it would round 3 times: 2 times with doubles (mul, add) and then at end again when converting double result to float. So with floats, using Math.fma would be an option and may improve a bit on Haswell(or alter) CPUs. But with doubles: never-ever! > Try using Math.fma to speed up vector computations > -------------------------------------------------- > > Key: LUCENE-9679 > URL: https://issues.apache.org/jira/browse/LUCENE-9679 > Project: Lucene - Core > Issue Type: Improvement > Reporter: Michael Sokolov > Priority: Major > > On the mailing list, Anton Hägerstrand <an...@blunders.io> posted a link to a > blog post showing hotspots in our indexing: > https://blunders.io/posts/lucene-bench-2021-01-10 and identified vecto dot > product computations as one of them. Not surprising in itself, but he also > suggested we might want to try using {{Math.fma}} in the computation to see > if it can optimize the multiply-and-add operation that is at the heart of > both the dot product and l2-norm distance. -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org