[Haskell-cafe] Counting bits: Sanity Check

Daniel McAllansmith dagda at xtra.co.nz
Wed Apr 12 17:21:37 EDT 2006


On Thursday 13 April 2006 08:55, David F. Place wrote:
> On Apr 12, 2006, at 3:30 PM, Daniel McAllansmith wrote:
> > Averages of user time for three runs on an Athlon64 running 64bit
> > linux:
> >
> > kern	0.29700
> > ones32 	0.30733
> > table32	0.37333
> > table 	0.38400
> >
> > I ran a whole lot more of kern and ones32... kern was consistently
> > faster than
> > ones32.  Curious.
>
> Yes, especially curious since the algorithm is taken from AMD's
> optimization guide for the Athlon and Opteron series.  I'm not good
> enough at reading core syntax to be able to see what GHC is doing
> with it.
>
> I wonder how this other crazy algorithm I found will work on your 64
> bit omputer.   It is much slower on my 32 bit PPC powerbook for
> obvious reasons.   If you'd like to try it, I'll include an updated
> BitTwiddle.hs .
>
> Usage:
> time ./bits 2000000 3000000 64

Averages of user time of five runs on an Athlon64 running 64bit linux:

64	0.1974
kern	0.2980
ones32	0.3240
table32	0.3754
table	0.3798

64 looks to be a good bit faster.

You didn't change anything in the ones32 algorithm did you?  The other 
algorithms are taking roughly what they did last time, but ones32 seems 
consistently slower now.

Daniel


More information about the Haskell-Cafe mailing list