performance - What's the most efficient way to run cross-platform, deterministic simulations in Haskell? -


my goal run simulation requires non-integral numbers across different machines might have varying cpu architectures , oses. main priority given same initial state, each machine should reproduce simulation same. secondary priority i'd calculations have performance , precision close realistically possible double-precision floats.

as far can tell, there doesn't seem way affect determinism of floating point calculations within haskell program, similar _controlfp , _fpu_setcw macros in c. so, @ moment consider options be

  1. use data.ratio
  2. use data.fixed
  3. use data.fixed.binary fixed-point package
  4. write module call _ controlfp (or equivivalent each platform) via ffi.
  5. possibly, else?

one problem fixed point arithmetic libraries don't have e.g. trigonometric functions or logarithms defined them (as don't implement floating type-class) guess need provide lookup tables functions in simulation seed data. or there better way?

both of fixed point libraries hide newtype constructor, (de-)serialization need done via torational/fromrational far can tell, , feels add unnecessary overhead.

my next step benchmark different fixed-point solutions see real world performance, meanwhile, i'd gladly take advice have on subject.

clause 11 of ieee 754-2008 standard describes needed reproducible floating-point results. among other things, need unambiguous expression evaluation rules. languages permit floating-point expressions evaluated precision or permit alterations of expressions (such evaluating a*b+c in single instruction instead of separate multiply , add instructions). not know haskell’s semantics. if haskell not precisely map expressions definite floating-point operations, cannot support reproducible floating-point results.

also, since mention trigonometric , logarithmic functions, aware these vary implementation implementation. not aware of math library provides correctly rounded implementations of every standard math function. (crlibm project create one.) each math library uses own approximations, , results vary slightly. perhaps might work around including math library simulation code, used instead of each haskell implementation’s default library.

routines convert between binary floating-point , decimal numerals source of differences between implementations. less of problem used because algorithms converting correctly known. however, might need checked in each implementation.


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -