[MLton-user] IEEEReal rounding not working

Sean McLaughlin seanmcl at gmail.com
Fri Jul 27 05:41:20 PDT 2007


Hi Matthew,

  Thank you very much for your prompt response!

As for interval arithmetic, a main concern of mine is that
the sqrt function rounds correctly given the rounding mode, as specified
in IEEE754.  This function is heavily used in my application, and some
compilers have been known not to follow the standard in this regard. This
makes a "by-hand" sqrt computation necessary, a performance penalty.
So the following code should be guaranteed to contain the mathematical
value:

  (* assumes rounding down *)
  fun sqrt (lo,hi) =
      let
        val lo' = Math.sqrt lo
        val _ = up()
        val hi' = Math.sqrt hi
      in
        down();
        (lo',hi')
      end

Sadly the transcendental functions are not so specified, so I have no other
expectations of the math library.

Best,

Sean

On 7/26/07, Matthew Fluet <fluet at tti-c.org> wrote:
>
>
> >>  I'd hate to lose optimizations, as I switched from O'Caml because the
> >>  floating point computations were so much faster in my application.
> >
> > My guess is that it wouldn't be that bad.  I suspect that floating-point
> > operations susceptible to CSE are rare; certainly, much rarer than
> integer,
> > array/vector, and tuple operations susceptible to CSE.
>
> I checked in the change to the treatment of floating-point operations; it
> has a negligible effect on the floating-point intensive benchmarks.  I
> suspect that the performance improvement over OCaml mainly comes from
> MLton using unboxed reals.
>
> MLton0 -- ~/devel/mlton/mlton.svn.trunk/build/bin/mlton (* FP ops
> Functional *)
> MLton1 -- ~/devel/mlton/mlton.svn.trunk.fpops/build/bin/mlton (* FP ops
> DependsOnState *)
> run time ratio
> benchmark       MLton0 MLton1
> barnes-hut        1.00   1.02
> fft               1.00   0.96
> hamlet            1.00   1.00
> mandelbrot        1.00   1.00
> matrix-multiply   1.00   1.03
> nucleic           1.00   1.00
> ray               1.00   1.01
> raytrace          1.00   1.01
> simple            1.00   1.00
> tensor            1.00   1.00
> tsp               1.00   1.03
> tyan              1.00   1.00
> vliw              1.00   0.99
> zern              1.00   1.00
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mlton.org/pipermail/mlton-user/attachments/20070727/08aab443/attachment.html


More information about the MLton-user mailing list