Class DotComputeKernel<TIn, TOut>
- Namespace
- Orleans.GpuBridge.Backends.DotCompute
- Assembly
- Orleans.GpuBridge.Backends.DotCompute.dll
DotCompute kernel adapter that wraps IAccelerator and ICompiledKernel. Provides Orleans.GpuBridge integration for DotCompute kernels.
public sealed class DotComputeKernel<TIn, TOut> : GpuKernelBase<TIn, TOut>, IGpuKernel<TIn, TOut>, IDisposable
Type Parameters
TInInput type for kernel execution
TOutOutput type for kernel execution
- Inheritance
-
GpuKernelBase<TIn, TOut>DotComputeKernel<TIn, TOut>
- Implements
-
IGpuKernel<TIn, TOut>
- Inherited Members
Constructors
DotComputeKernel(IAccelerator, KernelDefinition, CompilationOptions?, Func<TIn, KernelArgument[]>?, Func<IUnifiedMemoryBuffer, TOut>?)
Creates a new DotCompute kernel adapter.
public DotComputeKernel(IAccelerator accelerator, KernelDefinition kernelDefinition, CompilationOptions? compilationOptions = null, Func<TIn, KernelArgument[]>? inputConverter = null, Func<IUnifiedMemoryBuffer, TOut>? outputConverter = null)
Parameters
acceleratorIAcceleratorDotCompute accelerator instance
kernelDefinitionKernelDefinitionKernel definition with source code
compilationOptionsCompilationOptionsCompilation options (null = default)
inputConverterFunc<TIn, KernelArgument[]>Function to convert TIn to KernelArgument[]
outputConverterFunc<IUnifiedMemoryBuffer, TOut>Function to convert GPU buffer to TOut
Properties
BackendProvider
Backend provider name
public override string BackendProvider { get; }
Property Value
IsGpuAccelerated
Whether kernel uses GPU acceleration (true for non-CPU accelerators)
public override bool IsGpuAccelerated { get; }
Property Value
KernelId
Unique kernel identifier
public override string KernelId { get; }
Property Value
Methods
Dispose()
Dispose kernel resources and free GPU memory.
public override void Dispose()
ExecuteAsync(TIn, CancellationToken)
Execute kernel with single input.
public override Task<TOut> ExecuteAsync(TIn input, CancellationToken cancellationToken = default)
Parameters
inputTIncancellationTokenCancellationToken
Returns
- Task<TOut>
ExecuteBatchAsync(TIn[], CancellationToken)
Execute kernel with batch input (optimized for GPU).
public override Task<TOut[]> ExecuteBatchAsync(TIn[] inputs, CancellationToken cancellationToken = default)
Parameters
inputsTIn[]cancellationTokenCancellationToken
Returns
- Task<TOut[]>
GetEstimatedExecutionTimeMicroseconds(int)
Get estimated execution time for input size. Uses GPU timing provider if available for accurate profiling.
public override long GetEstimatedExecutionTimeMicroseconds(int inputSize)
Parameters
inputSizeint
Returns
Remarks
Execution time estimation strategy: 1. If ITimingProvider is available, use timer resolution for accuracy bounds 2. Use empirical measurements from past executions (if available) 3. Fall back to heuristic based on accelerator type and input size
Heuristics are based on typical memory-bound kernel performance: - GPU: ~0.1μs per element (high bandwidth, parallel execution) - CPU: ~1μs per element (sequential or limited parallelism)
GetMemoryRequirements()
Get memory requirements for kernel execution.
public override KernelMemoryRequirements GetMemoryRequirements()
Returns
InitializeAsync(CancellationToken)
Initialize kernel by compiling to GPU code.
public override Task InitializeAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
WarmupAsync(CancellationToken)
Warmup kernel for optimal performance (JIT compilation, cache warming).
public override Task WarmupAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken