From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA00864 for caml-redistribution@pauillac.inria.fr; Fri, 25 Feb 2000 18:05:07 +0100 (MET) Resent-Message-Id: <200002251705.SAA00864@pauillac.inria.fr> 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 RAA29347 for ; Fri, 25 Feb 2000 17:04:02 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id RAA02010; Fri, 25 Feb 2000 17:04:02 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA19412; Fri, 25 Feb 2000 17:04:00 +0100 (MET) Message-ID: <20000225170400.16733@pauillac.inria.fr> Date: Fri, 25 Feb 2000 17:04:00 +0100 From: Xavier Leroy To: jean-marc alliot Cc: caml-list@inria.fr Subject: Re: Some questions about floatting point issues References: <20000211111749.34427@pauillac.inria.fr> <20000213073403Q.garrigue@kurims.kyoto-u.ac.jp> <38A7B721.172F585C@univ-savoie.fr> <20000215170653.54672@pauillac.inria.fr> <38AA8A8B.17558090@univ-savoie.fr> <20000218101403.40695@pauillac.inria.fr> <38B1A244.2B0F5832@maxtal.com.au> <38B26FE9.BAA12AAE@recherche.enac.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1 In-Reply-To: <38B26FE9.BAA12AAE@recherche.enac.fr>; from jean-marc alliot on Tue, Feb 22, 2000 at 12:15:53PM +0100 Resent-From: weis@pauillac.inria.fr Resent-Date: Fri, 25 Feb 2000 18:05:07 +0100 Resent-To: caml-redistribution@pauillac.inria.fr > The problem is that, to write a correct interval library, you have to > use some processor specific features regarding rounding mode (you have > to turn it to rounding towards minus infinity when computing lower > bounds, towards plus infinity when computing upper bound, etc). > > I wrote the assembly language routines to do the trick, but I have a few > questions: > 1) What is the default mode turned on by ocaml (I suppose it is rounding > towards nearest?) Caml doesn't change the rounding mode, it leaves whatever mode the C run-time system sets before starting the Caml program. (Not quite: on buggy libc's, e.g. libc 5 under Linux, Caml used to change the mode at start-up to enable NaNs and other IEEE features, but this is no longer necessary with Linux libc 6.) > 2) Is this mode often reinforced (before each floatting point operation) > or is it only set once? It is never reinforced. On the x86, float->int conversion changes the rounding mode temporarily, but restores the original mode on exit. > 3) Is it possible to tell ocamlopt to inline a few lines of assembly > code? Changing the FPU mode is very fast (two "mov", one "and" and one > "or") and it is a pity to suffer the overhead of one function call each > time. I agree that an inline asm facility would sometimes be useful, but there is currently no such thing in Caml. One little trick: assuming your C function to change mode doesn't allocate and doesn't raise exceptions, you could declare it as external changemode : unit -> unit = "changemode" "noalloc" The "noalloc" qualifier allows ocamlopt to generate a faster call to the C routine. - Xavier Leroy