Table of Contents

Class MetalExecutionManager

Namespace
DotCompute.Backends.Metal.Execution
Assembly
DotCompute.Backends.Metal.dll

Unified Metal execution manager that orchestrates all execution components, integrating with the existing Metal backend architecture for production-grade usage.

public sealed class MetalExecutionManager : IDisposable
Inheritance
MetalExecutionManager
Implements
Inherited Members
Extension Methods

Constructors

MetalExecutionManager(nint, ILogger<MetalExecutionManager>, IOptions<MetalExecutionManagerOptions>?)

Initializes the Metal execution manager with all required components

public MetalExecutionManager(nint device, ILogger<MetalExecutionManager> logger, IOptions<MetalExecutionManagerOptions>? options = null)

Parameters

device nint
logger ILogger<MetalExecutionManager>
options IOptions<MetalExecutionManagerOptions>

Properties

CommandStream

Gets the command stream manager

public MetalCommandStream CommandStream { get; }

Property Value

MetalCommandStream

Device

Gets the Metal device handle

public nint Device { get; }

Property Value

nint

EncoderFactory

Gets the command encoder factory

public MetalCommandEncoderFactory EncoderFactory { get; }

Property Value

MetalCommandEncoderFactory

ErrorHandler

Gets the error handler

public MetalErrorHandler ErrorHandler { get; }

Property Value

MetalErrorHandler

EventManager

Gets the event manager

public MetalEventManager EventManager { get; }

Property Value

MetalEventManager

ExecutionContext

Gets the execution context

public MetalExecutionContext ExecutionContext { get; }

Property Value

MetalExecutionContext

IsAppleSilicon

Gets whether the execution manager is running on Apple Silicon

public bool IsAppleSilicon { get; }

Property Value

bool

IsGpuAvailable

Gets whether the GPU is currently available

public bool IsGpuAvailable { get; }

Property Value

bool

Methods

CreateTrackedBuffer(nuint, MetalStorageMode, string?)

Creates and tracks a Metal buffer

public nint CreateTrackedBuffer(nuint length, MetalStorageMode storageMode, string? resourceId = null)

Parameters

length nuint
storageMode MetalStorageMode
resourceId string

Returns

nint

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

ExecuteComputeOperationAsync<T>(MetalComputeOperationDescriptor, Func<MetalOperationExecutionInfo, MetalCommandEncoder, Task<T>>, CancellationToken)

Executes a compute operation with comprehensive management and error handling

public Task<T> ExecuteComputeOperationAsync<T>(MetalComputeOperationDescriptor descriptor, Func<MetalOperationExecutionInfo, MetalCommandEncoder, Task<T>> operation, CancellationToken cancellationToken = default)

Parameters

descriptor MetalComputeOperationDescriptor
operation Func<MetalOperationExecutionInfo, MetalCommandEncoder, Task<T>>
cancellationToken CancellationToken

Returns

Task<T>

Type Parameters

T

ExecuteMemoryOperationAsync(MetalMemoryOperationDescriptor, CancellationToken)

Executes a memory operation with comprehensive management

public Task ExecuteMemoryOperationAsync(MetalMemoryOperationDescriptor descriptor, CancellationToken cancellationToken = default)

Parameters

descriptor MetalMemoryOperationDescriptor
cancellationToken CancellationToken

Returns

Task

GenerateDiagnosticReport()

Generates a comprehensive diagnostic report

public MetalDiagnosticInfo GenerateDiagnosticReport()

Returns

MetalDiagnosticInfo

GetStatistics()

Gets comprehensive statistics from all execution components

public MetalExecutionManagerStats GetStatistics()

Returns

MetalExecutionManagerStats

PerformHealthCheckAsync(CancellationToken)

Performs a comprehensive health check

public Task<MetalExecutionManagerHealthCheck> PerformHealthCheckAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<MetalExecutionManagerHealthCheck>

ReleaseTrackedResource(string, bool)

Releases and untracks a Metal resource

public void ReleaseTrackedResource(string resourceId, bool releaseNativeResource = true)

Parameters

resourceId string
releaseNativeResource bool