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
TThe 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
Count
Gets the current number of messages in the queue.
int Count { get; }
Property Value
CurrentTransferMode
Gets the current transfer mode being used.
P2PTransferMode CurrentTransferMode { get; }
Property Value
DestinationDeviceId
Gets the destination device identifier.
string DestinationDeviceId { get; }
Property Value
IsDirectP2PAvailable
Gets a value indicating whether direct P2P is available for this queue.
bool IsDirectP2PAvailable { get; }
Property Value
IsEmpty
Gets a value indicating whether the queue is empty.
bool IsEmpty { get; }
Property Value
IsFull
Gets a value indicating whether the queue is full.
bool IsFull { get; }
Property Value
SourceDeviceId
Gets the source device identifier.
string SourceDeviceId { get; }
Property Value
Methods
ClearAsync(CancellationToken)
Clears all messages from the queue.
ValueTask ClearAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancellation token.
Returns
GetStatistics()
Gets queue statistics.
P2PQueueStatistics GetStatistics()
Returns
ReceiveAsync(CancellationToken)
Receives a message from the source device.
ValueTask<P2PReceiveResult<T>> ReceiveAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancellation 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
maxMessagesintMaximum number of messages to receive.
cancellationTokenCancellationTokenCancellation 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
messageTThe message to send.
cancellationTokenCancellationTokenCancellation 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
messagesReadOnlyMemory<T>The messages to send.
cancellationTokenCancellationTokenCancellation 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
messageTThe peeked message if available.
Returns
- bool
True if a message is available; otherwise, false.