Table of Contents

Interface IKernelCacheService

Namespace
DotCompute.Runtime.Services.Interfaces
Assembly
DotCompute.Runtime.dll

Service for caching compiled kernels

public interface IKernelCacheService

Methods

ClearAsync()

Clears the kernel cache

Task ClearAsync()

Returns

Task

A task representing the clear operation

EvictAsync()

Evicts old or unused cached kernels

Task<int> EvictAsync()

Returns

Task<int>

The number of evicted kernels

GenerateCacheKey(KernelDefinition, IAccelerator, CompilationOptions?)

Generates a cache key for a kernel definition and accelerator

string GenerateCacheKey(KernelDefinition definition, IAccelerator accelerator, CompilationOptions? options)

Parameters

definition KernelDefinition

The kernel definition

accelerator IAccelerator

The target accelerator

options CompilationOptions

Compilation options

Returns

string

The cache key

GetAsync(string)

Gets a cached kernel if available

Task<ICompiledKernel?> GetAsync(string cacheKey)

Parameters

cacheKey string

The cache key

Returns

Task<ICompiledKernel>

The cached kernel or null if not found

GetStatistics()

Gets cache statistics

KernelCacheStatistics GetStatistics()

Returns

KernelCacheStatistics

Cache statistics

StoreAsync(string, ICompiledKernel)

Stores a compiled kernel in the cache

Task StoreAsync(string cacheKey, ICompiledKernel kernel)

Parameters

cacheKey string

The cache key

kernel ICompiledKernel

The compiled kernel

Returns

Task

A task representing the store operation