Table of Contents

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:

  1. Parse C# method body using Roslyn
  2. Generate deserialization from msg_buffer to typed request struct
  3. Translate C# operations to CUDA equivalents
  4. 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

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

kernel DiscoveredRingKernel

The discovered ring kernel metadata.

compilation Compilation

The Roslyn compilation containing the source.

Returns

string

The translated CUDA handler function, or null if translation fails.