Table of Contents

Interface IP2PMessageQueue<T>

Namespace
DotCompute.Abstractions.Messaging
Assembly
DotCompute.Abstractions.dll

Represents a peer-to-peer message queue for multi-GPU communication.

public interface IP2PMessageQueue<T> : IAsyncDisposable where T : unmanaged

Type Parameters

T

The message type.

Inherited Members

Remarks

P2P message queues enable efficient message passing between GPU devices using direct P2P memory transfers when available, with automatic fallback to host-mediated transfers when P2P is not supported.

Transfer Modes:

  • DirectP2P: Uses NVLink or PCIe P2P for lowest latency
  • HostStaged: Uses pinned host memory for cross-topology transfers
  • Adaptive: Automatically selects optimal transfer mode

Properties

Capacity

Gets the maximum capacity of the queue.

int Capacity { get; }

Property Value

int

Count

Gets the current number of messages in the queue.

int Count { get; }

Property Value

int

CurrentTransferMode

Gets the current transfer mode being used.

P2PTransferMode CurrentTransferMode { get; }

Property Value

P2PTransferMode

DestinationDeviceId

Gets the destination device identifier.

string DestinationDeviceId { get; }

Property Value

string

IsDirectP2PAvailable

Gets a value indicating whether direct P2P is available for this queue.

bool IsDirectP2PAvailable { get; }

Property Value

bool

IsEmpty

Gets a value indicating whether the queue is empty.

bool IsEmpty { get; }

Property Value

bool

IsFull

Gets a value indicating whether the queue is full.

bool IsFull { get; }

Property Value

bool

SourceDeviceId

Gets the source device identifier.

string SourceDeviceId { get; }

Property Value

string

Methods

ClearAsync(CancellationToken)

Clears all messages from the queue.

ValueTask ClearAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask

GetStatistics()

Gets queue statistics.

P2PQueueStatistics GetStatistics()

Returns

P2PQueueStatistics

ReceiveAsync(CancellationToken)

Receives a message from the source device.

ValueTask<P2PReceiveResult<T>> ReceiveAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<P2PReceiveResult<T>>

The received message, or null if the queue is empty.

ReceiveBatchAsync(int, CancellationToken)

Receives multiple messages from the source device.

ValueTask<P2PBatchReceiveResult<T>> ReceiveBatchAsync(int maxMessages, CancellationToken cancellationToken = default)

Parameters

maxMessages int

Maximum number of messages to receive.

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<P2PBatchReceiveResult<T>>

The received messages.

SendAsync(T, CancellationToken)

Sends a message to the destination device.

ValueTask<P2PSendResult> SendAsync(T message, CancellationToken cancellationToken = default)

Parameters

message T

The message to send.

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<P2PSendResult>

The result of the send operation.

SendBatchAsync(ReadOnlyMemory<T>, CancellationToken)

Sends multiple messages to the destination device in a batch.

ValueTask<P2PBatchSendResult> SendBatchAsync(ReadOnlyMemory<T> messages, CancellationToken cancellationToken = default)

Parameters

messages ReadOnlyMemory<T>

The messages to send.

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<P2PBatchSendResult>

The result of the batch send operation.

TryPeek(out T)

Attempts to peek at the next message without removing it.

bool TryPeek(out T message)

Parameters

message T

The peeked message if available.

Returns

bool

True if a message is available; otherwise, false.