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
loggerILogger<MetalGraphExecutor>The logger instance for execution monitoring.
commandExecutorIMetalCommandExecutorThe Metal command executor for GPU operations.
maxConcurrentOperationsintThe 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
graphMetalComputeGraphThe graph to execute.
commandQueuenintThe Metal command queue for execution.
cancellationTokenCancellationTokenOptional 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
nodeMetalGraphNodeThe node whose dependencies to wait for.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task
A task that completes when all dependencies are finished.