Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1396366
| From | "George Spelvin" <linux@horizon.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [patch V4] lib: GCD: Use binary GCD algorithm instead of Euclidean |
| Date | 2016-05-08 00:40 +0200 |
| Message-ID | <rwj3b-1FZ-11@gated-at.bofh.it> (permalink) |
| References | <rw8AN-Fn-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Sam Ravnborg wrote:
> sparc64 have an efficient ffs implementation.
> We use run-time patching to use the proper version
> depending on the actual sparc cpu.
>
> As this is determinded at config time, then let the
> sparc cpu that has the efficient ffs benefit from this.
>
> In other words - select CPU_NO_EFFICIENT_FFS only for SPARC32.
I'm not sure this is the right thing.
It's always a function call, and there's boot-time code patching to use
either an unrolled binary search or a POPC instructon on processors that
have that instruction.
The NO_EFFICIENT_FFS isn't much slower than the __ffs version, so the
call/return alone might eat the difference, and if the CPU doesn't have
POPC support it's definitely a lose.
Quite simply, gcd isn't important enough to be worth the same boot-time
code patching, and if we have to use one on both types of CPU the the
NO_EFFICIENT_FFS path is the safer alternative in case of uncertainty.
Would you be willing to try benchmarking it? The baseline code, plus two
versions of the __ffs code using the two different __ffs implementations
(forced out of line by compiling from assembler source or using
inine asm and __attribute((noinline))).
By the way, the SPARC64 implementation could be improved.
It's currently 5 instructions:
__ffs:
neg %o0, %g1
xnor %o0, %g1, %o1
popc %o1, %o0
retl
sub %o0, 1, %o0
That could be improved to 4:
sub %o0, 1, %g1
andn %g1, %o0, %g1
retl
popc %g1, %o0
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[patch V4] lib: GCD: Use binary GCD algorithm instead of Euclidean zengzhaoxiu@163.com - 2016-05-06 12:00 +0200
Re: [patch V4] lib: GCD: Use binary GCD algorithm instead of Euclidean Andrew Morton <akpm@linux-foundation.org> - 2016-05-07 01:10 +0200
Re: [patch V4] lib: GCD: Use binary GCD algorithm instead of Euclidean "George Spelvin" <linux@horizon.com> - 2016-05-07 10:50 +0200
Re: [patch V4] lib: GCD: Use binary GCD algorithm instead of Euclidean Andreas Schwab <schwab@linux-m68k.org> - 2016-05-07 12:50 +0200
Re: [patch V4] lib: GCD: Use binary GCD algorithm instead of Euclidean "George Spelvin" <linux@horizon.com> - 2016-05-07 22:50 +0200
Re: [patch V4] lib: GCD: Use binary GCD algorithm instead of Euclidean Zhaoxiu Zeng <zengzhaoxiu@163.com> - 2016-05-08 15:20 +0200
Re: [patch V4] lib: GCD: Use binary GCD algorithm instead of Euclidean Sam Ravnborg <sam@ravnborg.org> - 2016-05-07 13:30 +0200
Re: [patch V4] lib: GCD: Use binary GCD algorithm instead of Euclidean "George Spelvin" <linux@horizon.com> - 2016-05-08 00:40 +0200
csiph-web