Firstborn/Library/PackageCache/com.unity.burst@1.7.3/Documentation~/docs/CSharpLanguageSupport_Intri...
Schaken-Mods b486678290 Library -Artifacts
Library -Artifacts
2023-03-28 12:24:16 -05:00

1.5 KiB

Intrinsics

System.Math

Burst provides an intrinsic for all methods declared by System.Math except for the following methods that are not supported:

  • double IEEERemainder(double x, double y)
  • Round(double value, int digits)

System.IntPtr

Burst supports all methods of System.IntPtr/System.UIntPtr, including the static fields IntPtr.Zero and IntPtr.Size

System.Threading.Interlocked

Burst supports atomic memory intrinsics for all methods provided by System.Threading.Interlocked (e.g Interlocked.Increment...etc.)

Care must be taken when using the interlocked methods that the source location being atomically accessed is naturally aligned - e.g. the alignment of the pointer is a multiple of the pointed-to-type.

For example:

[StructLayout(LayoutKind.Explicit)]
struct Foo
{
    [FieldOffset(0)] public long a;
    [FieldOffset(5)] public long b;

    public long AtomicReadAndAdd()
    {
        return Interlocked.Read(ref a) + Interlocked.Read(ref b);
    }
}

Let's assume that the pointer to the struct Foo has an alignment of 8 - the natural alignment of a long value. The Interlocked.Read of a would be successful because it lies on a naturally aligned address, but b would not. Undefined behaviour will occur at the load of b as a result.

System.Threading.Thread

Burst supports the MemoryBarrier method of System.Threading.Thread.

System.Threading.Volatile

Burst supports the non-generic variants of Read and Write provided by System.Threading.Volatile.