Table of Contents

Class P2PBufferFactory

Namespace
DotCompute.Core.Memory
Assembly
DotCompute.Core.dll

P2P-aware buffer factory that creates optimized buffers for multi-GPU scenarios. Handles direct P2P transfers, host-mediated transfers, and memory pooling.

public sealed class P2PBufferFactory : IAsyncDisposable
Inheritance
P2PBufferFactory
Implements
Inherited Members

Constructors

P2PBufferFactory(ILogger, P2PCapabilityDetector)

P2P-aware buffer factory that creates optimized buffers for multi-GPU scenarios. Handles direct P2P transfers, host-mediated transfers, and memory pooling.

public P2PBufferFactory(ILogger logger, P2PCapabilityDetector capabilityDetector)

Parameters

logger ILogger
capabilityDetector P2PCapabilityDetector

Methods

CreateEmptyP2PBufferAsync<T>(IAccelerator, int, P2PBufferOptions?, CancellationToken)

Creates an empty P2P buffer with specified parameters.

public ValueTask<P2PBuffer<T>> CreateEmptyP2PBufferAsync<T>(IAccelerator device, int length, P2PBufferOptions? options = null, CancellationToken cancellationToken = default) where T : unmanaged

Parameters

device IAccelerator
length int
options P2PBufferOptions
cancellationToken CancellationToken

Returns

ValueTask<P2PBuffer<T>>

Type Parameters

T

CreateP2PBufferAsync<T>(IUnifiedMemoryBuffer<T>, IAccelerator, P2PBufferOptions?, CancellationToken)

Creates a P2P-optimized buffer on the target device with data from the source buffer.

public ValueTask<P2PBuffer<T>> CreateP2PBufferAsync<T>(IUnifiedMemoryBuffer<T> sourceBuffer, IAccelerator targetDevice, P2PBufferOptions? options = null, CancellationToken cancellationToken = default) where T : unmanaged

Parameters

sourceBuffer IUnifiedMemoryBuffer<T>
targetDevice IAccelerator
options P2PBufferOptions
cancellationToken CancellationToken

Returns

ValueTask<P2PBuffer<T>>

Type Parameters

T

CreateP2PBufferSliceAsync<T>(P2PBuffer<T>, IAccelerator, int, int, P2PBufferOptions?, CancellationToken)

Creates a buffer slice optimized for P2P operations.

public ValueTask<P2PBuffer<T>> CreateP2PBufferSliceAsync<T>(P2PBuffer<T> sourceBuffer, IAccelerator targetDevice, int startIndex, int elementCount, P2PBufferOptions? options = null, CancellationToken cancellationToken = default) where T : unmanaged

Parameters

sourceBuffer P2PBuffer<T>
targetDevice IAccelerator
startIndex int
elementCount int
options P2PBufferOptions
cancellationToken CancellationToken

Returns

ValueTask<P2PBuffer<T>>

Type Parameters

T

DisposeAsync()

Gets dispose asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

The result of the operation.

EstablishP2PConnectionAsync(IAccelerator, IAccelerator, CancellationToken)

Enables P2P connection between two devices and manages connection state.

public ValueTask<bool> EstablishP2PConnectionAsync(IAccelerator device1, IAccelerator device2, CancellationToken cancellationToken = default)

Parameters

device1 IAccelerator
device2 IAccelerator
cancellationToken CancellationToken

Returns

ValueTask<bool>

GetBufferPoolStatistics()

Gets buffer pool statistics for all devices.

public IReadOnlyList<DeviceBufferPoolStatistics> GetBufferPoolStatistics()

Returns

IReadOnlyList<DeviceBufferPoolStatistics>

GetConnectionStatistics()

Gets P2P connection statistics.

public P2PConnectionStatistics GetConnectionStatistics()

Returns

P2PConnectionStatistics