Re: Overriding libSystem's math functions
Re: Overriding libSystem's math functions
- Subject: Re: Overriding libSystem's math functions
- From: Greg Guerin <email@hidden>
- Date: Mon, 11 Dec 2006 16:25:50 -0700
Mike Blaguszewski wrote:
>The application is a multiplayer simulation game, which I'm porting to the
>Mac. The simulation needs to stay basically in sync (no cumulative errors)
>over the course of the game. It already works fine PC<->PC, since the
>binaries are identical, but PC<->Mac or even PPC<- >Intel is harder.
You have more to worry about than the standard math functions. There are
no guarantees that the FP primitives will be identical across platforms.
Add, subtract, multiply, divide could have small differences in and around
the LSBs. Intel chips use 80-bit intermediates, IIRC, while PPC does not.
If you require bit-for-bit identical behavior in all FP operations, from
primitive to transcendental, your goal is almost certainly futile, unless
you have identical software imps of all FP ops on all platforms. That's a
major cost, though.
Depending on the arithmetic used in your sim, small differences may or may
not be significant, even without considering the standard C functions.
"Sensitive dependence on initial conditions" is at the heart of most
chaotic systems behavior. See the history of the Lorenz attractor to see
how tiny differences can lead to completely different outcomes.
One way to avoid cumulative errors is to periodically insert an I-frame of
full reference data, instead of relying on the perfect repeatable precision
of infinitely many deltas. This obviously changes the sync protocol, but
it's the only way I can think of to avoid the cumulative effects of small
error terms.
<http://en.wikipedia.org/wiki/Group_of_pictures(GOP)>
I assume you have something like I-frames in the first place. It's what a
new person entering an existing sim in progress gets when they first join.
There has to be some initial reference, or you have to forbid all late
entrances. I don't know how much of this your sim supports, so maybe you
don't have I-frames or initial references. But if you do, periodically
triggering the broadcast of one should mitigate the effects of cumulative
error. It may introduce its own problems, though, such as jumpiness if the
cumulative errors are noticeably large.
>The game is mostly graphics-bound, so taking a hit in FP performance is
>probably okay. Since this is a port of an existing app, I'm trying to do
>the easiest reasonable thing that will work.
Easy, reasonable, works: pick any two.
-- GG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden