[Haskell-cafe] Haskell version of ray tracer code is much slower than the original ML

Philip Armstrong phil at kantaka.co.uk
Thu Jun 21 09:12:11 EDT 2007

On Thu, Jun 21, 2007 at 01:39:24PM +0100, Jon Harrop wrote:
>Awesome stuff!
>On Thursday 21 June 2007 12:36:27 Philip Armstrong wrote:
>> On Thu, Jun 21, 2007 at 12:25:44PM +0100, Sebastian Sylvan wrote:
>> >Try using floats for the vector, and strict fields (add a ! to the
>> >fields in the data declaration).
>> Because the optimisation page on the haskell wiki is very explicit
>> about never using Float when you can use Double, that's why. An older
>> revision used Float and it was slower than the current one. Making the
>> datatypes strict also makes no difference.
>Where exactly do the !s go and what do they do?

On the datatypes:

data Vector = V !Double !Double !Double

for instance. They tell the compiler to make those fields strict
rather than lazy. This may or may not help things...

>> OCaML floats are Doubles, at least on x86.
>Yes. OCaml doesn't have a 32-bit float storage format, apart from an 
>entirely-float big array. Also, the ML in OCaml doesn't stand for 
>metalanguage. ;-)


>I take it you saw the whole language comparison:
>  http://www.ffconsultancy.com/languages/ray_tracer/

Yup. I'd been meaning to run off a haskell version for a

>I'll be uploading concurrent implementations ASAP. Haskell should do well 
>there... :-)

I'll be on the lookout.

>PS: You spelled my name wrong!



http://www.kantaka.co.uk/ .oOo. public key: http://www.kantaka.co.uk/gpg.txt

More information about the Haskell-Cafe mailing list