BurstCompile FloatMode, FloatPrecision, Compile Async

Hello, so I was trying to look up some in depth info about the burst attributes, but I can’t find anything clear enough.

Example:

[BurstCompile(FloatMode = FloatMode.Fast,FloatPrecision = FloatPrecision.Low,CompileSynchronously = true)]

What exactly do all these parameters do? I know that FloatMode.Fast is obviously faster than standard for example, but I’m looking for in depth information. How much faster? How much precision is exactly sacrificed? If FloatPrecision represents float precision (as in number of decimals), then what does the float mode Fast sacrifice in order to get that extra speed compared to FloatMode.Default? Even then, is FloadMode.Default actually slower or faster than FloatMode.Fast?

FloatMode:

Specifically, I want to know more about FloatMode.Default, .Fast, .Deterministic and .Strict. Is Strict faster than Fast? What exactly does Strict mean? Is default deterministic? If so, what’s the difference between default and deterministic?

Float precision:

I assume a High precision float would have more decimals than a Low one. If that’s not the case, what exactly does it do? If it is the case, how much precision is exactly lost/gained for every step in number of decimals?

Compile synchronously:

The documentation says ‘Gets or sets whether or not to burst compile the code immediately on first use, or in the background over time’. Why would you want to compile it in the background over time? Does that mean that compilation is being done even, say, 10 minutes after program start if set to false? Why would anyone want to set that to false?

1 Like

The documents are actually pretty detailed on this. Not sure what you’re reading.

https://docs.unity3d.com/Packages/com.unity.burst@latest/

Seems to answer all your questions.

1 Like

As @tertle said, our docs are quite detailed about FloatPrecision and FloatMode:
https://docs.unity3d.com/Packages/com.unity.burst@latest

To expand a bit on CompileSynchronously:

  • This is only relevant for play mode in the editor (i.e. it’s ignored when building a standalone player).
  • If CompileSynchronously=false (the default), then while Burst is compiling your code in the background, your code will be run using Mono. You would want to set CompileSynchronously=true when you’re doing profiling, or are writing deterministic code where you don’t want it to ever run on Mono.

Lee actually covered this stuff in his Unite talk - here are links to the relevant time codes:

3 Likes

Hmm I did check that page, but I somehow managed to miss that information. I should probably stop doing this kind of stuff so late at night.

Anyway, thanks for the links! Also, good to know that CompileAsync is editor mode only.

2 Likes