Table of Contents

Interface IDeviceManager

Namespace
Orleans.GpuBridge.Abstractions.Providers
Assembly
Orleans.GpuBridge.Abstractions.dll

Interface for managing compute devices in GPU backends. The device manager is responsible for discovering, enumerating, and managing compute devices available to the application, as well as creating execution contexts and providing device metrics for monitoring and optimization purposes.

public interface IDeviceManager : IDisposable
Inherited Members

Methods

CreateContextAsync(IComputeDevice, ContextOptions, CancellationToken)

Creates a compute context on the specified device. A compute context represents an execution environment where kernels can be compiled, loaded, and executed. Multiple contexts can exist on the same device.

Task<IComputeContext> CreateContextAsync(IComputeDevice device, ContextOptions options, CancellationToken cancellationToken = default)

Parameters

device IComputeDevice

The device on which to create the context.

options ContextOptions

Configuration options for the context creation.

cancellationToken CancellationToken

Token to cancel the context creation operation.

Returns

Task<IComputeContext>

A task that completes with the created compute context.

GetDefaultDevice()

Gets the default device for computation. This is typically the most capable device available, or the device designated as the primary compute device by the system or backend provider.

IComputeDevice GetDefaultDevice()

Returns

IComputeDevice

The default compute device for the system.

GetDevice(int)

Gets a specific device by its index in the device enumeration.

IComputeDevice? GetDevice(int deviceIndex)

Parameters

deviceIndex int

The zero-based index of the device to retrieve.

Returns

IComputeDevice

The device at the specified index, or null if the index is invalid.

GetDeviceMetricsAsync(IComputeDevice, CancellationToken)

Gets current utilization and performance metrics for the specified device. This information can be used for monitoring, load balancing, and performance optimization decisions.

Task<DeviceMetrics> GetDeviceMetricsAsync(IComputeDevice device, CancellationToken cancellationToken = default)

Parameters

device IComputeDevice

The device for which to retrieve metrics.

cancellationToken CancellationToken

Token to cancel the metrics retrieval operation.

Returns

Task<DeviceMetrics>

A task that completes with the current device metrics.

GetDevices()

Gets all available compute devices discovered by the device manager. This list represents all devices that are currently available for use, regardless of their current status or utilization.

IReadOnlyList<IComputeDevice> GetDevices()

Returns

IReadOnlyList<IComputeDevice>

A read-only list of all discovered compute devices.

InitializeAsync(CancellationToken)

Initializes the device manager and discovers available devices. This method performs the initial device enumeration and setup required before other operations can be performed. It should be called once during application startup.

Task InitializeAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Token to cancel the initialization operation.

Returns

Task

A task that completes when initialization is finished.

ResetDeviceAsync(IComputeDevice, CancellationToken)

Resets the specified device, clearing its memory and resetting its state. This operation will invalidate all existing contexts and resources associated with the device. Use this method to recover from error conditions or to ensure a clean state for new operations.

Task ResetDeviceAsync(IComputeDevice device, CancellationToken cancellationToken = default)

Parameters

device IComputeDevice

The device to reset.

cancellationToken CancellationToken

Token to cancel the reset operation.

Returns

Task

A task that completes when the device has been reset.

SelectDevice(DeviceSelectionCriteria)

Selects the best device based on the specified requirements and preferences. This method evaluates all available devices against the provided criteria and returns the device that best matches the requirements.

IComputeDevice SelectDevice(DeviceSelectionCriteria criteria)

Parameters

criteria DeviceSelectionCriteria

The selection criteria and preferences for device selection.

Returns

IComputeDevice

The device that best matches the specified criteria.