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

2021-06-19 Thread Mark Dickinson
Change by Mark Dickinson : -- assignee: mark.dickinson -> ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

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

2020-01-13 Thread Juraj Sukop
Juraj Sukop added the comment: FWIW, there is a new implementation of FMA [1] which is licensed very permissively [2]. Perhaps it could be used here as well..? [1] https://github.com/smasher164/fma [2] https://github.com/smasher164/fma/commit/4e85d2388c7d4d850be12df918f9431ca687f57a

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

2020-01-13 Thread STINNER Victor
STINNER Victor added the comment: > For Windows, you need to do much more than this: it's not just about handling > NaNs and infinities, it's about reimplementing the entire function from > scratch to give correctly rounded results. Without correctly-rounded results, > there's very little

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

2020-01-13 Thread Mark Dickinson
Mark Dickinson added the comment: Okay, looks like Windows is happy in the PR's continuous integration. If the buildbots are also happy, then I'm content to have this pushed through. -- ___ Python tracker

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

2020-01-13 Thread Mark Dickinson
Mark Dickinson added the comment: > If tests continue to fail on some platforms, I plan to manually handle NaN > and INF in the C code, before calling libc fma(). For Windows, you need to do much more than this: it's not just about handling NaNs and infinities, it's about reimplementing the

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

2020-01-13 Thread STINNER Victor
STINNER Victor added the comment: I converted https://hg.python.org/cpython/rev/b33012ef1417 written by Mark Dickinson into a GitHub PR: PR 17987. I still expect tests failures. I plan to use the PR as a starting point to implement math.fma(). If tests continue to fail on some platforms, I

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

2020-01-13 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +17391 stage: commit review -> patch review pull_request: https://github.com/python/cpython/pull/17987 ___ Python tracker ___

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

2020-01-12 Thread Steven D'Aprano
Change by Steven D'Aprano : -- nosy: +steven.daprano ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

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

2019-05-16 Thread Caleb Donovick
Change by Caleb Donovick : -- nosy: +donovick ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

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

2018-02-21 Thread Nico Schlömer
Nico Schlömer added the comment: Okay, thanks for the info. As a stop-gap measure, I've created pyfma [1, 2]. Install with ``` pip install pyfma ``` and use with ``` pyfma.fma(3.0, 2.0, 1.0) ``` Only works on Unix reliable then, but that's all I care about. :)

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

2018-02-21 Thread Mark Dickinson
Mark Dickinson 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,

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

2018-02-20 Thread Nico Schlömer
Nico Schlömer added the comment: > Existing libm implementations don't work, Okay. Is this because of the inf/NaN discrimination hiccups mentioned above or are there any other pitfalls? -- ___ Python tracker

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

2018-02-20 Thread Mark Dickinson
Mark Dickinson added the comment: > Do I read this thread correctly assuming that this hasn't been implemented > yet? Yes. Existing libm implementations don't work, so simply wrapping the libm function isn't enough. And writing an implementation from scratch is

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

2018-02-20 Thread Nico Schlömer
Nico Schlömer added the comment: Do I read this thread correctly assuming that this hasn't been implemented yet? If not, I would probably make my own little library for this -- I really need the feature for the precision. -- nosy: +nschloe

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

2017-01-24 Thread Eric Fahlgren
Changes by Eric Fahlgren : -- nosy: +eric.fahlgren ___ Python tracker ___ ___

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

2017-01-24 Thread Mark Dickinson
Mark Dickinson added the comment: The patch needs tests for the case where a*b overflows and c is infinite (either of the same sign as a*b or not). This combination should never return NaN, but a poor emulation of fma might do so. -- ___ Python

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

2017-01-21 Thread Mark Dickinson
Mark Dickinson added the comment: Also failures on Gentoo: here b is positive (possibly +inf), and c is finite, so we expect an infinite result. Instead, we're apparently getting a NaN. I don't have a good guess about what's causing this: the rest of the tests are passing, so it's unlikely

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

2017-01-21 Thread Roundup Robot
Roundup Robot added the comment: New changeset b5a5f13500b9 by Mark Dickinson in branch 'default': Issue #29282: Backed out changeset b33012ef1417 https://hg.python.org/cpython/rev/b5a5f13500b9 -- ___ Python tracker

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

2017-01-21 Thread Mark Dickinson
Mark Dickinson added the comment: Failures on the Windows buildbot (http://buildbot.python.org/all/builders/AMD64%20Windows8.1%20Non-Debug%203.x/builds/238/steps/test/logs/stdio) shown below. It looks as though Windows is emulating the FMA operation on this machine (and not doing a

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

2017-01-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Cross fingers... -- ___ Python tracker ___ ___ Python-bugs-list mailing

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

2017-01-21 Thread Roundup Robot
Roundup Robot added the comment: New changeset b33012ef1417 by Mark Dickinson in branch 'default': Issue #29282: add fused multiply-add function, math.fma. https://hg.python.org/cpython/rev/b33012ef1417 -- nosy: +python-dev ___ Python tracker

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

2017-01-19 Thread Mark Dickinson
Mark Dickinson added the comment: Thanks, Serhiy. I'm going to hold off committing this for 24 hours or so, because I want to follow the buildbots when I do (and I don't have time for that right now). I wouldn't be at all surprised to see platform-specific test failures. --

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

