[Haskell-cafe] performance issues with popCount
nicolas at incubaid.com
Sat Sep 8 12:28:21 CEST 2012
On Fri, 2012-09-07 at 15:55 -0700, Johan Tibell wrote:
> On Fri, Sep 7, 2012 at 4:54 AM, Nicolas Trangez <nicolas at incubaid.com> 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.c
> > Out of interest: isn't this compiled into the popCnt# primop (and popcnt
> > instruction on SSE4.2)?
> It's the other way around the popCnt# primop is compiled into either
> calls to these C functions or into the popcnt instruction, if -msse4.2
> is given.
Yes, indeed. I was referring to Data.Bits.popCount, but looking back
this was indeed completely non-obvious. My bad.
> > I recently noticed Data.IntSet also contains a fairly basic "bitcount"
> > implementation . Is this kept as-is for a reason, instead of using
> > popCount from Data.Bits?
> I don't think so, except that we want to support the last 3 released
> versions of GHC so we need to have a fallback if Data.Bits.popCount
> isn't defined.
I might look into creating a (CPP-based) patch then.
More information about the Haskell-Cafe