Re: Some improvements to numeric sqrt() and ln()
От | Tels |
---|---|
Тема | Re: Some improvements to numeric sqrt() and ln() |
Дата | |
Msg-id | fbeb0c1236f61c121b4dbc0f21fa49c4@bloodgate.com обсуждение исходный текст |
Ответ на | Re: Some improvements to numeric sqrt() and ln() (Dean Rasheed <dean.a.rasheed@gmail.com>) |
Ответы |
Re: Some improvements to numeric sqrt() and ln()
Re: Some improvements to numeric sqrt() and ln() |
Список | pgsql-hackers |
Dear Dean, On 2020-03-01 20:47, Dean Rasheed wrote: > On Fri, 28 Feb 2020 at 08:15, Dean Rasheed <dean.a.rasheed@gmail.com> > wrote: >> >> It's possible that there are further gains to be had in the sqrt() >> algorithm on platforms that support 128-bit integers, but I haven't >> had a chance to investigate that yet. >> > > Rebased patch attached, now using 128-bit integers for part of > sqrt_var() on platforms that support them. This turned out to be well > worth it (1.5 to 2 times faster than the previous version if the > result has less than 30 or 40 digits). Thank you for these patches, these sound like really nice improvements. One thing can to my mind while reading the patch: + * If r < 0 Then + * Let r = r + 2*s - 1 + * Let s = s - 1 + /* s is too large by 1; let r = r + 2*s - 1 and s = s - 1 */ + r_int64 += 2 * s_int64 - 1; + s_int64--; This can be reformulated as: + * If r < 0 Then + * Let r = r + s + * Let s = s - 1 + * Let r = r + s + /* s is too large by 1; let r = r + 2*s - 1 and s = s - 1 */ + r_int64 += s_int64; + s_int64--; + r_int64 += s_int64; which would remove one mul/shift and the temp. variable. Mind you, I have not benchmarked this, so it might make little difference, but maybe it is worth trying it. Best regards, Tels
Вложения
В списке pgsql-hackers по дате отправления: