Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

> What results for all components equal? hypot(1.0, 1.0, ..., 1.0)

The scaled summation will be exact (all elements scale to 1.0 and frac is 
always 0.0).

> Would it give a performance benefit if get rid of multiplication 
> and division, and scale by the power of two approximation of the 
> max using ldexp()?

You're right that the multiplication and division are the most expensive part 
(the adds and subtracts are cheaper and can be done in parallel with subsequent 
memory fetches).  See the attached Clang and GCC-8 disassemblies.

I've tried a number of variants and couldn't get any performance boost without 
breaking some of the test cases.  This patch is the best of a dozen attempts.

----------
Added file: https://bugs.python.org/file47744/math_hypot.s

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34376>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to