Deterministic across IA32 processors

thelovegoose
Posts: 7
Joined: Tue Nov 16, 2010 9:14 pm

Deterministic across IA32 processors

Post by thelovegoose »

Is it possible to get deterministic results across all major IA32 processors?
Apologies if this has been asked before, I have searched the forum for the answer, but all relevant information seems to be geared toward determinism on the same machine.
We have a multiplayer physics based RTS that currently uses physx but have unfortunately discovered that its not deterministic across processors.

Has anyone successfully achieved this?

I'm planning to test bullet and other physics libraries over the next few weeks, but would greatly appreciate some advice before I start so I'm not wasting my time, and some clues on what compiler options/ preprocessor definition I might need to build with,

Edit: We're only planning to use the most simple physics eg : convex shapes, forces, collision detection, character controllers.

Cheers,

Peter

Heres a quick look at the game :

Image
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Deterministic across IA32 processors

Post by Erwin Coumans »

It is highly unlikely to achieve across IA32 processors, unless you are running the same operating system and compile using the same compiler with identical settings.
Is that the case?

What differences did you find with different processors? Could it be that the code path is different because differences in CPUs SIMD version etc?
Thanks,
Erwin
thelovegoose
Posts: 7
Joined: Tue Nov 16, 2010 9:14 pm

Re: Deterministic across IA32 processors

Post by thelovegoose »

Hi Erwin,

We will be using a single compiler, with identical settings and the game is only for windows, and only supporting IA32 processors.
I don't actually know at the moment what the cause of the non deterministic results we found with physx are. There is very little information about it available and its closed source.

What I'm hoping is, if we build bullet with the fp model set to the consistent settings, sacrificing some or all optimizations, we can get the floating point calculations to be exactly the same on all our target processors.

Do you have any reason to believe that that wouldn't be possible?
thelovegoose
Posts: 7
Joined: Tue Nov 16, 2010 9:14 pm

Re: Deterministic across IA32 processors

Post by thelovegoose »

  • Does bullet use any SSE(1/2/3)/MMX compiler intrinsics or assembly?
    It turns out that one of the reasons why physx is not deterministic across different processors is because they scale up or down the number of solvers based on the 'power' of the processor. I take it youre not doing anything like that with bullet?
    Where you iterate over collections, are they always explicitly ordered? Ie there is no ordering over stl::maps etc where the ordering can be different dependent on platform?
    Do you set controlfp anywhere in the code?
    Is one single precision used throughout bullet (eg float). Is it possible to configure this?
Cheers again,

Pete

If the answers to the above are all positive, then, to my knowledge there should be no reason why it can't be made deterministic across processors (with a single compiler & operating system). I have already succeeded in getting a fairly floating point intensive program deterministic across processors, there's no reason why a physics library should be any different (I hope!).
I'm going to be testing this over the next week so I'll let you know how I get on, and I'm happy to share details of how to get it deterministic across processors if anyone is interested.
Also, should this succeed, you should make it known that this is possible with bullet, there is growing interest in this capability!
thelovegoose
Posts: 7
Joined: Tue Nov 16, 2010 9:14 pm

Re: Deterministic across IA32 processors

Post by thelovegoose »

Bullet is deterministic across all x86 processors if you use controlfp at the beginning of your application, and after calls to external dlls. You will also need to stick to single threaded and disable randomization of solvers. In my tests I used floats and comipled with x87 instructions only (suited to my needs) but it may also be deterministic with SSE (& SSE2), and using doubles.
A quick warning - opengl (used in the demos) can reset the floating-point control word!

Thats about it but if anyone would like more detail, or copies of the test and or results let me know,

Cheers,

Pete