Bit counting

Andrew Hume andrew at alice.UUCP
Wed Jan 11 15:42:47 AEST 1989



i admired the futzy but clever-looking algorithm to do parallel addition
to determine bit counts reported by rich neitzel. i myself had guessed
that table lookup by bytes was an appropriate space/time tradeoff.
i present times for 300K calls on a mips 120-5 below (8 is table lookup
for 8 bit chunks, 4 is for 4bit chunks and s is the parallel aaddition alg).
note that on the mips, the 3x speedup for 's' found on the vax isn't.
tuttle=; timex a.out 8
real        4.01
user        3.98
sys         0.03
tuttle=; timex a.out 4
real       11.61
user       11.59
sys         0.01
tuttle=; timex a.out s
real       11.33
user       11.24
sys         0.03
this was without optimising; -O3 gains a bit more:
tuttle=; timex a.out 8
real        3.64
user        3.62
sys         0.01
tuttle=; timex a.out 4
real       11.13
user       11.05
sys         0.02
tuttle=; timex a.out s
real       10.34
user       10.32
sys         0.02



More information about the Comp.lang.c mailing list