Table of Contents

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

IAccelerator

Handle

Gets the native handle for this stream.

public abstract nint Handle { get; }

Property Value

nint

Id

Gets the unique identifier for this stream.

public abstract string Id { get; }

Property Value

string

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

bool

SupportsAsync

Gets whether this stream supports asynchronous operations.

public abstract bool SupportsAsync { get; }

Property Value

bool

Methods

AddCallbackAsync(Action)

Adds a callback to be called when all currently enqueued operations complete.

public abstract ValueTask AddCallbackAsync(Action callback)

Parameters

callback Action

The 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

source IUnifiedMemoryBuffer

The source buffer.

destination IUnifiedMemoryBuffer

The destination buffer.

count int

The number of elements to copy.

Returns

ValueTask

A task representing the copy operation.

Type Parameters

T

The 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

ValueTask

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

buffer IUnifiedMemoryBuffer

The buffer to fill.

value T

The value to fill with.

count int

The number of elements to fill.

Returns

ValueTask

A task representing the fill operation.

Type Parameters

T

The 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

kernel ICompiledKernel

The compiled kernel to launch.

gridDim Dim3

The grid dimensions.

blockDim Dim3

The block dimensions.

arguments object[]

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

event AcceleratorEvent

The 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

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask

A task representing the synchronization.

WaitForEventAsync(AcceleratorEvent)

Waits for an event on this stream.

public abstract ValueTask WaitForEventAsync(AcceleratorEvent acceleratorEvent)

Parameters

acceleratorEvent AcceleratorEvent

The event to wait for.

Returns

ValueTask

A task representing the wait operation.