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
Pervasives.{min,max} not specialized to floats by ocamlopt
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-08-18 (15:34)
From: Olivier Andrieu <oandrieu@n...>
Subject: Re: [Caml-list] Pervasives.{min, max} not specialized to floats by ocamlopt
 Will M Farr [Thursday 17 August 2006] :
 > Hello all,
 > I was profiling some numerical code compiled with ocamlopt today (for  
 > the record: PPC G4, Mac OS X 10.4.7, ocamlopt 3.09.2), and I noticed  
 > that a lot of time was taken up in the compare_val function, even  
 > though type inference asserted that all values I was comparing were  
 > floats.  Turns out the culprits were Pervasives.min and  
 > Pervasives.max---these functions do not specialize to the appropriate  
 > assembly instructions if their arguments are known to be floats.   

Indeed. That's because min and max are not primitives provided by the
runtime library but regular caml functions from pervasives.ml :
| let min x y = if x <= y then x else y
| let max x y = if x >= y then x else y

 > I don't know how hard it would be to change this in ocamlopt, but
 > it seems like it would be pretty simple.

I don't know, float comparisons tend not to be 'pretty simple' usually
(because of NaNs).