Table of Contents

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

context CudaContext

The CUDA context.

logger ILogger<OptimizedCudaMemoryPrefetcher>

Logger for diagnostics.

config PrefetcherConfiguration

Prefetcher configuration.

Properties

Statistics

Gets prefetcher performance statistics.

public PrefetcherStatistics Statistics { get; }

Property Value

PrefetcherStatistics

Methods

DisableAutoPrefetch(nint)

Disables automatic prefetching for a memory region.

public void DisableAutoPrefetch(nint devicePtr)

Parameters

devicePtr nint

Device 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

devicePtr nint

Device memory pointer.

size long

Total size of the memory region.

enableAdaptive bool

Enable 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

devicePtr nint

Device memory pointer.

offset long

Offset to prefetch.

size long

Size to prefetch in bytes.

strategy PrefetchStrategy

Prefetch strategy.

priority PrefetchPriority

Request 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

devicePtr nint

Device memory pointer.

offset long

Offset to prefetch.

size long

Size to prefetch in bytes.

cacheLevel CacheLevel

Target cache level.

hint MemoryAccessHint

Memory access hint.

Returns

ValueTask

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

devicePtr nint

Device memory pointer.

offset long

Access offset in bytes.

size long

Access size in bytes.

accessType MemoryAccessType

Type of memory access.