<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>Ryan Newton:</div><blockquote type="cite"><div class="gmail_quote"><div>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. &nbsp;Though in some cases there's not really anything stopping us but more backend/codegen work&nbsp;(I'm thinking of arithmetically intensive loops with scalars only). &nbsp;For example, the following Mandel kernel is in many ways the *same* as the C version:</div>

<div><br></div><div><a href="https://github.com/simonmar/monad-par/blob/662fa05b2839c8a0a6473dc490ead8dd519ddd1b/examples/src/mandel.hs#L24H" target="_blank">https://github.com/simonmar/monad-par/blob/662fa05b2839c8a0a6473dc490ead8dd519ddd1b/examples/src/mandel.hs#L24H</a></div>

<div><br></div><div>We have the types; we've got strictness (for this loop); but the C version was 6X faster when I tested it.</div></div></blockquote><div><br></div></div>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<div><br></div><div>&nbsp;&nbsp;<a href="https://wiki.cse.unsw.edu.au/cs3141/12s1/Parallelism%20notes">https://wiki.cse.unsw.edu.au/cs3141/12s1/Parallelism%20notes</a></div><div><br></div><div>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.)</div><div><br></div><div>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.)</div><div><br></div><div>Manuel</div><div><br></div></body></html>