Re: [Haskell-cafe] performance issues with popCount

2012-09-08 Thread Nicolas Trangez
On Fri, 2012-09-07 at 15:55 -0700, Johan Tibell wrote: > On Fri, Sep 7, 2012 at 4:54 AM, Nicolas Trangez wrote: > > On Thu, 2012-09-06 at 12:07 -0700, Johan Tibell wrote: > >> Have a look at the popCount implementation for e.g. Int, which are > >> written in C and called through the FFI: > >> > >>

Re: [Haskell-cafe] performance issues with popCount

2012-09-07 Thread Johan Tibell
On Fri, Sep 7, 2012 at 4:54 AM, Nicolas Trangez wrote: > On Thu, 2012-09-06 at 12:07 -0700, Johan Tibell wrote: >> Have a look at the popCount implementation for e.g. Int, which are >> written in C and called through the FFI: >> >> https://github.com/ghc/packages-ghc-prim/blob/master/cbits/popcnt.

Re: [Haskell-cafe] performance issues with popCount

2012-09-07 Thread Nicolas Trangez
On Thu, 2012-09-06 at 12:07 -0700, Johan Tibell wrote: > Have a look at the popCount implementation for e.g. Int, which are > written in C and called through the FFI: > > https://github.com/ghc/packages-ghc-prim/blob/master/cbits/popcnt.c Out of interest: isn't this compiled into the popCnt# pri

Re: [Haskell-cafe] performance issues with popCount

2012-09-06 Thread Johan Tibell
Hi Harald, On Thu, Sep 6, 2012 at 9:46 AM, Harald Bögeholz wrote: > Anyway, I tried this version > > popCount :: Integer -> Int > popCount = go 0 > where > go c 0 = c > go c w = go (c+1) (w .&. (w - 1)) > > and profiling showed that my program spent 80 % of its time counting b

Re: [Haskell-cafe] performance issues with popCount

2012-09-06 Thread Thomas DuBuisson
What _should_ be happening is we should be calling GMP's popcount function when using integer-gmp. As for your code I worry about it: * being too lazy, so add some bang patterns or seq * using boxed arrays, so use unboxed * indexing arrays by Integer comparison even when those are small integers -

[Haskell-cafe] performance issues with popCount

2012-09-06 Thread Harald Bögeholz
Dear Haskell Cafe, I am struggling with the performance of the popCount function from Data.Bits. To be more precise: I downloaded the Haskell Platform 2012.2.0.0 from http://hackage.haskell.org/platform/ (64 bit, Mac OS X). In this version I found the popCount function to be broken. If I look in

Re: [Haskell-cafe] Performance Issues

2008-01-29 Thread Adam Langley
> This computes 100!. This version takes 8m29.189s to execute. > Replace foldr1 with foldr and that goes down to 7m4.315s. Replace > product' with the Prelude product and it takes only 6m17.685s. Why is > that so? I'm using ghc 6.8.1 on Mac OS X. I'm guessing that the speedup with the Prelude

[Haskell-cafe] Performance Issues

2008-01-29 Thread Adrian Neumann
Hello Haskell-Cafe! I've read about Control.Parallel and wanted to give it a try. Here's what I wrote: --- import Control.Parallel import Data.List splitList :: [Integer] -> [[Integer]] splitList = unfoldr f where f [] = Nothing f ~x = Just (splitAt 3 x) map' :: (a->b) -