2017-01-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Then LGTM unconditionally. -- ___ Python tracker ___ ___ Python-bugs-list

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

2017-01-19 Thread Mark Dickinson
Mark Dickinson added the comment: Ah, the dev guide says 80 characters. (https://docs.python.org/devguide/documenting.html) -- ___ Python tracker ___

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

2017-01-19 Thread Mark Dickinson
Mark Dickinson added the comment: > lines in What's New are too long. Thanks. Fixed (I think). I'm not sure what the limit is, but the lines are now all <= 79 characters long. -- Added file: http://bugs.python.org/file46346/math_fma3.patch ___

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

2017-01-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: LGTM except that lines in What's New are too long. -- assignee: -> mark.dickinson stage: patch review -> commit review ___ Python tracker

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

2017-01-19 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- Removed message: http://bugs.python.org/msg285838 ___ Python tracker ___

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

2017-01-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Have you missed the patch? -- ___ Python tracker ___ ___ Python-bugs-list

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

2017-01-19 Thread Mark Dickinson
Mark Dickinson added the comment: Whoops; looks like I failed to attach the updated patch. Here it is. -- Added file: http://bugs.python.org/file46345/math_fma2.patch ___ Python tracker

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

2017-01-19 Thread Mark Dickinson
Mark Dickinson added the comment: Serhiy, Victor: thanks for the reviews. Here's a new patch. Differences w.r.t. the old one: - Converted to argument clinic. - Updated docstring to talk about special cases. - More tests, as suggested by Serhiy. - whatsnew entry and ..versionadded in docs.

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

2017-01-17 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: LGTM except that needed the versionadded directive and What's New entry. And maybe few additional tests. -- ___ Python tracker

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

2017-01-17 Thread Mark Dickinson
Changes by Mark Dickinson : -- stage: -> patch review ___ Python tracker ___ ___

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

2017-01-17 Thread Mark Dickinson
Mark Dickinson added the comment: And here's a patch. -- keywords: +patch Added file: http://bugs.python.org/file46321/math_fma.patch ___ Python tracker

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

2017-01-16 Thread Mark Dickinson
Mark Dickinson added the comment: Here's a pure Python reference implementation, with tests. -- Added file: http://bugs.python.org/file46304/fma_reference.py ___ Python tracker

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

2017-01-16 Thread Mark Dickinson
Mark Dickinson added the comment: > Isn't the behaviour of quiet NaNs kindof implementation-dependent already? Not as far as IEEE 754-2008 is concerned, and not as far as Python's math module is concerned, either: handling of special cases is, as far as I know, both consistent across

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

2017-01-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: Isn't the behaviour of quiet NaNs kindof implementation-dependent already? -- ___ Python tracker ___

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

2017-01-16 Thread Mark Dickinson
Mark Dickinson added the comment: An implementation note: IEEE 754-2008 leaves it to the implementation to decide whether FMA operations like: 0 * inf + nan and inf * 0 + nan (where nan represents a quiet NaN and the inf and 0 can have arbitrary signs) signal the invalid operation

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

2017-01-16 Thread Mark Dickinson
Mark Dickinson added the comment: > The performance argument unlikely is applicable in this case. Agreed. This is mainly about accuracy, not speed: the FMA operation is a fundamental building block for floating-point arithmetic, is useful in some numerical algorithms, and essential in others

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

2017-01-16 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The performance argument unlikely is applicable in this case. I suppose that an overhead of function call in Python make two operators faster than one function call. Alternatives to fma() for exact computations are integer arithmetic (if all values can be

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

2017-01-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: I don't know. If I want to compute a dot product, the first thing I'll do is import Numpy and then use the `@` operator on Numpy arrays. -- ___ Python tracker

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

2017-01-16 Thread Juraj Sukop
Juraj Sukop added the comment: I would say because it has wide applicability, especially considering the amount of code it adds. It is similar in spirit to `copysign` or `fsum` which are already there and C99 includes it anyway. For simpler things like dot product or polynomial evaluation

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

2017-01-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: What's the point of adding this in the math module rather than a more specialized library like Numpy? -- nosy: +pitrou ___ Python tracker

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

2017-01-16 Thread STINNER Victor
STINNER Victor added the comment: Thread on python-ideas: https://mail.python.org/pipermail/python-ideas/2017-January/044300.html -- ___ Python tracker

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

2017-01-16 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: +haypo ___ Python tracker ___ ___

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

2017-01-16 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: +mark.dickinson ___ Python tracker ___ ___

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

2017-01-16 Thread Juraj Sukop
Changes by Juraj Sukop : Added file: http://bugs.python.org/file46300/setup.py ___ Python tracker ___

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

2017-01-16 Thread Juraj Sukop
Changes by Juraj Sukop : Added file: http://bugs.python.org/file46298/xmathmodule.c ___ Python tracker ___

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

2017-01-16 Thread Juraj Sukop
Changes by Juraj Sukop : Added file: http://bugs.python.org/file46299/example.py ___ Python tracker ___

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

2017-01-16 Thread Juraj Sukop
New submission from Juraj Sukop: Fused multiply-add (henceforth FMA) is an operation which calculates the product of two numbers and then the sum of the product and a third number with just one floating-point rounding. More concretely: r = x*y + z The value of `r` is the same as if the