lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> I think the main difficulty is reproducibility of floating-point calculations

Most platforms now use IEEE 754 and so should yield reproducible
floating-point calculations, but perhaps you should use "make ansi"
to avoid all smart macros in luaconf.h.

Note that, unlike C code, Lua evaluates arithmetic expressions by always
storing intermediate results in memory and I think this alone should
ensure reproducibility, provided lua_Numbers have the same precision.
(In C intermediate results might be held in higher precision in the FP
processor.)

> My plan is to replace the arithmetic macros in luaconf.h and the
> function calls lmathlib.c with calls to the relevant functions in the
> MPFR library,

That should be easy to do. I'd be interested in seeing the results.

>I am also concerned about ensuring reproducible order of execution.

In the standard implementation Lua already has this.

> If I compile with gcc using -O0, will that suffice?

I'd be surprised if the C code in Lua depended on order of execution,
so that shouldn't make a difference, but again I'd be interested in
your findings. Please report.