Class MetalUnifiedMemoryOptimizer
- Namespace
- DotCompute.Backends.Metal.Memory
- Assembly
- DotCompute.Backends.Metal.dll
Optimizer for unified memory access patterns on Apple Silicon.
public sealed class MetalUnifiedMemoryOptimizer : IDisposable
- Inheritance
-
MetalUnifiedMemoryOptimizer
- Implements
- Inherited Members
- Extension Methods
Remarks
⚠️ STUB IMPLEMENTATION - Metal backend in development. Provides optimization hints for unified memory architectures (M1/M2/M3/M4).
Constructors
MetalUnifiedMemoryOptimizer(nint, ILogger<MetalUnifiedMemoryOptimizer>)
Initializes a new instance of the MetalUnifiedMemoryOptimizer class.
public MetalUnifiedMemoryOptimizer(nint device, ILogger<MetalUnifiedMemoryOptimizer> logger)
Parameters
devicenintThe Metal device handle.
loggerILogger<MetalUnifiedMemoryOptimizer>The logger instance.
Properties
IsAppleSilicon
Gets whether the system is running on Apple Silicon with unified memory.
public bool IsAppleSilicon { get; }
Property Value
IsUnifiedMemory
Gets whether the device has unified memory architecture.
public bool IsUnifiedMemory { get; }
Property Value
Methods
Dispose()
Disposes the memory optimizer.
public void Dispose()
EstimatePerformanceGain(long, MemoryUsagePattern)
Estimates the performance gain for the given allocation.
public double EstimatePerformanceGain(long sizeInBytes, MemoryUsagePattern pattern)
Parameters
sizeInByteslongThe allocation size in bytes.
patternMemoryUsagePatternThe memory usage pattern.
Returns
- double
The estimated performance multiplier (1.0 = no gain).
GetOptimalStorageMode(MemoryOptions)
Gets the optimal storage mode for the given memory options.
public MetalStorageMode GetOptimalStorageMode(MemoryOptions options)
Parameters
optionsMemoryOptionsThe memory options.
Returns
- MetalStorageMode
The optimal Metal storage mode.
GetOptimalStorageMode(MemoryUsagePattern)
Gets the optimal storage mode for the given memory usage pattern.
public MetalStorageMode GetOptimalStorageMode(MemoryUsagePattern pattern)
Parameters
patternMemoryUsagePatternThe memory usage pattern.
Returns
- MetalStorageMode
The optimal Metal storage mode.
TrackZeroCopyOperation(long)
Tracks a zero-copy operation for statistics.
public void TrackZeroCopyOperation(long sizeInBytes)
Parameters
sizeInByteslongThe size of the zero-copy operation.