Class RingKernelHandlerTranslator
- Namespace
- DotCompute.Backends.CUDA.RingKernels
- Assembly
- DotCompute.Backends.CUDA.dll
Translates unified ring kernel methods (RingKernelContext + TRequest) to CUDA device functions.
public sealed class RingKernelHandlerTranslator
- Inheritance
-
RingKernelHandlerTranslator
- Inherited Members
Remarks
This translator handles the unified ring kernel API where methods have the signature:
public static void ProcessMessage(RingKernelContext ctx, TRequest request)
The translation process:
- Parse C# method body using Roslyn
- Generate deserialization from msg_buffer to typed request struct
- Translate C# operations to CUDA equivalents
- Generate serialization from response to output_buffer
Supported C# to CUDA mappings:
ctx.SyncThreads()→__syncthreads()ctx.ThreadFence()→__threadfence()ctx.EnqueueOutput(response)→ serialize and set output_size- Property access (request.X) → struct field access
- Local variable declarations → CUDA variable declarations
- Arithmetic operations → CUDA arithmetic
Constructors
RingKernelHandlerTranslator(ILogger<RingKernelHandlerTranslator>)
Initializes a new instance of the RingKernelHandlerTranslator class.
public RingKernelHandlerTranslator(ILogger<RingKernelHandlerTranslator> logger)
Parameters
loggerILogger<RingKernelHandlerTranslator>The logger for diagnostic messages.
Methods
TranslateKernelHandler(DiscoveredRingKernel, Compilation)
Translates a unified ring kernel method to a CUDA device function.
public string? TranslateKernelHandler(DiscoveredRingKernel kernel, Compilation compilation)
Parameters
kernelDiscoveredRingKernelThe discovered ring kernel metadata.
compilationCompilationThe Roslyn compilation containing the source.
Returns
- string
The translated CUDA handler function, or null if translation fails.