[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20070306.135834.26100913.davem@davemloft.net>
Date: Tue, 06 Mar 2007 13:58:34 -0800 (PST)
From: David Miller <davem@...emloft.net>
To: shemminger@...ux-foundation.org
Cc: rkuhn@....physik.tu-muenchen.de, andi@...stfloor.org,
dada1@...mosbay.com, jengelh@...ux01.gwdg.de,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [RFC] div64_64 support
From: Stephen Hemminger <shemminger@...ux-foundation.org>
Date: Tue, 6 Mar 2007 10:29:41 -0800
> /* calculate the cubic root of x using Newton-Raphson */
> static uint32_t ncubic(uint64_t a)
> {
> uint64_t x;
>
> /* Initial estimate is based on:
> * cbrt(x) = exp(log(x) / 3)
> */
> x = 1u << (fls64(a)/3);
>
> /* Converges in 3 iterations to > 32 bits */
>
> x = (2 * x + div64_64(a, x*x)) / 3;
> x = (2 * x + div64_64(a, x*x)) / 3;
> x = (2 * x + div64_64(a, x*x)) / 3;
>
> return x;
> }
Indeed that will be the fastest variant for cpus with hw
integer division.
I did a quick sparc64 port, here is what I got:
Function clocks mean(us) max(us) std(us) total error
ocubic 529 0.35 15.16 0.66 545101
ncubic 498 0.33 12.83 0.36 576263
acbrt 427 0.28 11.04 0.33 547562
hcbrt 393 0.26 10.18 0.47 2410
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists