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:
> >>
> >>
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.
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
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
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 -
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
> 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
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) -