English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Question about optimization
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-11-02 (12:00)
From: Jon Harrop <jonathandeanharrop@g...>
Subject: Re: [Caml-list] Question about optimization
On Sunday 02 November 2008 02:52:49 Michał C wrote:
> Hi!
> I'm working on a physical based ray(path) tracer and the performance
> is one of my top priorities (just after the image quality).
> So I have a question about optimization: can You share some tips or
> maybe optimizing strategies to improve the speed of programs?
> here is my code: http://neos1.ovh.org/ray3.ml,
> and here is how I compile it:
> ocamlopt -inline 100 -unsafe -ffast-math str.cmxa -I +lablgl
> lablgl.cmxa lablglut.cmxa -o ray ray.ml

Looks good but get rid of -unsafe and use records to represent vectors instead 
of arrays and compile in 64-bit and get rid of -ffast-math.

I don't know if it affects performance but get rid of conditions returning 
bool constants:

  if hc2 < 0. then false else true

Should be:

  hc2 >= 0.

> Maybe You can take a look, sure I don't expect You to look through it
> in some hardcore way, but You know, maybe there are some obvious
> mistakes or unnecessary boxing which will spot your eye.
> Thanks in advance,
> oh and if you possibly want to see the development or how the program
> works - http://neos1.wordpress.com

May I have an example scene description file that I can use for profiling? 
Without it, I have no way to direct my effort...

Dr Jon Harrop, Flying Frog Consultancy Ltd.