Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If your program is parallelized, as it might be to run on a quad core, then it may well be non-deterministic.</p> <p>Imagine that you have 4 processors adding a floating point value to the same memory location. Then you might get</p> <pre><code>(((InitialValue+P1fp)+P2fp)+P3fp)+P4fp </code></pre> <p>or</p> <pre><code>(((InitialValue+P2fp)+P3fp)+P1fp)+P4fp </code></pre> <p>or any of the other possible orderings.</p> <p>Heck, you might even get </p> <pre><code> InitialValue+(P2fp+P3fp)+(P1fp+P4fp) </code></pre> <p>if the compiler is good enough.</p> <p>Unfortunately, floating point addition is not commutative or associative. Real number arithmetic is, but floating point is not, because of rounding, overflow, and underflow.</p> <p>Because of this, parallel FP computation is often non-deterministic. "Often", because programs that look like </p> <pre><code> on each processor while( there is work to do ) { get work calculate result add to total } </code></pre> <p>will be non-deterministic, because the amount of time that each takes may vary widely - you can't predict the order of operations. (Worse if the threads interact.)</p> <p>But not always, because there are styles of parallel programming that are deterministic.</p> <p>Of course, what many folks who care about determinism do is work in integer or fixed point to avoid the problem. I am particularly fond of superaccumulators, 512, 1024, or 2048 bit numbers that floating point numbers can be added to, without suffering rounding errors.</p> <hr> <p>As for a single threaded application: the compiler may rearrange the code. Different compilations may give different answers. But any particular binary should be deterministic.</p> <p>Unless... you are working in a dynamic language. That performs optimizatuions that reorder the FP computations, that vary over time.</p> <p>Or unless... really long shot: Itanium had some features, like the ALAT, that made even single threaded coded non-deterministic. You are unlikely to be affected by these.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload