[PATCH v3 5/7] math: Remove powerpc e_hypot
Adhemerval Zanella
adhemerval.zanella@linaro.org
Thu Nov 11 17:13:31 GMT 2021
On 11/11/2021 14:05, Wilco Dijkstra wrote:
> Hi Adhemerval,
>
>> On 10/11/2021 11:34, Wilco Dijkstra wrote:
>>> I think the new algorithm will always be slower due to the dependent sqrt and
>>> division. So it's hard to improve unless we only use it for special cases (eg. when
>>> ax and ay are close). Returning sqrt (fma (ax, ax, ay * ay)) is about twice as fast
>>> and gives just over 1 ULP, so we're losing a lot of performance for a small ULP
>>> improvement.
>>
>> My main drive for this change is remove the arch-specific implementation in
>> favor of an implementation that might be optimized better by the compiler
>> without the need to extra hacks by arch-specific hooks (as I did for power7).
>
> I'm all for having a single optimized generic implementation like we did for other
> math functions. In general there is little scope for compiler optimizations due to
> conservative FP settings - it is all down to highly optimizing both the algorithm
> and implementation.
>
>> Another option is to use the powerpc implementation which favor FP over integer
>> as the default one.
>
> That is the fastest implementation. It is less accurate though (~1.04ULP with FMA
> and ~1.21ULP without FMA), so I'm not sure that would be acceptable.
This should not be worse than the current default (the powerpc one is essentially
the same as default using FP operations).
>
> I did some quick optimizations on the new algorithm, on Neoverse N1 my fastest
> version is less than 10% slower than the powerpc version, and has ~0.94 ULP error.
Do you mean besides the optimized nan/inf checks? I can check if it helps on
powerpc.
More information about the Libc-alpha
mailing list