caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Pervasives.{min,max} not specialized to floats by ocamlopt
@ 2006-08-17 18:34 Will M Farr
  2006-08-18 15:34 ` [Caml-list] Pervasives.{min, max} " Olivier Andrieu
  0 siblings, 1 reply; 4+ messages in thread
From: Will M Farr @ 2006-08-17 18:34 UTC (permalink / raw)
  To: caml-list

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.   
Including my own min and max functions in the module to shadow these  
removed the calls to compare_val.  I'm curious if this is well-known  
behavior (a google search didn't turn up anything).  It's, of course,  
not a bug, but it's definitely surprising when all the other  
polymorphic comparisons are special-cased for floats!

I don't know how hard it would be to change this in ocamlopt, but it  
seems like it would be pretty simple.  If it is simple, it would be a  
good candidate to change in the next release for those of us who do a  
lot of float-comparing.

Thanks!
Will


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-08-18 15:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-17 18:34 Pervasives.{min,max} not specialized to floats by ocamlopt Will M Farr
2006-08-18 15:34 ` [Caml-list] Pervasives.{min, max} " Olivier Andrieu
2006-08-18 15:37   ` Will M Farr
2006-08-18 15:43   ` Shawn

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).