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
DeviceType
Gets the device type as a string (e.g., "CPU", "GPU", "TPU").
string DeviceType { get; }
Property Value
Info
Gets device information.
AcceleratorInfo Info { get; }
Property Value
IsAvailable
Gets whether the accelerator is available for use.
bool IsAvailable { get; }
Property Value
Memory
Gets memory manager for this accelerator.
IUnifiedMemoryManager Memory { get; }
Property Value
MemoryManager
Gets the memory manager for this accelerator (alias for Memory).
IUnifiedMemoryManager MemoryManager { get; }
Property Value
Type
Gets the accelerator type.
AcceleratorType Type { get; }
Property Value
Methods
CompileKernelAsync(KernelDefinition, CompilationOptions?, CancellationToken)
Compiles a kernel for execution.
ValueTask<ICompiledKernel> CompileKernelAsync(KernelDefinition definition, CompilationOptions? options = null, CancellationToken cancellationToken = default)
Parameters
definitionKernelDefinitionoptionsCompilationOptionscancellationTokenCancellationToken
Returns
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
cancellationTokenCancellationTokenCancellation 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
cancellationTokenCancellationTokenCancellation 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
cancellationTokenCancellationTokenCancellation 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
cancellationTokenCancellationTokenCancellation 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
optionsResetOptionsReset configuration options. If null, uses Default.
cancellationTokenCancellationTokenCancellation 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
cancellationTokenCancellationToken