Table of Contents

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

device IAccelerator

The device.

deviceCapabilities DeviceCapabilities

The device capabilities.

logger ILogger

The logger.

Methods

AllocateAsync(long, CancellationToken)

Allocates a buffer with standard pooling strategy.

public ValueTask<IUnifiedMemoryBuffer> AllocateAsync(long sizeInBytes, CancellationToken cancellationToken = default)

Parameters

sizeInBytes long
cancellationToken CancellationToken

Returns

ValueTask<IUnifiedMemoryBuffer>

AllocateMemoryMappedAsync(long, CancellationToken)

Allocates a memory-mapped buffer for very large datasets.

public ValueTask<IUnifiedMemoryBuffer> AllocateMemoryMappedAsync(long sizeInBytes, CancellationToken cancellationToken = default)

Parameters

sizeInBytes long
cancellationToken CancellationToken

Returns

ValueTask<IUnifiedMemoryBuffer>

AllocateStreamingAsync(long, int, CancellationToken)

Allocates a buffer optimized for streaming transfers.

public ValueTask<IUnifiedMemoryBuffer> AllocateStreamingAsync(long sizeInBytes, int chunkSize, CancellationToken cancellationToken = default)

Parameters

sizeInBytes long
chunkSize int
cancellationToken CancellationToken

Returns

ValueTask<IUnifiedMemoryBuffer>

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()

Returns

DeviceBufferPoolStatistics