Class OptimizedCudaMemoryPrefetcher
- Namespace
- DotCompute.Backends.CUDA.Memory
- Assembly
- DotCompute.Backends.CUDA.dll
Advanced CUDA memory prefetcher with intelligent pattern recognition:
- Predictive prefetching based on access patterns
- Multi-level prefetch strategies (L1, L2, global memory)
- Adaptive prefetch distance based on bandwidth utilization
- NUMA-aware prefetching for multi-GPU systems
- Asynchronous prefetch operations with minimal overhead
- Cache pollution avoidance with smart eviction policies Target: 30-50% improvement in memory-bound kernel performance
public sealed class OptimizedCudaMemoryPrefetcher : IDisposable
- Inheritance
-
OptimizedCudaMemoryPrefetcher
- Implements
- Inherited Members
- Extension Methods
Constructors
OptimizedCudaMemoryPrefetcher(CudaContext, ILogger<OptimizedCudaMemoryPrefetcher>, PrefetcherConfiguration?)
Initializes a new optimized CUDA memory prefetcher.
public OptimizedCudaMemoryPrefetcher(CudaContext context, ILogger<OptimizedCudaMemoryPrefetcher> logger, PrefetcherConfiguration? config = null)
Parameters
contextCudaContextThe CUDA context.
loggerILogger<OptimizedCudaMemoryPrefetcher>Logger for diagnostics.
configPrefetcherConfigurationPrefetcher configuration.
Properties
Statistics
Gets prefetcher performance statistics.
public PrefetcherStatistics Statistics { get; }
Property Value
Methods
DisableAutoPrefetch(nint)
Disables automatic prefetching for a memory region.
public void DisableAutoPrefetch(nint devicePtr)
Parameters
devicePtrnintDevice memory pointer.
Dispose()
Performs dispose.
public void Dispose()
EnableAutoPrefetch(nint, long, bool)
Enables automatic prefetching for a memory region based on learned patterns.
public void EnableAutoPrefetch(nint devicePtr, long size, bool enableAdaptive = true)
Parameters
devicePtrnintDevice memory pointer.
sizelongTotal size of the memory region.
enableAdaptiveboolEnable adaptive prefetch distance.
OptimizePrefetchPatterns()
Analyzes and optimizes prefetch patterns for improved performance.
public void OptimizePrefetchPatterns()
PrefetchAsync(nint, long, long, PrefetchStrategy, PrefetchPriority)
Explicitly prefetches memory region with specified strategy.
public ValueTask PrefetchAsync(nint devicePtr, long offset, long size, PrefetchStrategy strategy = PrefetchStrategy.Auto, PrefetchPriority priority = PrefetchPriority.Normal)
Parameters
devicePtrnintDevice memory pointer.
offsetlongOffset to prefetch.
sizelongSize to prefetch in bytes.
strategyPrefetchStrategyPrefetch strategy.
priorityPrefetchPriorityRequest priority.
Returns
- ValueTask
Task representing the prefetch operation.
PrefetchToCacheAsync(nint, long, long, CacheLevel, MemoryAccessHint)
Prefetches memory to specific cache levels with fine-grained control.
public ValueTask PrefetchToCacheAsync(nint devicePtr, long offset, long size, CacheLevel cacheLevel, MemoryAccessHint hint = MemoryAccessHint.Normal)
Parameters
devicePtrnintDevice memory pointer.
offsetlongOffset to prefetch.
sizelongSize to prefetch in bytes.
cacheLevelCacheLevelTarget cache level.
hintMemoryAccessHintMemory access hint.
Returns
RecordAccess(nint, long, long, MemoryAccessType)
Records a memory access pattern for future prefetching.
public void RecordAccess(nint devicePtr, long offset, long size, MemoryAccessType accessType)
Parameters
devicePtrnintDevice memory pointer.
offsetlongAccess offset in bytes.
sizelongAccess size in bytes.
accessTypeMemoryAccessTypeType of memory access.