Table of Contents

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

device nint

The Metal device handle.

logger ILogger<MetalUnifiedMemoryOptimizer>

The logger instance.

Properties

IsAppleSilicon

Gets whether the system is running on Apple Silicon with unified memory.

public bool IsAppleSilicon { get; }

Property Value

bool

IsUnifiedMemory

Gets whether the device has unified memory architecture.

public bool IsUnifiedMemory { get; }

Property Value

bool

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

sizeInBytes long

The allocation size in bytes.

pattern MemoryUsagePattern

The 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

options MemoryOptions

The 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

pattern MemoryUsagePattern

The 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

sizeInBytes long

The size of the zero-copy operation.