From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 37FFFBC4E for ; Fri, 18 Aug 2006 17:34:14 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k7IFYD8U019749 for ; Fri, 18 Aug 2006 17:34:13 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA19628 for ; Fri, 18 Aug 2006 17:34:12 +0200 (MET DST) Received: from kraid.nerim.net (smtp-105-friday.nerim.net [62.4.16.105]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k7IFYCKB025858 for ; Fri, 18 Aug 2006 17:34:12 +0200 Received: from karryall.dnsalias.org (karryall.dnsalias.org [213.41.240.180]) by kraid.nerim.net (Postfix) with ESMTP id C422E41092; Fri, 18 Aug 2006 17:34:11 +0200 (CEST) Received: by karryall.dnsalias.org (Postfix, from userid 500) id 98F0E42EFF2; Fri, 18 Aug 2006 17:34:13 +0200 (CEST) From: Olivier Andrieu MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17637.56821.564137.320990@karryall.dnsalias.org> Date: Fri, 18 Aug 2006 17:34:13 +0200 To: Will M Farr Cc: caml-list@inria.fr Subject: Re: [Caml-list] Pervasives.{min, max} not specialized to floats by ocamlopt In-Reply-To: <5EAC544C-8B6E-4004-B817-20190E868A3B@MIT.edu> References: <5EAC544C-8B6E-4004-B817-20190E868A3B@MIT.edu> X-Mailer: VM 7.19 under Emacs 21.4.1 X-Miltered: at concorde with ID 44E5DDF5.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; andrieu:01 oandrieu:01 pervasives:01 ocamlopt:01 ocamlopt:01 val:01 inference:01 pervasives:01 runtime:01 nans:01 2006:98 caml-list:01 functions:01 functions:01 nerim:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 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