From: Denys Vlasenko <vda.linux@googlemail.com>
To: Michal Nazarewicz <mina86@mina86.com>
Cc: linux-kernel@vger.kernel.org, m.nazarewicz@samsung.com,
"Douglas W. Jones" <jones@cs.uiowa.edu>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCHv2 1/3] lib: vsprintf: optimised put_dec_trunc() and put_dec_full()
Date: Tue, 10 Aug 2010 05:17:48 +0200 [thread overview]
Message-ID: <201008100517.48231.vda.linux@googlemail.com> (raw)
In-Reply-To: <6f90103dea29739de0f4f0ede3f3da68afe84343.1281295424.git.mina86@mina86.com>
On Sunday 08 August 2010 21:29, Michal Nazarewicz wrote:
> -- Speed --------------------------------------------------------
> orig_put_dec_full : 1.054570 1.356214 1.732636 1.725760 Original
> mod1_put_dec_full : 1.000000 1.017216 1.255518 1.116559
> mod3_put_dec_full : 1.018222 1.000000 1.000000 1.000000 Proposed
>
> orig_put_dec_trunc : 1.137903 1.216017 1.850478 1.662370 Original
> mod1_put_dec_trunc : 1.000000 1.078154 1.355635 1.400637
> mod3_put_dec_trunc : 1.025989 1.000000 1.000000 1.000000 Proposed
> -- Size ---------------------------------------------------------
> orig_put_dec_full : 1.212766 1.310345 1.355372 1.355372 Original
> mod1_put_dec_full : 1.021277 1.000000 1.000000 1.000000
> mod3_put_dec_full : 1.000000 1.172414 1.049587 1.049587 Proposed
>
> orig_put_dec_trunc : 1.363636 1.317365 1.784000 1.784000 Original
> mod1_put_dec_trunc : 1.181818 1.275449 1.400000 1.400000
> mod3_put_dec_trunc : 1.000000 1.000000 1.000000 1.000000 Proposed
In my testing on Phenom II the speed gain is smaller,
but it is indeed faster. And smaller!
> + /*
> + * '(x * 0xcccd) >> 19' is an approximation of 'x / 10' that
> + * gives correct results for all x < 81920. However, because
> + * intermediate result can be at most 32-bit we limit x to be
> + * 16-bit.
> + *
> + * Because of those, we check if we are dealing with a "big"
> + * number and if so, we make it smaller remembering to add to
> + * the most significant digit.
> + */
> + if (q >= 50000) {
> + a = '5';
> + q -= 50000;
...
> + /*
> + * We need to check if q is < 65536 so we might as well check
You meant "need to check if q is < 81920"?
> + * if we can just call the _full version of this function.
> + */
> + if (q > 9999)
> + return put_dec_full(buf, q);
--
vda
next prev parent reply other threads:[~2010-08-10 3:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-08 19:29 [PATCHv2 1/3] lib: vsprintf: optimised put_dec_trunc() and put_dec_full() Michal Nazarewicz
2010-08-08 19:29 ` [PATCHv2 2/3] lib: vsprintf: optimised put_dec() for 32-bit machines Michal Nazarewicz
2010-08-08 19:29 ` [PATCHv2 3/3] lib: vsprintf: added a put_dec() test and benchmark tool Michal Nazarewicz
2010-08-10 4:15 ` [PATCHv2 2/3] lib: vsprintf: optimised put_dec() for 32-bit machines Denys Vlasenko
2010-08-10 7:42 ` Michał Nazarewicz
2010-08-10 16:10 ` Denys Vlasenko
2010-08-10 3:17 ` Denys Vlasenko [this message]
2010-08-10 7:39 ` [PATCHv2 1/3] lib: vsprintf: optimised put_dec_trunc() and put_dec_full() Michał Nazarewicz
2010-08-10 16:08 ` Denys Vlasenko
2010-08-10 22:42 ` Michal Nazarewicz
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=201008100517.48231.vda.linux@googlemail.com \
--to=vda.linux@googlemail.com \
--cc=akpm@linux-foundation.org \
--cc=jones@cs.uiowa.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=m.nazarewicz@samsung.com \
--cc=mina86@mina86.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.