Are floating point numbers deterministic on the same architecture? (IL2CPP)

Hi everyone,
recently I learned that within Burst floating point math is deterministic on the same architecture,
does the same hold true outside of Burst on IL2CPP?

Currently, where I need determinism outside of Burst I’m using soft floats.
Using normal floats would of course be a lot more convenient.

I do not need cross-platform or cross-architecture determinism.
Only x64: AMD ↔ Intel.

No, for IL2CPP we don’t have deterministic floating point calculations between architectures.

Thanks for your reply,
are floating point calculations deterministic on the same architecture?
Do floating point calculations have the same result on, for instance, x64 Intel and x64 AMD machines?

I worked on a game using Unity 2017.1 which relied on deterministic floats, but it used Mono, not IL2CPP. We wrote a test function to perform various calculations and print the actual binary results and everything relevant to the game matched on Intel and AMD, including transform manipulations.

We did hit an issue involving animations, however. It was a fighting game where the hit boxes followed the characters’ joints, and a few animations for a specific character caused the transforms to break determinism. We assumed Unity used SIMD for animation (which are more prone to differ between architectures), but didn’t figure out why it happened to one character but not the others. We got around it by pre-calculating the hitbox positions for all animations into scriptable objects instead.

Also, the game did not use PhysX physics at all.

My suggestion is to test it like we did: write a function that performs all the calculations you can think of and prints the floats’ raw bits. You can save those values then run the function on different PCs to compare the results.

2 Likes

We don’t make any guarantees about this, but so long as you are using the same C++ compiler to build the generated C++ code, I think that there should be no differences.

I agree with @Neto_Kokku though - you definitely want to test and validate this.

1 Like