Table of Contents

Class MetalGraphExecutor

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

Provides optimized execution of Metal compute graphs with parallel processing, resource scheduling, and performance monitoring capabilities.

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

Constructors

MetalGraphExecutor(ILogger<MetalGraphExecutor>, IMetalCommandExecutor, int)

Initializes a new instance of the MetalGraphExecutor class.

public MetalGraphExecutor(ILogger<MetalGraphExecutor> logger, IMetalCommandExecutor commandExecutor, int maxConcurrentOperations = 8)

Parameters

logger ILogger<MetalGraphExecutor>

The logger instance for execution monitoring.

commandExecutor IMetalCommandExecutor

The Metal command executor for GPU operations.

maxConcurrentOperations int

The maximum number of concurrent operations allowed.

Methods

Dispose()

Releases all resources used by the Metal graph executor.

public void Dispose()

ExecuteAsync(MetalComputeGraph, nint, CancellationToken)

Executes a Metal compute graph with optimal performance and resource utilization.

public Task<MetalGraphExecutionResult> ExecuteAsync(MetalComputeGraph graph, nint commandQueue, CancellationToken cancellationToken = default)

Parameters

graph MetalComputeGraph

The graph to execute.

commandQueue nint

The Metal command queue for execution.

cancellationToken CancellationToken

Optional cancellation token.

Returns

Task<MetalGraphExecutionResult>

The execution result containing performance metrics and status.

Exceptions

ArgumentNullException

Thrown when graph or commandQueue is null.

InvalidOperationException

Thrown when the graph is not built or contains validation errors.

WaitForDependenciesAsync(MetalGraphNode, CancellationToken)

Waits for all dependencies of a node to complete.

public Task WaitForDependenciesAsync(MetalGraphNode node, CancellationToken cancellationToken = default)

Parameters

node MetalGraphNode

The node whose dependencies to wait for.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

A task that completes when all dependencies are finished.