From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: jean-marc alliot <alliot@recherche.enac.fr>
Cc: caml-list@inria.fr
Subject: Re: Some questions about floatting point issues
Date: Fri, 25 Feb 2000 17:04:00 +0100 [thread overview]
Message-ID: <20000225170400.16733@pauillac.inria.fr> (raw)
In-Reply-To: <38B26FE9.BAA12AAE@recherche.enac.fr>; from jean-marc alliot on Tue, Feb 22, 2000 at 12:15:53PM +0100
> 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
prev parent reply other threads:[~2000-02-25 17:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-02-10 13:49 Typing problem jean-marc alliot
2000-02-11 10:17 ` Pierre Weis
2000-02-12 22:34 ` Jacques Garrigue
2000-02-14 8:04 ` Thread feature missing Christophe Raffalli
2000-02-14 15:11 ` Gerd Stolpmann
2000-02-15 16:06 ` Xavier Leroy
2000-02-16 11:31 ` Christophe Raffalli
2000-02-18 9:14 ` Xavier Leroy
2000-02-21 20:38 ` skaller
2000-02-22 11:15 ` Some questions about floatting point issues jean-marc alliot
2000-02-25 16:04 ` Xavier Leroy [this message]
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=20000225170400.16733@pauillac.inria.fr \
--to=xavier.leroy@inria.fr \
--cc=alliot@recherche.enac.fr \
--cc=caml-list@inria.fr \
/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