Determinism

Same inputs. Same bits.
Every run, every machine.

GridSim gives the same answer to the last bit on every run, on Windows, Linux and macOS, on x64 and ARM64, and on every CPU tier from AVX-512 to no vector unit at all. Not close to machine epsilon: the same bits.

That is what lets a result be pinned exactly in a test, compared with another machine byte for byte, and trusted when an iterative solver runs thousands of steps.

Why it takes work

The platform does not give you this for free.

01

Maths libraries differ

Math.Sin and friends call the operating system's C maths library, and Windows, glibc and Apple round some results differently in the last place. sin(π/4) is 0x3FE6A09E667F3BCC from FDLIBM and …BCD from the Windows C runtime.

02

Hardware fuses and reorders

Fused multiply-add rounds a × b + c once instead of twice, and only some CPUs have it. Vector width changes the order of a sum, and floating-point addition is not associative.

03

Threads change orders

Any value combined across threads, or any sort that breaks ties by runtime internals, can change the order of arithmetic from one run to the next.

What GridSim does

Its own maths, one order for every sum.

Every transcendental function comes from DetMath, GridSim's own deterministic maths library.

DetMath is a line-by-line C# port of Sun's FDLIBM 5.3, the library Java's StrictMath is defined by. It is plain IEEE 754 arithmetic and integer bit work, so it gives the same bits everywhere. It is checked bit for bit against Java 21 StrictMath on special values and about 1.1 million results across 14 functions.

  • Elementary functions. Sin, Cos, SinCos, Tan, Asin, Acos, Atan, Atan2, Exp, Expm1, Log, Log10, Pow, Sinh, Cosh, Tanh, plus the complex Phase and FromPolar.
  • No fused multiply-add on any numerical path.
  • One defined order for every reduction. The vector kernels pick AVX-512, AVX2, SSE or scalar at run time, and each arm performs exactly the same IEEE operations in the same order. A dot product always sums into four partials and combines them as (s0 + s1) + (s2 + s3).
  • No cross-thread arithmetic. Parallel loops write each item to its own slot, the sort that feeds the sparse LU ordering is frozen, and every NaN that leaves the engine is canonical.
  • Dense and sparse agree to the bit. Every value, iteration count and status of the two power-flow engines is equal, and every CPU state estimate takes the same sparse step at every network size.

Enforced, not hoped for

A test reads the compiled code.

DeterministicMathGuardTests reads the compiled assemblies of the core, the GPU backend, the data bridge and the command line tool, decodes every method's IL and fails the test run on any call to a platform transcendental, a fused multiply-add or a horizontal vector reduction. Because it reads IL, a property, a qualified name or a using static cannot hide a call.

FdlibmStrictMathVectorTests proves DetMath equals Java StrictMath bit for bit. D1CrossTierTests runs every vector arm on the same input in one process and requires exactly equal results. gridsim simdcheck reports the tier your machine is using.

The same pinned results, on every CI leg
PlatformModes
Linux and Windows x64Normal; AVX2 off with FMA off; hardware intrinsics off; forced AVX-512; forced 256-bit
macOS, Apple siliconNormal; hardware intrinsics off
Linux and Windows ARM64Normal; hardware intrinsics off

Every leg is a hard gate on the same pins. A release publishes nothing unless every leg passes.

GPU

Deterministic on the GPU. Measured against the CPU.

The GPU backend sits behind the same linear-solver seam as the CPU: native ROCm (hipSOLVER, rocSPARSE) for AMD Instinct first, then OpenCL and CUDA. It is built for FP64, because the solves are double precision end to end.

GPU results are deterministic, but they are not bit-identical with the CPU. The device runs different algorithms, natural-order dense elimination and Jacobi-preconditioned BiCGSTAB to a 1e-10 residual, sums in a different order and fuses multiply-add. So the GPU is measured against the CPU instead, and a GPU solve reports how many of its Newton steps fell back to the CPU LU.

1.45e-12

Largest voltage-magnitude difference from the CPU, in per unit, over 27 MATPOWER cases on an RTX A4000.

5.2e-11

Largest angle difference from the CPU, in degrees, with the same convergence and iteration counts.

Breaking-change discipline

When a result changes, the release says so.

Any change to a numerical path ships labelled BREAKING CHANGE, with its measured size.

GridSim is too large and too configurable for anyone to prove that a change has no effect on every path a user can run. So the label does not depend on what the measured cases show; the measurements only say how big the change is.

  • RC-4 (2.1.073). The sparse LU ordering and the Newton voltage floor changed. On 66 MATPOWER cases results moved by at most 9.7e-13 pu in voltage magnitude and 1.9e-11 degrees in angle, with identical convergence and iteration counts.
  • Everything else is additive: new verbs, options, model types and event kinds. Within one version, bit identity holds.

See it for yourself

Run it twice. Compare the bytes.

Then run it on another machine and compare again.

Technical specificationSparse and GPU numerics