CoDel AQM discussions
 help / color / mirror / Atom feed
From: Jim Gettys <jg@freedesktop.org>
To: Dave Taht <dave.taht@gmail.com>
Cc: codel@lists.bufferbloat.net
Subject: Re: [Codel] fp sqrt vis int sqrt?
Date: Fri, 04 May 2012 11:14:16 -0400	[thread overview]
Message-ID: <4FA3F248.3070101@freedesktop.org> (raw)
In-Reply-To: <CAA93jw49KZZHBfb47cGN7tTxw8RbGzHHEVodhdpzmbOp78CREQ@mail.gmail.com>

On 05/04/2012 11:11 AM, Dave Taht wrote:
> The linux kernel has no floating point in it, so I'd substituted the
> internal int_sqrt as a substitute,
> just to get something to work.
>
> static inline ktime_t control_law(const struct codel_sched_data *q, ktime_t t)
> {
>         return ktime_add_ns(t, q->interval / int_sqrt(q->count));
> }
>
> Often ns2 models use floating point. Having not seen the model I don't
> know that for sure.
>
> The series for an integer sqrt is far more 'chunky' than a fp one.
>
> int sqrt 1,2,3,4 = 1 1 1 2
> fp sqrt 1 2 3 4 = 1 1.4.1 1.73 2
>
> and gets even more chunky as you get larger values, eg, sqrt(36
> through 48) = 6, sqrt(49) = 7
>
> So we could precalculate the interval/sqrt(count) using floating point
> in the control law calculation,
> early, during qdisc setup, thus neatly avoiding both the divide and
> sqrt in the control law path.
>
> Or we could do fixed point.
>
> Kathie: In the sim, in various simulations, what is the dynamic range
> of count? And is it floating point sqrt?
>
The Wikipedia article on fast inverse sqrt is enlightening on computing
this really fast.

See:

http://en.wikipedia.org/wiki/Fast_inverse_square_root

This has little to do with whether an integer or floating point value is
better algorithmically.
                            - Jim

  reply	other threads:[~2012-05-04 15: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 [this message]
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

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=4FA3F248.3070101@freedesktop.org \
    --to=jg@freedesktop.org \
    --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