From: linux@horizon.com
To: alex.williamson@hp.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: Need better is_better_time_interpolator() algorithm
Date: 25 Aug 2005 17:40:29 -0400 [thread overview]
Message-ID: <20050825214029.21209.qmail@science.horizon.com> (raw)
> (frequency) * (1/drift) * (1/latency) * (1/(jitter_factor * cpus))
(Note that 1/cpus, being a constant for all evaluations of this
expression, has no effect on the final ranking.)
The usual way it's done is with some fiddle factors:
quality_a^a * quality_b^b * quality_c^c
Or, equivalently:
a * log(quality_a) + b * log(quality_b) + c * log(quality_c)
Then you use the a, b and c factors to weight the relative importance
of them. Your suggestion is equivalent to setting all the exponents to 1.
But you can also say that "a is twice as important as b" in a
consistent manner.
Note that computing a few bits of log_2 is not hard to do in integer
math if you're not too anxious about efficiency:
unsigned log2(unsigned x)
{
unsigned result = 31;
unsigned i;
assert(x);
while (!x & (1u<<31)) {
x <<= 1;
result--;
}
/* Think of x as a 1.31-bit fixed-point number, 1 <= x < 2 */
for (i = 0; i < NUM_FRACTION_BITS; i++) {
unsigned long long y = x;
/* Square x and compare to 2. */
y *= x;
result <<= 1;
if (y & (1ull<<63)) {
result++;
x = (unsigned)(y >> 32);
} else {
x = (unsigned)(y >> 31);
}
}
return result;
}
Setting NUM_FRACTION_BITS to 16 or so would give enough room for
reasonable-sized weights and not have the total overflow 32 bits.
next reply other threads:[~2005-08-25 21:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-25 21:40 linux [this message]
2005-08-25 23:07 ` Need better is_better_time_interpolator() algorithm Alex Williamson
2005-08-26 16:48 ` Christoph Lameter
-- strict thread matches above, loose matches on Subject: below --
2005-08-25 16:44 Alex Williamson
2005-08-25 17:36 ` john stultz
2005-08-25 18:43 ` Alex Williamson
2005-08-25 19:02 ` john stultz
2005-08-26 15:39 ` Christoph Lameter
2005-08-26 16:18 ` Alex Williamson
2005-08-26 19:16 ` George Anzinger
2005-08-26 19:26 ` Alex Williamson
2005-08-26 19:33 ` Christoph Lameter
2005-08-26 19:51 ` George Anzinger
2005-08-27 11:55 ` Pavel Machek
2005-08-29 17:00 ` Christoph Lameter
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050825214029.21209.qmail@science.horizon.com \
--to=linux@horizon.com \
--cc=alex.williamson@hp.com \
--cc=linux-kernel@vger.kernel.org \
/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