caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Olivier Andrieu <oandrieu@nerim.net>
To: Will M Farr <farr@MIT.EDU>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Pervasives.{min, max} not specialized to floats by ocamlopt
Date: Fri, 18 Aug 2006 17:34:13 +0200	[thread overview]
Message-ID: <17637.56821.564137.320990@karryall.dnsalias.org> (raw)
In-Reply-To: <5EAC544C-8B6E-4004-B817-20190E868A3B@MIT.edu>

 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


  reply	other threads:[~2006-08-18 15:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-17 18:34 Pervasives.{min,max} " Will M Farr
2006-08-18 15:34 ` Olivier Andrieu [this message]
2006-08-18 15:37   ` [Caml-list] Pervasives.{min, max} " Will M Farr
2006-08-18 15:43   ` Shawn

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=17637.56821.564137.320990@karryall.dnsalias.org \
    --to=oandrieu@nerim.net \
    --cc=caml-list@inria.fr \
    --cc=farr@MIT.EDU \
    /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).