[Codel] fp sqrt vis int sqrt?
Eric Dumazet
eric.dumazet at gmail.com
Fri May 4 14:50:16 EDT 2012
On Fri, 2012-05-04 at 11:39 -0700, Dave Taht wrote:
> Heh. I'd only gotten as far as
>
> #include <stdio.h>
> #include <math.h>
> main() {
>
>
>
>
>
> before your mail arrived.
Yep, so maybe we can use a precomputed table of 25 values (100 bytes),
using the reciprocal trick to get precise integer approximation.
(interval/sqrt(count)).
So that control_law() has no multiply or divide to do, just a lookup in
the array.
Then for count values >= 25, either we can afford an error less than 20%
using the q->sqrt_count maintained in // with q->count, either we
compute the reciprocal each time we change q->count.
(cost : one divide + int_sqrt() call )
plus one multiply in control_law()
Not sure we need to be ultra precise.
More information about the Codel
mailing list