[issue29282] Fused multiply-add: proposal to add math.fma()

Mark Dickinson report at bugs.python.org
Wed Feb 21 04:12:24 EST 2018


Mark Dickinson <dickinsm at gmail.com> added the comment:

> Is this because of the inf/NaN discrimination hiccups [...]

No, more than that. If it were just that, we could work around it by adding the appropriate special case handling before calling the libm fma (as has been done, reluctantly, with some of the other math module functions; see the source for math.pow, for example).

But the fma implementation on Windows is fundamentally broken. For finite numbers, it simply doesn't give what it's supposed to (a * b + c, computed with a _single_ rounding). Since that single rounding is most of the point of fma, that makes the libm fma not fit for purpose on Windows.

It _is_ possible, with care, to code up a not-too-inefficient fma emulation using clever tricks like Veltkamp splitting and Dekker multiplication. I have half such an implementation sitting on my home computer, but so far have not had the cycles to finish it (and it's not high on the priority list right now).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue29282>
_______________________________________


More information about the Python-bugs-list mailing list