[ODE] Re: Deterministic simulation on multiple clients

Alen Ladavac alenl-ml at croteam.com
Mon Mar 21 10:02:34 MST 2005


Actually, there are some additional quirks to consider regarding
deterministic IEEE results:

1) On x86, internal floating point register precision is 80 bits by default,
while your data is usually stored in 32 (float) or 64 (double) bits. This
means that a set of operationations performed purely in registers will not
have the same result as is some intermediate results are stored in memory.
Having your code go in two different paths that _look_ as if they are
calculating the same formula may end in different results. This can be
caused by different compiler version, or some changes in code, or just
plainly code taking different paths due to some unrelated if statement.
Additionally, even if it takes exactly the same path, maybe some external
library (usually renderer, gfx driver, etc) changes the default precision at
some point and doesn't return it back, so on some of your frames you are
running in 32 bits internally, and on some you run on 80 bits. You can
assert against changed precision, and you should maybe even _force_ it to
the one you use for storing results in memory. Even though that doesn't
guarantee exactly same results in different code paths.

2) Again on x86, there is this thing with FPU register stack overflow.
Strangely enough, if a part of code "forgets" to pop a register off the FPU
stack, it will linger there until it causes FPU stack overflow in some other
part of code. That is, when a part that needs all 8 registers pushes its 8th
register, the ligering value from the buggy part will fall out down the
bottom of the FPU stack, but the new top value will be garbled (#NAN or
#IND, don't remember exactly), causing bogus results, which may not
immediately appear as "wrong". Since most of code doesn't use all 8 levels
of FPU stack, this problem can leak to a completely different part of the
app.

HTH,
Alen

----- Original Message -----
From: "George Birbilis" <birbilis at kagi.com>
To: <ode at q12.org>; "Henrik Grimm" <hengr at hotpop.com>
Sent: Sunday, March 20, 2005 20:59
Subject: Re: [ODE] Re: Deterministic simulation on multiple clients


> >> Also are you sure that even identical hardware won't give you
> >> different rounding errors?
> >
> > Well, I am no expert in hardware, but I think it is quite unlikely that
> > rounding is non-deterministic.
>
> nope, it should be deterministic if standard IEEE math datatypes like
single
> and double are used
>
> -----
> George Birbilis (birbilis at kagi.com)
> Microsoft Most Valuable Professional
> MVP J# for 2004 & 2005
> http://www.kagi.com/birbilis
> --------------
>
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
>



More information about the ODE mailing list