Table of Contents

Interface IAccelerator

Namespace
DotCompute.Abstractions
Assembly
DotCompute.Abstractions.dll

Represents a compute accelerator device.

public interface IAccelerator : IAsyncDisposable
Inherited Members

Properties

Context

Gets the accelerator context.

AcceleratorContext Context { get; }

Property Value

AcceleratorContext

DeviceType

Gets the device type as a string (e.g., "CPU", "GPU", "TPU").

string DeviceType { get; }

Property Value

string

Info

Gets device information.

AcceleratorInfo Info { get; }

Property Value

AcceleratorInfo

IsAvailable

Gets whether the accelerator is available for use.

bool IsAvailable { get; }

Property Value

bool

Memory

Gets memory manager for this accelerator.

IUnifiedMemoryManager Memory { get; }

Property Value

IUnifiedMemoryManager

MemoryManager

Gets the memory manager for this accelerator (alias for Memory).

IUnifiedMemoryManager MemoryManager { get; }

Property Value

IUnifiedMemoryManager

Type

Gets the accelerator type.

AcceleratorType Type { get; }

Property Value

AcceleratorType

Methods

CompileKernelAsync(KernelDefinition, CompilationOptions?, CancellationToken)

Compiles a kernel for execution.

ValueTask<ICompiledKernel> CompileKernelAsync(KernelDefinition definition, CompilationOptions? options = null, CancellationToken cancellationToken = default)

Parameters

definition KernelDefinition
options CompilationOptions
cancellationToken CancellationToken

Returns

ValueTask<ICompiledKernel>

GetHealthSnapshotAsync(CancellationToken)

Gets a comprehensive health snapshot of the device including sensor readings, health status, and performance metrics.

ValueTask<DeviceHealthSnapshot> GetHealthSnapshotAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<DeviceHealthSnapshot>

A task containing the device health snapshot.

Remarks

This method queries the device for real-time health information including: - Temperature, power consumption, and utilization - Memory usage and availability - Error counts and device status - Throttling information

Performance: Typically takes 1-10ms to collect all metrics. For high-frequency monitoring, consider caching snapshots for 100-500ms.

Orleans Integration: Use for grain placement decisions and health monitoring.

GetProfilingMetricsAsync(CancellationToken)

Gets current profiling metrics from the device.

ValueTask<IReadOnlyList<ProfilingMetric>> GetProfilingMetricsAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<IReadOnlyList<ProfilingMetric>>

A task containing the collection of profiling metrics.

Remarks

This is a lighter-weight alternative to GetProfilingSnapshotAsync(CancellationToken) when you only need raw metrics without statistics or recommendations.

GetProfilingSnapshotAsync(CancellationToken)

Gets a comprehensive profiling snapshot of accelerator performance.

ValueTask<ProfilingSnapshot> GetProfilingSnapshotAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<ProfilingSnapshot>

A task containing the profiling snapshot.

Remarks

This method provides detailed performance metrics including: - Kernel execution statistics (average, min, max, percentiles) - Memory operation statistics (bandwidth, transfer times) - Device utilization metrics - Performance trends and bottlenecks - Optimization recommendations

Performance: Typically takes 1-5ms to collect all metrics. Profiling overhead is minimal (<1%) when not actively querying.

Use Cases: Performance optimization, backend selection, monitoring dashboards.

GetSensorReadingsAsync(CancellationToken)

Gets current sensor readings from the device.

ValueTask<IReadOnlyList<SensorReading>> GetSensorReadingsAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<IReadOnlyList<SensorReading>>

A task containing the collection of available sensor readings.

Remarks

This is a lighter-weight alternative to GetHealthSnapshotAsync(CancellationToken) when you only need raw sensor data without health scoring or status analysis.

ResetAsync(ResetOptions?, CancellationToken)

Resets the accelerator device to a clean state.

ValueTask<ResetResult> ResetAsync(ResetOptions? options = null, CancellationToken cancellationToken = default)

Parameters

options ResetOptions

Reset configuration options. If null, uses Default.

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<ResetResult>

A task containing detailed information about the reset operation.

Remarks

Device reset clears device state and optionally reinitializes resources. The extent of reset depends on ResetType:

  • Soft: Flush queues, clear pending operations (1-10ms)
  • Context: Reset context, clear caches (10-50ms)
  • Hard: Full reset, clear all memory (50-200ms)
  • Full: Complete reinitialization (200-1000ms)

Important: Hard and Full invalidate all existing UnifiedBuffer instances. The application must recreate buffers after reset completes.

Orleans Integration: Use during grain deactivation, error recovery, or when transferring device ownership between grains. Consider GrainDeactivation for typical grain lifecycle scenarios.

Error Recovery: When recovering from device errors or hangs, use ErrorRecovery which forces a hard reset and clears all state.

Thread Safety: Reset operations are thread-safe. Concurrent operations will wait for completion or be cancelled depending on WaitForCompletion.

Exceptions

TimeoutException

Thrown if reset exceeds Timeout.

InvalidOperationException

Thrown if reset cannot be performed (e.g., device lost).

ObjectDisposedException

Thrown if the accelerator has been disposed.

SynchronizeAsync(CancellationToken)

Synchronizes all pending operations.

ValueTask SynchronizeAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

ValueTask