using System; using System.Runtime.CompilerServices; // Make internals visible to Unity.Burst.Editor for BurstGlobalCompilerOptions [assembly: InternalsVisibleTo("Unity.Burst.Editor")] // Make internals visible to Unity burst tests [assembly: InternalsVisibleTo("Unity.Burst.Tests.UnitTests")] [assembly: InternalsVisibleTo("Unity.Burst.Editor.Tests")] [assembly: InternalsVisibleTo("Unity.Burst.Benchmarks")] namespace Unity.Burst { // FloatMode and FloatPrecision must be kept in sync with burst.h / Burst.Backend /// /// Represents the floating point optimization mode for compilation. /// public enum FloatMode { /// /// Use the default target floating point mode - . /// Default = 0, /// /// No floating point optimizations are performed. /// Strict = 1, /// /// Reserved for future. /// Deterministic = 2, /// /// Allows algebraically equivalent optimizations (which can alter the results of calculations), it implies : /// optimizations can assume results and arguments contain no NaNs or +/- Infinity and treat sign of zero as insignificant. /// optimizations can use reciprocals - 1/x * y , instead of y/x. /// optimizations can use fused instructions, e.g. madd. /// Fast = 3, } /// /// Represents the floating point precision used for certain builtin operations e.g. sin/cos. /// public enum FloatPrecision { /// /// Use the default target floating point precision - . /// Standard = 0, /// /// Compute with an accuracy of 1 ULP - highly accurate, but increased runtime as a result, should not be required for most purposes. /// High = 1, /// /// Compute with an accuracy of 3.5 ULP - considered acceptable accuracy for most tasks. /// Medium = 2, /// /// Compute with an accuracy lower than or equal to , with some range restrictions (defined per function). /// Low = 3, } /// /// This attribute can be used to tag jobs as being Burst Compiled, and optionally set some compilation parameters. /// [AttributeUsage(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Method)] public class BurstCompileAttribute : System.Attribute { /// /// Gets or sets the float mode of operation for this burst compilation. /// /// /// The default is . /// public FloatMode FloatMode { get; set; } /// /// Gets or sets the floating point precision to use for this burst compilation. /// Allows you to trade accuracy for speed of computation, useful when you don't require much precision. /// /// /// The default is . /// public FloatPrecision FloatPrecision { get; set; } /// /// Gets or sets whether or not to burst compile the code immediately on first use, or in the background over time. /// /// The default is false, true will force this code to be compiled synchronously on first invocation. public bool CompileSynchronously { get; set; } /// /// Gets or sets whether to compile the code in a way that allows it to be debugged. /// If this is set to true, the current implementation disables optimisations on this method /// allowing it to be debugged using a Native debugger. /// /// /// The default is false. /// public bool Debug { get; set; } /// /// Gets or sets whether to disable safety checks for the current job or function pointer. /// If this is set to true, the current job or function pointer will be compiled /// with safety checks disabled unless the global 'Safety Checks/Force On' option is active. /// /// /// The default is false. /// public bool DisableSafetyChecks { get; set; } internal string[] Options { get; set; } /// /// Tags a struct/method/class as being burst compiled, with the default , and . /// /// /// /// [BurstCompile] /// struct MyMethodsAreCompiledByBurstUsingTheDefaultSettings /// { /// //.... /// } /// /// public BurstCompileAttribute() { } /// /// Tags a struct/method/class as being burst compiled, with the specified , and the default . /// /// /// /// [BurstCompile(FloatPrecision.Low,FloatMode.Fast)] /// struct MyMethodsAreCompiledByBurstWithLowPrecisionAndFastFloatingPointMode /// { /// //.... /// } /// /// /// Specify the required floating point precision. /// Specify the required floating point mode. public BurstCompileAttribute(FloatPrecision floatPrecision, FloatMode floatMode) { FloatMode = floatMode; FloatPrecision = floatPrecision; } internal BurstCompileAttribute(string[] options) { Options = options; } } }