Interface IKernelCache
- Namespace
- DotCompute.Runtime.Services.Interfaces
- Assembly
- DotCompute.Runtime.dll
Caches compiled kernels to avoid recompilation overhead.
public interface IKernelCache
Methods
ClearAsync()
Clears all cached kernels.
Task<int> ClearAsync()
Returns
GenerateCacheKey(KernelDefinition, IAccelerator, CompilationOptions?)
Generates a cache key for a kernel configuration.
string GenerateCacheKey(KernelDefinition kernelDefinition, IAccelerator accelerator, CompilationOptions? compilationOptions)
Parameters
kernelDefinitionKernelDefinitionThe kernel definition
acceleratorIAcceleratorThe target accelerator
compilationOptionsCompilationOptionsOptional compilation options
Returns
- string
A unique cache key
GetAsync(string)
Retrieves a compiled kernel from the cache.
Task<ICompiledKernel?> GetAsync(string cacheKey)
Parameters
cacheKeystringThe cache key
Returns
- Task<ICompiledKernel>
The cached compiled kernel, or null if not found
GetStatisticsAsync()
Gets cache statistics.
Task<CacheStatistics> GetStatisticsAsync()
Returns
- Task<CacheStatistics>
Cache statistics including hit rate, size, etc.
InvalidateAsync(string)
Invalidates a specific cache entry.
Task<bool> InvalidateAsync(string cacheKey)
Parameters
cacheKeystringThe cache key to invalidate
Returns
PrewarmAsync(IEnumerable<KernelDefinition>, IEnumerable<IAccelerator>)
Pre-warms the cache with commonly used kernels.
Task<int> PrewarmAsync(IEnumerable<KernelDefinition> kernelDefinitions, IEnumerable<IAccelerator> accelerators)
Parameters
kernelDefinitionsIEnumerable<KernelDefinition>Kernel definitions to pre-compile and cache
acceleratorsIEnumerable<IAccelerator>Available accelerators
Returns
StoreAsync(string, ICompiledKernel)
Stores a compiled kernel in the cache.
Task StoreAsync(string cacheKey, ICompiledKernel compiledKernel)
Parameters
cacheKeystringThe cache key
compiledKernelICompiledKernelThe compiled kernel to cache
Returns
- Task
A task representing the store operation