Ryan Newton:
> As a community I think we have to face the fact that writing the hot inner 
> loop of your application as idiomatic Haskell is not [yet] going to give you 
> C/Fortran performance off the bat.  Though in some cases there's not really 
> anything stopping us but more backend/codegen work (I'm thinking of 
> arithmetically intensive loops with scalars only).  For example, the 
> following Mandel kernel is in many ways the *same* as the C version:
> 
> https://github.com/simonmar/monad-par/blob/662fa05b2839c8a0a6473dc490ead8dd519ddd1b/examples/src/mandel.hs#L24H
> 
> We have the types; we've got strictness (for this loop); but the C version 
> was 6X faster when I tested it.

Did you use the LLVM backend? I am asking because I have seen dramatic 
differences between the code generators in similar example. Have a look at

  https://wiki.cse.unsw.edu.au/cs3141/12s1/Parallelism%20notes

With GHC's native code generator, the C version is much faster than the Haskell 
version (by a factor of 2 or 3 IIRC), but using GHC's LLVM backend, the Haskell 
version is even a few percent faster than the C version on my machine. (This is 
on OS X using llvm-gcc to compile the C code — that is, the code generator for 
the C and Haskell version goes via LLVM.)

I think that is an interesting example, because it shows (a) just how much of a 
difference a good code generator can make and (b) that using the same code 
generator, a Haskell compiler has no inherent disadvantage to a C compiler. 
(Nevertheless, especially for small examples, it is much easier to write a slow 
Haskell than to write a slow C program.)

Manuel

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to