Files
Misaki.HighPerformance/Misaki.HighPerformance.LowLevel/Buffer/AllocationOption.cs
Misaki f8b11182a9 Refactor allocation flags, SPMD API, and cleanup
Replaced HasFlag with HasOption for allocation flags to avoid boxing and improve performance. Added AllocationOptionExtensions. Reduced FreeListChunkSize default. Removed redundant allocation handle checks. Renamed MultipleAdd to MultiplyAdd in SPMD interfaces and implementations, updating all usages. Expanded SPMD lane interface with new mask/scatter methods and XML docs. Updated GGX jobs and allocation tests. Bumped assembly versions.
2026-05-07 17:07:10 +09:00

49 lines
1.7 KiB
C#

using System.Runtime.CompilerServices;
namespace Misaki.HighPerformance.LowLevel.Buffer;
[Flags]
public enum AllocationOption : byte
{
/// <summary>
/// Default allocation option. Values are uninitialized.
/// </summary>
None = 0,
/// <summary>
/// Clear the memory to zero upon allocation.
/// </summary>
Clear = 1 << 0
}
internal static class AllocationOptionExtensions
{
// HasFlag still cuase boxing in debug mode, so we implement our own version of HasFlag to avoid boxing.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool HasOption(this AllocationOption options, AllocationOption flag)
{
return (options & flag) != 0;
}
}
[Obsolete("Use AllocationHandle instead.")]
public enum Allocator : byte
{
// Make the first allocator as invalid because we don't want to user create a default collection without passing any parameters
/// <summary>
/// The invalid allocator. This value is reserved and should not be used for actual memory allocations. It can be used to indicate an uninitialized or invalid state in allocation scenarios.
/// </summary>
Invalid,
/// <summary>
/// Allocator for temporary allocations. Allocations are automatically released after use automatically.
/// </summary>
Temp,
/// <summary>
/// Allocator for persistent allocations using a free list. Allocations are not automatically released after use, but can be reused to reduce fragmentation, system call and improve performance.
/// </summary>
FreeList,
/// <summary>
/// Allocator for persistent allocations. Allocations are not automatically released after use.
/// </summary>
Persistent,
}