Browse thread
Pervasives.{min,max} not specialized to floats by ocamlopt
-
Will M Farr
- Olivier Andrieu
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| 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). -- Olivier