Table of Contents

Class CpuAccelerator

Namespace
DotCompute.Backends.CPU.Accelerators
Assembly
DotCompute.Backends.CPU.dll

CPU-based compute accelerator with SIMD vectorization support. Migrated to use BaseAccelerator, reducing code by 75% while maintaining full functionality.

public sealed class CpuAccelerator : BaseAccelerator, IAccelerator, IAsyncDisposable
Inheritance
CpuAccelerator
Implements
Inherited Members

Constructors

CpuAccelerator(IOptions<CpuAcceleratorOptions>, IOptions<CpuThreadPoolOptions>, ILogger<CpuAccelerator>)

CPU-based compute accelerator with SIMD vectorization support. Migrated to use BaseAccelerator, reducing code by 75% while maintaining full functionality.

public CpuAccelerator(IOptions<CpuAcceleratorOptions> options, IOptions<CpuThreadPoolOptions> threadPoolOptions, ILogger<CpuAccelerator> logger)

Parameters

options IOptions<CpuAcceleratorOptions>
threadPoolOptions IOptions<CpuThreadPoolOptions>
logger ILogger<CpuAccelerator>

Methods

CompileKernelCoreAsync(KernelDefinition, CompilationOptions, CancellationToken)

Core kernel compilation logic to be implemented by derived classes.

protected override ValueTask<ICompiledKernel> CompileKernelCoreAsync(KernelDefinition definition, CompilationOptions options, CancellationToken cancellationToken)

Parameters

definition KernelDefinition
options CompilationOptions
cancellationToken CancellationToken

Returns

ValueTask<ICompiledKernel>

DisposeCoreAsync()

Core disposal logic to be implemented by derived classes.

protected override ValueTask DisposeCoreAsync()

Returns

ValueTask

GetHealthSnapshotAsync(CancellationToken)

Gets a comprehensive health snapshot of the CPU accelerator.

public override ValueTask<DeviceHealthSnapshot> GetHealthSnapshotAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<DeviceHealthSnapshot>

A task containing the device health snapshot.

Remarks

CPU health monitoring uses .NET's cross-platform System.Diagnostics APIs to collect process-level and system-level metrics.

Available Metrics: - CPU utilization (process-level percentage) - Memory usage (working set, private memory, virtual memory) - Thread count (active threads in thread pool) - Garbage collection metrics (Gen0, Gen1, Gen2 collections) - System memory information (total physical memory)

Cross-Platform Support: - Windows: Full metrics available - Linux: Full metrics available via /proc - macOS: Full metrics available via system APIs

Limitations: - CPU utilization is process-level, not system-wide - No hardware temperature sensors - No power consumption metrics - No individual core utilization breakdown

Performance: Typically sub-millisecond as metrics are queried from OS-cached process information.

GetProfilingMetricsAsync(CancellationToken)

Gets current profiling metrics from the CPU.

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

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<IReadOnlyList<ProfilingMetric>>

A task containing the collection of profiling metrics.

GetProfilingSnapshotAsync(CancellationToken)

Gets a comprehensive profiling snapshot of CPU accelerator performance.

public override ValueTask<ProfilingSnapshot> GetProfilingSnapshotAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<ProfilingSnapshot>

A task containing the profiling snapshot.

Remarks

CPU profiling tracks kernel execution performance using high-resolution Stopwatch timing. This provides detailed insights into SIMD vectorization effectiveness and thread pool utilization.

Available Metrics: - Kernel execution statistics (average, min, max, median, P95, P99) - Memory allocation statistics - Thread pool utilization - SIMD vectorization effectiveness - Performance trends and bottleneck identification

Profiling Overhead: Minimal (<0.1%) as timing uses high-resolution Stopwatch.

GetSensorReadingsAsync(CancellationToken)

Gets current sensor readings from the CPU accelerator.

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

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<IReadOnlyList<SensorReading>>

A task containing the collection of sensor readings.

Remarks

CPU sensor readings include process-level metrics and system-level information. All metrics are cross-platform compatible.

ResetAsync(ResetOptions?, CancellationToken)

Resets the CPU accelerator to a clean state.

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

Parameters

options ResetOptions
cancellationToken CancellationToken

Returns

ValueTask<ResetResult>

Remarks

CPU reset operations:

  • Soft: No-op (CPU operations are synchronous)
  • Context: Clear thread pool statistics
  • Hard: Clear memory statistics and thread pool state
  • Full: Complete reset with full reinitialization

Note: CPU accelerator operations are primarily synchronous, so reset mainly involves clearing statistics and cached state rather than device-level reset.

SynchronizeCoreAsync(CancellationToken)

Core synchronization logic to be implemented by derived classes.

protected override ValueTask SynchronizeCoreAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

ValueTask