Table of Contents

Class CudaKernelCompiler

Namespace
DotCompute.Backends.CUDA.Compilation
Assembly
DotCompute.Backends.CUDA.dll

CUDA kernel compiler implementation using NVRTC. Now delegates to specialized compilation pipeline for improved maintainability.

public sealed class CudaKernelCompiler : IDisposable, IAsyncDisposable
Inheritance
CudaKernelCompiler
Implements
Inherited Members
Extension Methods

Constructors

CudaKernelCompiler(CudaContext, ILogger)

Initializes a new instance of the CudaKernelCompiler class.

[RequiresUnreferencedCode("This type uses runtime code generation and reflection")]
[RequiresDynamicCode("This type uses runtime code generation for CUDA kernel compilation")]
public CudaKernelCompiler(CudaContext context, ILogger logger)

Parameters

context CudaContext

The context.

logger ILogger

The logger.

Methods

ClearCache()

Performs clear cache.

public void ClearCache()

CompileAsync(KernelDefinition, CompilationOptions?, CancellationToken)

Gets compile asynchronously.

public Task<ICompiledKernel> CompileAsync(KernelDefinition definition, CompilationOptions? options = null, CancellationToken cancellationToken = default)

Parameters

definition KernelDefinition

The definition.

options CompilationOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<ICompiledKernel>

The result of the operation.

CompileBatchAsync(KernelDefinition[], CompilationOptions?, CancellationToken)

Gets compile batch asynchronously.

public Task<ICompiledKernel[]> CompileBatchAsync(KernelDefinition[] definitions, CompilationOptions? options = null, CancellationToken cancellationToken = default)

Parameters

definitions KernelDefinition[]

The definitions.

options CompilationOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<ICompiledKernel[]>

The result of the operation.

CompileKernelAsync(KernelDefinition, CompilationOptions?, CancellationToken)

Gets compile kernel asynchronously.

public Task<ICompiledKernel> CompileKernelAsync(KernelDefinition definition, CompilationOptions? options = null, CancellationToken cancellationToken = default)

Parameters

definition KernelDefinition

The definition.

options CompilationOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<ICompiledKernel>

The result of the operation.

Dispose()

Performs dispose.

public void Dispose()

DisposeAsync()

Gets dispose asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

The result of the operation.

GetAllMangledNames(string)

Gets all mangled function names for a kernel.

public static Dictionary<string, string>? GetAllMangledNames(string kernelName)

Parameters

kernelName string

Returns

Dictionary<string, string>

GetCacheStatistics()

Gets cache statistics for monitoring and debugging

public CacheStatistics GetCacheStatistics()

Returns

CacheStatistics

GetMangledFunctionName(string, string)

Gets the mangled function name for a kernel and function name.

public static string? GetMangledFunctionName(string kernelName, string functionName)

Parameters

kernelName string
functionName string

Returns

string

GetNvrtcVersion()

Gets NVRTC version information

public static (int major, int minor) GetNvrtcVersion()

Returns

(int x, int y)

IsNvrtcAvailable()

Checks NVRTC availability and version

public static bool IsNvrtcAvailable()

Returns

bool

TryGetCached(string, out ICompiledKernel?)

Returns true if able to get cached, otherwise false.

public bool TryGetCached(string kernelName, out ICompiledKernel? compiledKernel)

Parameters

kernelName string

The kernel name.

compiledKernel ICompiledKernel

The compiled kernel.

Returns

bool

true if the operation succeeded; otherwise, false.