From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id BAA29754; Tue, 21 Jan 2003 01:45:26 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA29989 for ; Tue, 21 Jan 2003 01:45:25 +0100 (MET) Received: from epexch01.qlogic.org ([63.170.40.3]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h0L0jGr16220 for ; Tue, 21 Jan 2003 01:45:21 +0100 (MET) Received: from epmailtmp.qlogic.org ([10.20.33.254]) by epexch01.qlogic.org with Microsoft SMTPSVC(5.0.2195.5329); Mon, 20 Jan 2003 18:45:22 -0600 Received: from [10.20.33.146] ([10.20.33.146]) by epmailtmp.qlogic.org with Microsoft SMTPSVC(5.0.2195.4905); Mon, 20 Jan 2003 18:45:22 -0600 Date: Mon, 20 Jan 2003 18:54:08 -0600 (CST) From: Brian Hurt X-X-Sender: Reply-To: Brian Hurt To: Nickolay Semyonov-Kolchin cc: David Chase , Subject: Re: Coyote Gulch test in Caml (was Re: [Caml-list] speed ) In-Reply-To: <200301210239.01608.snob@snob.spb.ru> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-OriginalArrivalTime: 21 Jan 2003 00:45:22.0345 (UTC) FILETIME=[61132190:01C2C0E6] Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, 21 Jan 2003, Nickolay Semyonov-Kolchin wrote: > On Tuesday 21 January 2003 02:23, David Chase wrote: > > Speed and accuracy are different things. Matlab class software need > accuracy, most computer games need speed. This is the reason of > "-ffast-math" key in gcc. Ocaml lacks such key, and always produce > ineffecient floating-point code. > >>From gcc's info: `-ffast-math' This option allows GCC to violate some ANSI or IEEE rules and/or specifications in the interest of optimizing code for speed. For example, it allows the compiler to assume arguments to the `sqrt' function are non-negative numbers and that no floating-point values are NaNs. This option should never be turned on by any `-O' option since it can result in incorrect output for programs which depend on an exact implementation of IEEE or ANSI rules/specifications for math functions. Which raises a couple of questions. The first question is wether -ffast-math mainly violates ANSI or IEEE rules. If ANSI, we're OK- we just define the Ocaml rules so we don't have to violate them. But then this brings up the issue of conformity vr.s performance. For example- the x86 has its 80-bit FP registers in 8087-legacy mode, but 64-bit registers if you're using SSE2. And PowerPC and PA-RISC both have extended precision fused multiply-adds (that keep higher precision, i.e. don't round, between the multiply and the adds). For that matter, could a "conforming" implementation of Ocaml use the 32-bit single precision SSE-1 registers? http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf http://www.cs.berkeley.edu/~wkahan/Curmudge.pdf As a general rule, I perfer the higher precision when it doesn't hurt enormously. Basically, keeping things at at least 64-bit IEEE FP is a good idea- except in special cases, the speed advantage of going down to single precision. Oh, and if we're talking about performance, memory behavior is much more important than precision of floating point primitives (so long as FP is in hardware). A complex FP operation may take tens of clock cycles- but a cache miss now takes hundreds. The most important paper about numeric performance of Ocaml might be this one: http://www.cs.princeton.edu/~mjrg/fpca95.ps.Z Brian ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners