Class ComputeStream
- Namespace
- DotCompute.Abstractions
- Assembly
- DotCompute.Abstractions.dll
Represents an execution stream on an accelerator for asynchronous command submission. Streams allow overlapping of computation and data transfers.
public abstract class ComputeStream : IAsyncDisposable
- Inheritance
-
ComputeStream
- Implements
- Inherited Members
Properties
Accelerator
Gets the accelerator this stream belongs to.
public abstract IAccelerator Accelerator { get; }
Property Value
Handle
Gets the native handle for this stream.
public abstract nint Handle { get; }
Property Value
Id
Gets the unique identifier for this stream.
public abstract string Id { get; }
Property Value
IsCompleted
Gets whether this stream has completed all enqueued operations.
public abstract bool IsCompleted { get; }
Property Value
- bool
True if all operations are complete, false otherwise.
IsDefault
Gets whether this stream is the default stream for the accelerator.
public abstract bool IsDefault { get; }
Property Value
SupportsAsync
Gets whether this stream supports asynchronous operations.
public abstract bool SupportsAsync { get; }
Property Value
Methods
AddCallbackAsync(Action)
Adds a callback to be called when all currently enqueued operations complete.
public abstract ValueTask AddCallbackAsync(Action callback)
Parameters
callbackActionThe callback to invoke.
Returns
- ValueTask
A task representing the callback scheduling.
CopyAsync<T>(IUnifiedMemoryBuffer, IUnifiedMemoryBuffer, int)
Enqueues a memory copy operation on this stream.
public abstract ValueTask CopyAsync<T>(IUnifiedMemoryBuffer source, IUnifiedMemoryBuffer destination, int count) where T : unmanaged
Parameters
sourceIUnifiedMemoryBufferThe source buffer.
destinationIUnifiedMemoryBufferThe destination buffer.
countintThe number of elements to copy.
Returns
- ValueTask
A task representing the copy operation.
Type Parameters
TThe element type.
CreateEvent()
Creates an event that can be used for synchronization.
public abstract AcceleratorEvent CreateEvent()
Returns
- AcceleratorEvent
A new accelerator event.
DisposeAsync()
Disposes of this stream asynchronously.
public abstract ValueTask DisposeAsync()
Returns
FillAsync<T>(IUnifiedMemoryBuffer, T, int)
Enqueues a memory fill operation on this stream.
public abstract ValueTask FillAsync<T>(IUnifiedMemoryBuffer buffer, T value, int count) where T : unmanaged
Parameters
bufferIUnifiedMemoryBufferThe buffer to fill.
valueTThe value to fill with.
countintThe number of elements to fill.
Returns
- ValueTask
A task representing the fill operation.
Type Parameters
TThe element type.
LaunchKernelAsync(ICompiledKernel, Dim3, Dim3, params object[])
Enqueues a kernel launch on this stream.
public abstract ValueTask LaunchKernelAsync(ICompiledKernel kernel, Dim3 gridDim, Dim3 blockDim, params object[] arguments)
Parameters
kernelICompiledKernelThe compiled kernel to launch.
gridDimDim3The grid dimensions.
blockDimDim3The block dimensions.
argumentsobject[]The kernel arguments.
Returns
- ValueTask
A task representing the kernel execution.
RecordEventAsync(AcceleratorEvent)
Records an event on this stream.
[SuppressMessage("Naming", "CA1716:In virtual/interface member ComputeStream.RecordEventAsync(AcceleratorEvent), rename parameter event", Justification = "Parameter name semantically correct; languages can escape reserved keywords")]
public abstract ValueTask RecordEventAsync(AcceleratorEvent @event)
Parameters
eventAcceleratorEventThe event to record.
Returns
- ValueTask
A task representing the record operation.
SynchronizeAsync(CancellationToken)
Synchronizes this stream, waiting for all enqueued operations to complete.
public abstract ValueTask SynchronizeAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancellation token.
Returns
- ValueTask
A task representing the synchronization.
WaitForEventAsync(AcceleratorEvent)
Waits for an event on this stream.
public abstract ValueTask WaitForEventAsync(AcceleratorEvent acceleratorEvent)
Parameters
acceleratorEventAcceleratorEventThe event to wait for.
Returns
- ValueTask
A task representing the wait operation.