Table of Contents

Class CudaKernelCache

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

Cache for compiled CUDA kernels to avoid recompilation.

public sealed class CudaKernelCache : IDisposable
Inheritance
CudaKernelCache
Implements
Inherited Members
Extension Methods

Constructors

CudaKernelCache()

Initializes a new instance of the CudaKernelCache class.

public CudaKernelCache()

CudaKernelCache(ILogger)

Initializes a new instance of the CudaKernelCache class with logging.

public CudaKernelCache(ILogger logger)

Parameters

logger ILogger

Logger instance.

Properties

Count

Gets the number of cached kernels.

public int Count { get; }

Property Value

int

Instance

Gets the singleton instance of the cache.

public static CudaKernelCache Instance { get; }

Property Value

CudaKernelCache

Methods

AddOrUpdateKernel(string, ICompiledKernel)

Adds or updates a kernel in the cache.

public void AddOrUpdateKernel(string key, ICompiledKernel kernel)

Parameters

key string

The cache key.

kernel ICompiledKernel

The compiled kernel.

CacheKernel(string, ICompiledKernel)

Caches a compiled kernel with the specified key.

public void CacheKernel(string key, ICompiledKernel kernel)

Parameters

key string

Cache key.

kernel ICompiledKernel

Compiled kernel to cache.

Cleanup()

Performs cleanup of unused kernels from the cache.

public void Cleanup()

Clear()

Clears all cached kernels.

public void Clear()

Dispose()

Disposes the cache and releases resources.

public void Dispose()

GenerateCacheKey(KernelDefinition, CompilationOptions?)

Generates a cache key for a kernel definition.

public static string GenerateCacheKey(KernelDefinition definition, CompilationOptions? options = null)

Parameters

definition KernelDefinition

The kernel definition.

options CompilationOptions

Compilation options.

Returns

string

A unique cache key.

OptimizeForWorkload(object)

Optimizes the cache for a specific workload profile.

public void OptimizeForWorkload(object profile)

Parameters

profile object

Workload profile for optimization.

RemoveKernel(string)

Removes a kernel from the cache.

public bool RemoveKernel(string key)

Parameters

key string

The cache key.

Returns

bool

True if removed; otherwise, false.

TryGetKernel(string, out ICompiledKernel?)

Tries to get a cached kernel.

public bool TryGetKernel(string key, out ICompiledKernel? kernel)

Parameters

key string

The cache key.

kernel ICompiledKernel

The cached kernel if found.

Returns

bool

True if found; otherwise, false.