Class NumaMemoryManager
- Namespace
- DotCompute.Backends.CPU.Threading.NUMA
- Assembly
- DotCompute.Backends.CPU.dll
NUMA-aware memory allocation and management.
public sealed class NumaMemoryManager : IDisposable
- Inheritance
-
NumaMemoryManager
- Implements
- Inherited Members
- Extension Methods
Remarks
Initializes a new instance of the NumaMemoryManager class.
Constructors
NumaMemoryManager(NumaTopology)
NUMA-aware memory allocation and management.
public NumaMemoryManager(NumaTopology topology)
Parameters
topologyNumaTopologyNUMA topology information.
Remarks
Initializes a new instance of the NumaMemoryManager class.
Properties
ActiveAllocations
Gets the number of active allocations.
public int ActiveAllocations { get; }
Property Value
TotalAllocatedBytes
Gets the total number of bytes allocated.
public long TotalAllocatedBytes { get; }
Property Value
Methods
AllocateAny(nuint)
Allocates memory on any available node.
public nint AllocateAny(nuint size)
Parameters
sizenuintSize in bytes.
Returns
- nint
Pointer to allocated memory or IntPtr.Zero if allocation failed.
AllocateInterleaved(nuint, params int[])
Allocates memory using interleaved policy across multiple nodes.
public nint AllocateInterleaved(nuint size, params int[] nodeIds)
Parameters
Returns
- nint
Pointer to allocated memory or IntPtr.Zero if allocation failed.
AllocateOnNode(nuint, int)
Allocates memory on a specific NUMA node.
public nint AllocateOnNode(nuint size, int nodeId)
Parameters
Returns
- nint
Pointer to allocated memory or IntPtr.Zero if allocation failed.
AllocatePreferred(nuint)
Allocates memory with automatic node selection based on current thread affinity.
public nint AllocatePreferred(nuint size)
Parameters
sizenuintSize in bytes.
Returns
- nint
Pointer to allocated memory or IntPtr.Zero if allocation failed.
AllocateSystem(nuint)
Allocates memory using system default allocation.
public nint AllocateSystem(nuint size)
Parameters
sizenuintSize in bytes.
Returns
- nint
Pointer to allocated memory or IntPtr.Zero if allocation failed.
CreateMemoryScope(int)
Creates a memory allocation scope that sets preferred node.
public IDisposable CreateMemoryScope(int nodeId)
Parameters
nodeIdintNode ID to prefer.
Returns
- IDisposable
Disposable memory scope.
Dispose()
Disposes of the memory manager and frees all managed allocations.
public void Dispose()
Free(nint)
Frees previously allocated memory.
public bool Free(nint memoryAddress)
Parameters
memoryAddressnintAddress of memory to free.
Returns
- bool
True if memory was freed successfully.
GetAllocationInfo(nint)
Gets allocation information for a memory address.
public AllocationInfo? GetAllocationInfo(nint memoryAddress)
Parameters
memoryAddressnintMemory address.
Returns
- AllocationInfo
Allocation information or null if not found.
GetMemoryStatistics()
Gets memory statistics for all allocations.
public MemoryStatistics GetMemoryStatistics()
Returns
- MemoryStatistics
Memory allocation statistics.
MigrateMemory(nint, int)
Migrates memory from one node to another (if supported by platform).
public bool MigrateMemory(nint memoryAddress, int targetNodeId)
Parameters
Returns
- bool
True if migration was successful or not needed.
SetPreferredNode(int)
Sets the preferred NUMA node for future allocations.
public void SetPreferredNode(int nodeId)
Parameters
nodeIdintPreferred node ID.