trying to make GPU physics deterministic

Started by
6 comments, last by lomateron 8 years, 9 months ago

I have to tryyyyyy

stuck with directx 10

1 update every 1/250 seconds

every 4 updates the input changes

IEEE stricness(/Gis) doesn't works

so I thought about using ints textures

every integer 0 to 2^24 can be represented in float(meaning I could still use float textures but operating with them as ints)

the resolution of the physics space will be 2^24 places, velocity and force vectors will have this resolution too

but then in HLSL sqrt(), it only works with floats, there are some functions that I could use like http://stackoverflow.com/questions/4930307/fastest-way-to-get-the-integer-part-of-sqrtn

but in the end will this work will it be too slow what do you think? any recommendations?

Advertisement

You have already asked this question.

If you mean by determinism on the same GPU, same driver, only different drivers; then just provide exactly the same input and remove any other source of undeterminism (uninitialized buffers, textures, etc) and be sure the data you're retrieving is serialized.

If you're asking about integers, they are also not deterministic between GPUs either. GCN clearly doesn't follow modulo-2 overflow rules for 32 bit int multiplication (I've tried); and some hardware may use floating point to emulate 24-bit multiplication ints.

Getting strict integer math as defined in the CPU ISA is something you need to consult with the IHV for the particular models you want to target.

GCN clearly doesn't follow modulo-2 overflow rules for 32 bit int multiplication

can you give an example plz, don't understand, are there other int operations that aren't deterministic?

I mean determinism by different gpu, AMD, NVIDIA, INTEL making them all produce same output every step in my updates using the same .exe and .fxo

can you give an example plz, don't understand, are there other int operations that aren't deterministic?

Last time I tried stuff like 2147483000u * 10u I got garbage instead of the expected 4294960816u. Can't remember the exact operation. I think it may have been bitshifts instead of multiplications.

You will obviously get the same behavior on every run on the same GPU with the same drivers.
But if you want cross-GPU determinism with integers you will have to be careful with "special situations" like overflow, underflow, and exceeding the 24-bit range (can't remember what the DX10 specs said on this). It may be possible but you will have to test a lot.

can you give an example plz, don't understand, are there other int operations that aren't deterministic?

Last time I tried stuff like 2147483000u * 10u I got garbage instead of the expected 4294960816u. Can't remember the exact operation. I think it may have been bitshifts instead of multiplications.

Is there any chance this could have been a driver/compiler issue? On the OpenCL compiler I've seen it forgetting about data hazards. It eventually got fixed.

Previously "Krohm"

This should be possible depending on the graphics card/drivers.

http://www.geeks3d.com/20110609/floating-point-and-ieee-754-compliance-for-nvidia-gpus/

Is there any chance this could have been a driver/compiler issue? On the OpenCL compiler I've seen it forgetting about data hazards. It eventually got fixed.

It's very possible, yes. However OP wants to do deterministic behaviour regardless of the GPU used, and things like driver/compiler bugs are an important factor. I tried that snippet around 3 months ago. If it was a driver bug, issues like this are still very current.

I am doing collision physics of spheres on GPU

I am doing the multiplayer by only sending user input so determinism is very important

One PC has new nvidia and other has old ATI

when I use floats in physics code I just have to wait less than 1 sec and I would see all balls in completely different position and as I said IEEE stricness(/Gis) doesn't works

now that I use uint-int, it works, waited 5 minutes in a very chaotic place, 1000 balls with explosions and collisions and all balls positions stay exactly same between 2 PCs

This topic is closed to new replies.

Advertisement