Class MetalCompiledRingKernel
- Namespace
- DotCompute.Backends.Metal.Compilation
- Assembly
- DotCompute.Backends.Metal.dll
Represents a compiled Ring Kernel with Metal library and pipeline state.
public sealed class MetalCompiledRingKernel : CompiledKernel, IDisposable
- Inheritance
-
MetalCompiledRingKernel
- Implements
- Inherited Members
- Extension Methods
Remarks
This class extends CompiledKernel with Ring Kernel-specific metadata including the discovered kernel information, Metal library handle, and compute pipeline state.
Lifecycle:
- Created by MetalRingKernelCompiler after successful compilation
- Metal library compiled from MSL source
- Compute pipeline state created for kernel execution
- Library and pipeline released on disposal
Constructors
MetalCompiledRingKernel(DiscoveredMetalRingKernel, nint, nint, nint, string, nint, int, int)
Initializes a new instance of the MetalCompiledRingKernel class.
[SetsRequiredMembers]
public MetalCompiledRingKernel(DiscoveredMetalRingKernel discoveredKernel, nint libraryHandle, nint pipelineStateHandle, nint kernelFunctionHandle, string mslSource, nint metalDevice, int threadExecutionWidth = 32, int maxTotalThreadsPerThreadgroup = 1024)
Parameters
discoveredKernelDiscoveredMetalRingKernelThe discovered kernel metadata.
libraryHandlenintThe Metal library handle.
pipelineStateHandlenintThe compute pipeline state handle.
kernelFunctionHandlenintThe kernel function handle.
mslSourcestringThe MSL source code.
metalDevicenintThe Metal device.
threadExecutionWidthintThe thread execution width.
maxTotalThreadsPerThreadgroupintThe maximum threads per threadgroup.
Properties
CompilationTimestamp
Gets the compilation timestamp.
public DateTime CompilationTimestamp { get; }
Property Value
DiscoveredKernel
Gets the discovered kernel metadata from reflection.
public DiscoveredMetalRingKernel DiscoveredKernel { get; }
Property Value
IsValid
Gets a value indicating whether this kernel is valid for execution.
public bool IsValid { get; }
Property Value
KernelEntryPoint
Gets the kernel entry point name (function name in MSL).
public string KernelEntryPoint { get; }
Property Value
KernelFunctionHandle
Gets the kernel function handle from the library.
public nint KernelFunctionHandle { get; }
Property Value
LibraryHandle
Gets the Metal library handle.
public nint LibraryHandle { get; }
Property Value
MaxTotalThreadsPerThreadgroup
Gets the maximum total threads per threadgroup for this kernel.
public int MaxTotalThreadsPerThreadgroup { get; }
Property Value
MetalDevice
Gets the Metal device this kernel was compiled for.
public nint MetalDevice { get; }
Property Value
MslSource
Gets the MSL source code.
public string MslSource { get; }
Property Value
PipelineStateHandle
Gets the compute pipeline state handle for kernel execution.
public nint PipelineStateHandle { get; }
Property Value
ThreadExecutionWidth
Gets the thread execution width (SIMD size) for this kernel.
public int ThreadExecutionWidth { get; }
Property Value
Remarks
On Apple Silicon, this is typically 32 threads.
Methods
Dispose(bool)
Releases the unmanaged resources used by the CompiledKernel and optionally releases the managed resources.
protected override void Dispose(bool disposing)
Parameters
disposingboolTrue to release both managed and unmanaged resources; false to release only unmanaged resources.
Remarks
This method is called by the Dispose() method and the finalizer. Override this method in derived classes to provide specific resource cleanup logic.