Table of Contents

Class CudaStreamManagerProduction

Namespace
DotCompute.Backends.CUDA.Execution
Assembly
DotCompute.Backends.CUDA.dll

Production-grade CUDA stream manager with stream pools, priorities, callbacks, and graph capture.

public sealed class CudaStreamManagerProduction : IDisposable
Inheritance
CudaStreamManagerProduction
Implements
Inherited Members
Extension Methods

Constructors

CudaStreamManagerProduction(CudaContext, ILogger<CudaStreamManagerProduction>, int)

Initializes a new instance of the CudaStreamManagerProduction class.

public CudaStreamManagerProduction(CudaContext context, ILogger<CudaStreamManagerProduction> logger, int maxPoolSize = 32)

Parameters

context CudaContext

The context.

logger ILogger<CudaStreamManagerProduction>

The logger.

maxPoolSize int

The max pool size.

Properties

IsCapturing

Gets whether graph capture is currently active.

public bool IsCapturing { get; }

Property Value

bool

PrioritiesSupported

Gets whether stream priorities are supported.

public bool PrioritiesSupported { get; }

Property Value

bool

Statistics

Gets stream statistics.

public StreamStatistics Statistics { get; }

Property Value

StreamStatistics

Methods

AddCallback(nint, Action, string?)

Adds a callback to a stream.

public void AddCallback(nint stream, Action callback, string? description = null)

Parameters

stream nint
callback Action
description string

BeginCapture(nint, CudaGraphCaptureMode)

Begins graph capture on a stream.

public void BeginCapture(nint stream, CudaGraphCaptureMode mode = CudaGraphCaptureMode.Global)

Parameters

stream nint
mode CudaGraphCaptureMode

CreateStream(string?, StreamPriority, StreamFlags)

Creates or gets a stream with the specified priority.

public nint CreateStream(string? name = null, StreamPriority priority = StreamPriority.Normal, StreamFlags flags = StreamFlags.NonBlocking)

Parameters

name string
priority StreamPriority
flags StreamFlags

Returns

nint

Dispose()

Performs dispose.

public void Dispose()

EndCapture()

Ends graph capture and returns the captured graph.

public nint EndCapture()

Returns

nint

InstantiateGraph(nint)

Creates an executable graph instance from a captured graph.

public nint InstantiateGraph(nint graph)

Parameters

graph nint

Returns

nint

IsStreamComplete(nint)

Queries if a stream has completed all operations.

public bool IsStreamComplete(nint stream)

Parameters

stream nint

Returns

bool

LaunchGraph(nint, nint)

Launches a graph on a stream.

public void LaunchGraph(nint graphExec, nint stream)

Parameters

graphExec nint
stream nint

RecordEvent(nint, nint)

Records an event on a stream.

public void RecordEvent(nint eventHandle, nint stream)

Parameters

eventHandle nint
stream nint

ReturnStream(nint)

Returns a stream to the pool.

public void ReturnStream(nint stream)

Parameters

stream nint

SynchronizeAsync(CancellationToken)

Asynchronously synchronizes all active streams.

public ValueTask SynchronizeAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

ValueTask

A task that completes when all streams are synchronized.

SynchronizeStream(nint)

Synchronizes a stream.

public void SynchronizeStream(nint stream)

Parameters

stream nint

WaitEvent(nint, nint)

Waits for an event on a stream.

public void WaitEvent(nint stream, nint eventHandle)

Parameters

stream nint
eventHandle nint