Class MetalGraphNode
Represents an individual computation node in a Metal compute graph. Each node encapsulates a single operation (kernel, memory copy, barrier) with its dependencies and resource requirements.
public sealed class MetalGraphNode
- Inheritance
-
MetalGraphNode
- Inherited Members
Constructors
MetalGraphNode(string, MetalNodeType)
Initializes a new instance of the MetalGraphNode class.
public MetalGraphNode(string id, MetalNodeType type)
Parameters
idstringThe unique identifier for this node.
typeMetalNodeTypeThe type of operation this node represents.
Exceptions
- ArgumentException
Thrown when id is null or whitespace.
Properties
Arguments
Gets or sets the kernel arguments array.
public IReadOnlyList<object> Arguments { get; set; }
Property Value
CanBeFused
Gets or sets a value indicating whether this node can be fused with adjacent nodes.
public bool CanBeFused { get; set; }
Property Value
CopySize
Gets or sets the size in bytes for memory operations.
public long CopySize { get; set; }
Property Value
CreatedAt
Gets the timestamp when this node was created.
public DateTimeOffset CreatedAt { get; }
Property Value
Dependencies
Gets or sets the list of nodes that this node depends on.
public IList<MetalGraphNode> Dependencies { get; }
Property Value
DestinationBuffer
Gets or sets the destination buffer for memory operations.
public nint DestinationBuffer { get; set; }
Property Value
EstimatedMemoryUsage
Gets or sets the estimated memory usage of this node in bytes.
public long EstimatedMemoryUsage { get; set; }
Property Value
ExecutionDuration
Gets the execution duration, if the node has completed.
public TimeSpan? ExecutionDuration { get; }
Property Value
ExecutionEndTime
Gets or sets the timestamp when this node completed execution.
public DateTimeOffset? ExecutionEndTime { get; set; }
Property Value
ExecutionError
Gets or sets any error that occurred during execution.
public Exception? ExecutionError { get; set; }
Property Value
ExecutionStartTime
Gets or sets the timestamp when this node started execution.
public DateTimeOffset? ExecutionStartTime { get; set; }
Property Value
ExecutionState
Gets or sets the current execution state of this node.
public MetalNodeExecutionState ExecutionState { get; set; }
Property Value
FillValue
Gets or sets the fill value for memory set operations.
public byte FillValue { get; set; }
Property Value
Id
Gets the unique identifier for this node.
public string Id { get; }
Property Value
IsMemoryOptimized
Gets or sets a value indicating whether this node's memory access patterns are optimized.
public bool IsMemoryOptimized { get; set; }
Property Value
Kernel
Gets or sets the compiled Metal kernel for kernel nodes.
public ICompiledKernel? Kernel { get; set; }
Property Value
MetalResources
Gets or sets Metal-specific resources associated with this node.
public Dictionary<string, object> MetalResources { get; }
Property Value
OptimizationHints
Gets or sets optimization hints for this node.
public MetalOptimizationHints OptimizationHints { get; set; }
Property Value
Priority
Gets or sets the priority level for this node's execution.
public MetalNodePriority Priority { get; set; }
Property Value
RequiredEncoderType
Gets or sets the Metal command encoder type required for this node.
public MetalCommandEncoderType RequiredEncoderType { get; set; }
Property Value
SourceBuffer
Gets or sets the source buffer for memory operations.
public nint SourceBuffer { get; set; }
Property Value
ThreadgroupsPerGrid
Gets or sets the number of threadgroups to dispatch for kernel nodes.
public MTLSize ThreadgroupsPerGrid { get; set; }
Property Value
ThreadsPerThreadgroup
Gets or sets the number of threads per threadgroup for kernel nodes.
public MTLSize ThreadsPerThreadgroup { get; set; }
Property Value
Type
Gets the type of operation this node represents.
public MetalNodeType Type { get; }
Property Value
UserData
Gets or sets custom user data associated with this node.
public object? UserData { get; set; }
Property Value
Methods
AddDependency(MetalGraphNode)
Adds a dependency to this node.
public void AddDependency(MetalGraphNode dependency)
Parameters
dependencyMetalGraphNodeThe node that this node depends on.
Exceptions
- ArgumentNullException
Thrown when dependency is null.
- InvalidOperationException
Thrown when adding the dependency would create a cycle.
Clone(string)
Creates a shallow copy of this node with a new ID.
public MetalGraphNode Clone(string newId)
Parameters
newIdstringThe ID for the cloned node.
Returns
- MetalGraphNode
A new node instance that is a copy of this node.
DependsOn(string)
Determines if this node depends directly on the specified node.
public bool DependsOn(string nodeId)
Parameters
nodeIdstringThe ID of the node to check for dependency.
Returns
- bool
trueif this node depends on the specified node; otherwise,false.
GetTransitiveDependencies()
Gets all transitive dependencies of this node.
public HashSet<MetalGraphNode> GetTransitiveDependencies()
Returns
- HashSet<MetalGraphNode>
A set of all nodes that this node transitively depends on.
HasDependencies()
Determines if this node has any dependencies.
public bool HasDependencies()
Returns
- bool
trueif the node has dependencies; otherwise,false.
RemoveDependency(string)
Removes a dependency from this node.
public bool RemoveDependency(string dependencyId)
Parameters
dependencyIdstringThe ID of the dependency to remove.
Returns
- bool
trueif the dependency was found and removed; otherwise,false.
ToString()
Returns a string representation of this node.
public override string ToString()
Returns
- string
A string containing the node's type and ID.
Validate()
Validates this node's configuration and resource requirements.
public IReadOnlyList<string> Validate()
Returns
- IReadOnlyList<string>
A list of validation errors, or an empty list if valid.