From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 74D43BB91 for ; Thu, 13 Jan 2005 20:01:37 +0100 (CET) Received: from biscayne-one-station.mit.edu (BISCAYNE-ONE-STATION.MIT.EDU [18.7.7.80]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j0DJ1aUC024033 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 13 Jan 2005 20:01:37 +0100 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by biscayne-one-station.mit.edu (8.12.4/8.9.2) with ESMTP id j0DJ1XFN007761; Thu, 13 Jan 2005 14:01:33 -0500 (EST) Received: from [192.168.1.104] (CSR-DYN-83.MIT.EDU [18.75.3.83]) (authenticated bits=0) (User authenticated as farr@ATHENA.MIT.EDU) by outgoing.mit.edu (8.12.4/8.12.4) with ESMTP id j0DJ1QBO007825 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT); Thu, 13 Jan 2005 14:01:26 -0500 (EST) In-Reply-To: References: <3D3A6BF5-657B-11D9-A551-000393A34E82@mit.edu> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <850815AC-6595-11D9-A551-000393A34E82@mit.edu> Content-Transfer-Encoding: 7bit Cc: caml-list@yquem.inria.fr, shootout-list@lists.alioth.debian.org From: "Will M. Farr" Subject: Re: [Caml-list] Ocaml sums the harmonic series -- four ways, four benchmarks: floating point performance Date: Thu, 13 Jan 2005 14:01:24 -0500 To: John Prevost X-Mailer: Apple Mail (2.619) X-Scanned-By: MIMEDefang 2.42 X-Miltered: at nez-perce with ID 41E6C590.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 powerpc:01 ocamlopt:01 ocamlopt:01 unrolling:01 prevost:01 wrote:01 wrote:01 invocation:01 -unsafe:01 -noassert:01 int-:01 ocaml:01 slowest:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: Is the PowerPC ocamlopt back-end less optimized than the x86? I didn't realize that ocamlopt did enough optimizations that the backend would be substantially different on the different architectures (in the manual they say that it compiles the code essentially as written -- no loop unrolling, etc). Are you sure that there isn't just a built-in instruction on the x86 that adds an int to a float? Will On 13 Jan 2005, at 12:29 PM, John Prevost wrote: > On Thu, 13 Jan 2005 10:53:16 -0500, Will M. Farr wrote: >> Each invocation was compiled with "ocamlopt -unsafe -noassert >> -o harmonic harmonic.ml". It looks like using references and >> loops is *by far* the fastest (and also that my PowerBook is >> pretty slow to convert int->float, but I don't think this is >> related to ocaml, since the C version does the same thing). > > Note that this is dependent on what CPU you're using. On my test > system (700MHz AMD Athlon with 256MB of memory), I saw this behavior: > > time ./harmonic 1000000000: > > harmonic: > you: 2m01.590s .. 0m00.790s > me: 0m30.811s .. 0m00.120s > > harmonic2: > you: 2m00.340s .. 0m00.440s > me: 0m30.847s .. 0m00.140s > > harmonic3: > you: 1m44.350s .. 0m00.740s > me: 0m38.002s .. 0m00.130s > > harmonic4: > you: 1m12.680s .. 0m00.430s > me: 1m14.603s .. 0m00.220s > > So on this system, harmonic4 is by far the slowest, and the fastest > version is the one that uses float_of_int and tail recursion. It's > unclear to me how much of this is that the Intel compiler is simply > better optimized than the PPC compiler. > > John.