From: "Randy.Dunlap" <rddunlap@osdl.org>
To: lkml <linux-kernel@vger.kernel.org>
Cc: WHarms@bfs.de
Subject: Re: patch: linux-2.6.4/lib/int_sqrt.c long aware
Date: Thu, 5 Aug 2004 20:47:16 -0700 [thread overview]
Message-ID: <20040805204716.38caeb88.rddunlap@osdl.org> (raw)
In-Reply-To: <20040805173023.175a77f8.rddunlap@osdl.org>
| From: <> (Walter Harms)
|
| hi list,
| this patch make int_sqrt() handle long properly. i tested it
| on my alpha and i386. also some comparision again an alternativ int_sqrt() code.
| The placement (and using) of 'tmp' is a bit odd but faster (on alpha, no matter on i386).
|
| happy hacking,
| walter
|
| ps: i must use c&p so be aware of possible tab->space translations
|
|
| --- linux-2.6.4/lib/int_sqrt.c.org 2004-03-21 12:58:55.783035928 +0100
| +++ linux-2.6.4/lib/int_sqrt.c 2004-03-21 13:16:20.999138928 +0100
| @@ -10,22 +10,23 @@
| */
| unsigned long int_sqrt(unsigned long x)
| {
| - unsigned long op, res, one;
| + unsigned long op, res, one,tmp;
|
| op = x;
| res = 0;
|
| - one = 1 << 30;
| + one = 1UL << (BITS_PER_LONG-2);
| while (one > op)
| one >>= 2;
|
| while (one != 0) {
| + tmp=res + one;
| if (op >= res + one) {
| - op = op - (res + one);
| - res = res + 2 * one;
| + op = op - tmp;
| + res = tmp + one;
| }
| - res /= 2;
| - one /= 4;
| + res >>= 1;
| + one >>= 2;
| }
| return res;
| }
Hi Walter,
I found a little time to play with this. I only tested it on
a P4 UP machine (via userspace app).
It does indeed speed up integer sqrt typically by around 3% for me.
--
~Randy
next parent reply other threads:[~2004-08-06 3:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20040805173023.175a77f8.rddunlap@osdl.org>
2004-08-06 3:47 ` Randy.Dunlap [this message]
2004-04-03 11:16 Walter Harms
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=20040805204716.38caeb88.rddunlap@osdl.org \
--to=rddunlap@osdl.org \
--cc=WHarms@bfs.de \
--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
all inboxes | Powered by JetHome®