> 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
This archive was generated by hypermail 2b29 : Fri Feb 25 2000 - 18:08:40 MET