From: Eric Dumazet <eric.dumazet@gmail.com>
To: Dave Taht <dave.taht@gmail.com>
Cc: codel@lists.bufferbloat.net
Subject: Re: [Codel] fp sqrt vis int sqrt?
Date: Sat, 05 May 2012 10:14:12 +0200 [thread overview]
Message-ID: <1336205652.3752.498.camel@edumazet-glaptop> (raw)
In-Reply-To: <1336159005.3752.384.camel@edumazet-glaptop>
On Fri, 2012-05-04 at 21:16 +0200, Eric Dumazet wrote:
> On Fri, 2012-05-04 at 12:04 -0700, Dave Taht wrote:
>
> > Late this evening I'll have time to incorporate the progress so far
> > today (thx for the cleanups and help!!!) and I'll try to get another
> > patch out late tonight. Unless you beat me to it.
> >
>
> I am not planning to send a patch in a near future, its 9h15pm here in
> France, and TGIF.
>
>
Oh well, this is obvious, just use the following and be done :
/* return interval/sqrt(x) with good precision
*/
u32 int_sqrt_div(u32 _interval, unsigned long x)
{
u64 interval = _interval;
/* scale for maximum precision */
while (x < (1UL << (BITS_PER_LONG - 2))) {
x <<= 2;
interval <<= 1;
}
do_div(interval, int_sqrt(x));
return (u32)interval;
}
Doing the scaling before calling int_sqrt() makes int_sqrt() faster,
since we avoid the initial scaling on 'one'
one = 1UL << (BITS_PER_LONG - 2);
while (one > op)
one >>= 2;
Always sleep a bit, its good.
prev parent reply other threads:[~2012-05-05 8:14 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-04 15:11 Dave Taht
2012-05-04 15:14 ` Jim Gettys
2012-05-04 15:19 ` Dave Taht
2012-05-04 15:26 ` Jim Gettys
2012-05-04 15:56 ` Eric Dumazet
2012-05-04 17:23 ` Dave Taht
2012-05-04 17:43 ` Dave Taht
2012-05-04 17:44 ` Dave Taht
2012-05-04 17:46 ` Dave Taht
2012-05-04 23:42 ` Kathleen Nichols
2012-05-05 0:01 ` Dave Taht
2012-05-04 17:47 ` Eric Dumazet
2012-05-04 18:26 ` Eric Dumazet
2012-05-04 18:39 ` Dave Taht
2012-05-04 18:50 ` Eric Dumazet
2012-05-04 19:04 ` Dave Taht
2012-05-04 19:16 ` Eric Dumazet
2012-05-05 8:14 ` Eric Dumazet [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.bufferbloat.net/postorius/lists/codel.lists.bufferbloat.net/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1336205652.3752.498.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=codel@lists.bufferbloat.net \
--cc=dave.taht@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox