Class DeviceBufferPool
- Namespace
- DotCompute.Core.Memory
- Assembly
- DotCompute.Core.dll
Device-specific buffer pool optimized for P2P operations and memory management. Provides different allocation strategies for various transfer patterns.
public sealed class DeviceBufferPool : IAsyncDisposable
- Inheritance
-
DeviceBufferPool
- Implements
- Inherited Members
Constructors
DeviceBufferPool(IAccelerator, DeviceCapabilities, ILogger)
Initializes a new instance of the DeviceBufferPool class.
public DeviceBufferPool(IAccelerator device, DeviceCapabilities deviceCapabilities, ILogger logger)
Parameters
deviceIAcceleratorThe device.
deviceCapabilitiesDeviceCapabilitiesThe device capabilities.
loggerILoggerThe logger.
Methods
AllocateAsync(long, CancellationToken)
Allocates a buffer with standard pooling strategy.
public ValueTask<IUnifiedMemoryBuffer> AllocateAsync(long sizeInBytes, CancellationToken cancellationToken = default)
Parameters
sizeInByteslongcancellationTokenCancellationToken
Returns
AllocateMemoryMappedAsync(long, CancellationToken)
Allocates a memory-mapped buffer for very large datasets.
public ValueTask<IUnifiedMemoryBuffer> AllocateMemoryMappedAsync(long sizeInBytes, CancellationToken cancellationToken = default)
Parameters
sizeInByteslongcancellationTokenCancellationToken
Returns
AllocateStreamingAsync(long, int, CancellationToken)
Allocates a buffer optimized for streaming transfers.
public ValueTask<IUnifiedMemoryBuffer> AllocateStreamingAsync(long sizeInBytes, int chunkSize, CancellationToken cancellationToken = default)
Parameters
sizeInByteslongchunkSizeintcancellationTokenCancellationToken
Returns
Cleanup()
Forces cleanup of unused pooled buffers.
public void Cleanup()
DisposeAsync()
Gets dispose asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
The result of the operation.
GetStatistics()
Gets comprehensive pool statistics.
public DeviceBufferPoolStatistics GetStatistics()