My goal is to run a simulation that requires non-integer numbers on different machines, which may have different architectures and processor OSs. The main priority is that with the same initial state, each machine should reproduce the simulation in exactly the same way. The secondary priority is that I would like the calculations to have performance and accuracy as much as possible to swim with double precision.
As far as I can tell, there is no way to influence the determinism of floating point calculations from the Haskell program, similar to the _controlfp and _FPU_SETCW in C. So, at the moment, I consider my parameters
One problem with fixed point arithmetic libraries is that they do not, for example. trigonometric functions or the logarithms defined for them (because they do not implement a class of type Floating ), so I assume that I will need to provide lookup tables for all functions in the semantic data of the simulation. Or is there a better way?
Both fixed-point libraries also hide the newtype constructor, so any (maladaptation) serialization should be done using toRational / fromRational , as far as I can tell, and it looks like it will add unnecessary overhead.
My next step is to compare different fixed-point solutions to see the real world performance, but in the meantime, I am happy to accept any advice on this.
shang source share