Class CompiledKernel
- Namespace
- Orleans.GpuBridge.Abstractions.Models
- Assembly
- Orleans.GpuBridge.Abstractions.dll
Represents a compiled GPU kernel that can be executed on compute devices.
public sealed class CompiledKernel : IDisposable
- Inheritance
-
CompiledKernel
- Implements
- Inherited Members
Remarks
This class encapsulates the compiled binary code, metadata, and native handles required for kernel execution. It implements IDisposable to ensure proper cleanup of native GPU resources.
Properties
BackendData
Gets or sets backend-specific data associated with this compiled kernel.
public object? BackendData { get; init; }
Property Value
- object
An object containing backend-specific execution context, such as a DotCompute kernel adapter, CUDA module reference, or other runtime-specific data needed for kernel execution. The exact type depends on the backend provider.
Remarks
This property allows backend providers to attach their specific execution context to the compiled kernel without requiring changes to the core abstraction. Backend implementations should cast this to their expected type before use.
CompiledCode
Gets the compiled binary code for the kernel.
public byte[] CompiledCode { get; init; }
Property Value
- byte[]
The platform-specific compiled binary code (e.g., PTX for CUDA, SPIR-V for OpenCL/Vulkan) that can be loaded and executed by the GPU driver.
IsDisposed
Gets a value indicating whether this kernel instance has been disposed.
public bool IsDisposed { get; }
Property Value
- bool
trueif the kernel has been disposed and its resources released; otherwise,false. Once disposed, the kernel cannot be used for execution.
KernelId
Gets the unique identifier for this compiled kernel.
public string KernelId { get; init; }
Property Value
- string
A unique string identifier used to reference the kernel in the system. This ID is typically generated during compilation and remains constant throughout the kernel's lifetime.
Metadata
Gets the metadata associated with the compiled kernel.
public KernelMetadata Metadata { get; init; }
Property Value
- KernelMetadata
Detailed metadata including resource requirements, execution constraints, and optimization information used for efficient kernel scheduling and execution.
Name
Gets the human-readable name of the kernel.
public string Name { get; init; }
Property Value
- string
A descriptive name for the kernel, often derived from the original method or function name. Used for debugging and logging purposes.
NativeHandle
Gets the native handle to the kernel object in the GPU driver.
public nint NativeHandle { get; init; }
Property Value
- nint
A platform-specific native pointer or handle that references the kernel object in the GPU runtime. This handle is used for direct API calls to execute the kernel. A value of IntPtr.Zero indicates no native handle.
Methods
Dispose()
Releases all resources used by the CompiledKernel.
public void Dispose()
Remarks
This method releases native GPU resources associated with the kernel, including any driver-level handles or memory allocations. After disposal, the kernel cannot be used for execution and any attempts to do so should result in an ObjectDisposedException.
This method is safe to call multiple times; subsequent calls have no effect.