[Haskell-cafe] Using loop fusion for writing efficent high-level code Re[2]: [Haskell] [Fwd: Re: Computer Language Shootout]

Bulat Ziganshin bulat.ziganshin at gmail.com
Wed Feb 28 08:38:10 EST 2007

Hello Duncan,

Tuesday, February 27, 2007, 1:09:53 PM, you wrote:

can you please provide examples of such code? the ultimate goal is to
have tutorial on writing efficient code in high-level manner, but that
is too ambitious. just some examples with a little explanation of how
this is compiled?

thanks in advance

>> So I think we should do the same.  It even shows in the Shootout - the
>> programs that are simultaneously fastest and clearest are not pure
>> Haskell, but delegate their innermost loops to tuned C libraries (FPS
>> and GMP). 

> I should note that FPS is almost completely Haskell code, not C. We use
> C for things like memcmp, memcpy, memset, reverse_copy, intersperse,
> maximum, minimum and count.

> Certainly some of the innards are low level style Haskell, though not
> the kind that could be replicated in C because we use high level
> transformations to fuse loop bodies together and wrap them in high
> performance, low level loop code.

> This is not the style where we just wrap well tuned C code, this is a
> style where we generate high performance low level code from a high
> level spec. This relies on GHC's excellent and programmable optimiser.

> It's wrong to say that the shootout improvements were only down to
> improved libraries. The performance of ByteString code improved very
> significantly between GHC 6.4 and 6.6 and a large part of that was down
> to optimiser improvements (not just the ForeignPtr rep change).

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list