Table of Contents

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:

  1. Scans loaded assemblies for [RingKernel] methods
  2. Validates method signatures (static, void return, public accessibility)
  3. Extracts attribute configuration (queue sizes, messaging strategy, etc.)
  4. Analyzes parameter types for CUDA compatibility
  5. Builds metadata registry for compilation pipeline

Constructors

RingKernelDiscovery(ILogger<RingKernelDiscovery>)

Initializes a new instance of the RingKernelDiscovery class.

public RingKernelDiscovery(ILogger<RingKernelDiscovery> logger)

Parameters

logger ILogger<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

kernelId string

The unique kernel ID to find.

assemblies IEnumerable<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

assemblies IEnumerable<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

kernelId string

The kernel ID.

Returns

DiscoveredRingKernel

The discovered kernel, or null if not in registry.