caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Re: Mini ray tracer
Date: Wed, 4 May 2005 08:27:11 +0100	[thread overview]
Message-ID: <200505040827.11366.jon@ffconsultancy.com> (raw)
In-Reply-To: <42786A96.3030204@bik-gmbh.de>

On Wednesday 04 May 2005 07:24, Florian Hars wrote:
> I did some comparisions (the ml code on that page doesn't compile, but the
> fix is trivial) and told gcc 3.3.5 to actually optimize the c++ (-O2
> -march=x86-64 -msse2 -ffast-math)

As I said last night, my timings were for optimised C++ and optimised OCaml on 
x86.

> and the c++ was consistently faster than 
> the ocaml code for detail levels of 4 and greater, marginally at 4, about
> 20% at a level of 10, twice as fast at 12, and infinitely faster at a level
> of 14 (the c++ program finished in less than three minutes, the ocaml
> program started to trigger the oom killer after about an hour, and I
> finally had to push the friendly red button labeled "reset" to get my
> computer back).

Yes, the OCaml program seems to use ~50% more memory. I assume C++ is inlining 
those structs. It would be ugly to work around this in the OCaml, AFAIK. If 
you want to work at the extremes of memory usage then you'll probably want to 
ditch that data structure and use a single-precision float big array.

> This looks like a suboptimal example for the speed of ocaml.

These results appear to be specific to 64-bit.

As far as the shootout is concerned, we seem to have agreed that you can 
optimise your code up to 100 LOC. So the OCaml can have some algorithmic 
optimisations which increase its performance and verbostity.

With these algorithmic optimisations, I get 35.6s (82 LOC OCaml) vs 36.8s (92 
LOC C++) on AMD64 for n=11.

The optimisation is to trace shadow rays using an intersection routine which 
returns as soon as any intersection is found, rather than returning the 
parameter of the first intersection.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists


  reply	other threads:[~2005-05-04  7:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-28  9:37 Jon Harrop
2005-05-02 19:48 ` Julian Brown
2005-05-03 22:47   ` [Caml-list] " Jon Harrop
2005-05-04  6:24   ` Florian Hars
2005-05-04  7:27     ` Jon Harrop [this message]
2005-05-04 11:22       ` Jon Harrop

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200505040827.11366.jon@ffconsultancy.com \
    --to=jon@ffconsultancy.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).