Class RingKernelDiscovery
- Namespace
- DotCompute.Backends.CUDA.Compilation
- Assembly
- DotCompute.Backends.CUDA.dll
Discovers Ring Kernel methods via runtime reflection and builds a registry for CUDA compilation.
public sealed class RingKernelDiscovery
- Inheritance
-
RingKernelDiscovery
- Inherited Members
Remarks
This component provides runtime discovery of methods marked with [RingKernel] attribute, which is required for the Ring Kernel compilation pipeline. Unlike the source generator's compile-time analysis, this performs runtime reflection to enable dynamic kernel loading and compilation.
Discovery process:
- Scans loaded assemblies for [RingKernel] methods
- Validates method signatures (static, void return, public accessibility)
- Extracts attribute configuration (queue sizes, messaging strategy, etc.)
- Analyzes parameter types for CUDA compatibility
- Builds metadata registry for compilation pipeline
Constructors
RingKernelDiscovery(ILogger<RingKernelDiscovery>)
Initializes a new instance of the RingKernelDiscovery class.
public RingKernelDiscovery(ILogger<RingKernelDiscovery> logger)
Parameters
loggerILogger<RingKernelDiscovery>The logger for diagnostic messages.
Methods
ClearRegistry()
Clears the kernel registry cache.
public void ClearRegistry()
DiscoverKernelById(string, IEnumerable<Assembly>?)
Discovers a specific Ring Kernel by its kernel ID.
[RequiresUnreferencedCode("Ring Kernel discovery uses runtime reflection which is not compatible with trimming.")]
public DiscoveredRingKernel? DiscoverKernelById(string kernelId, IEnumerable<Assembly>? assemblies = null)
Parameters
kernelIdstringThe unique kernel ID to find.
assembliesIEnumerable<Assembly>Optional assemblies to scan. If null, scans all loaded assemblies.
Returns
- DiscoveredRingKernel
The discovered kernel, or null if not found.
DiscoverKernels(IEnumerable<Assembly>?)
Discovers all Ring Kernel methods in the specified assemblies.
[RequiresUnreferencedCode("Ring Kernel discovery uses runtime reflection which is not compatible with trimming.")]
public IReadOnlyCollection<DiscoveredRingKernel> DiscoverKernels(IEnumerable<Assembly>? assemblies = null)
Parameters
assembliesIEnumerable<Assembly>The assemblies to scan. If null or empty, scans all loaded assemblies.
Returns
- IReadOnlyCollection<DiscoveredRingKernel>
A collection of discovered Ring Kernels.
Remarks
This method scans all types in the provided assemblies looking for methods marked with [RingKernel] attribute. Discovered kernels are validated and added to the registry.
GetAllRegisteredKernels()
Gets all kernels currently in the registry.
public IReadOnlyCollection<DiscoveredRingKernel> GetAllRegisteredKernels()
Returns
- IReadOnlyCollection<DiscoveredRingKernel>
A read-only collection of all registered kernels.
GetKernelFromRegistry(string)
Gets a discovered kernel from the registry.
public DiscoveredRingKernel? GetKernelFromRegistry(string kernelId)
Parameters
kernelIdstringThe kernel ID.
Returns
- DiscoveredRingKernel
The discovered kernel, or null if not in registry.