Skip to main content

ComputeDevice

Trait ComputeDevice 

Source
pub trait ComputeDevice: Send + Sync {
Show 26 methods // Required methods fn device_id(&self) -> DeviceId; fn device_name(&self) -> &str; fn device_type(&self) -> DeviceType; fn compute_utilization(&self) -> Result<f64, GpuError>; fn compute_clock_mhz(&self) -> Result<u32, GpuError>; fn compute_temperature_c(&self) -> Result<f64, GpuError>; fn compute_power_watts(&self) -> Result<f64, GpuError>; fn compute_power_limit_watts(&self) -> Result<f64, GpuError>; fn memory_used_bytes(&self) -> Result<u64, GpuError>; fn memory_total_bytes(&self) -> Result<u64, GpuError>; fn memory_bandwidth_gbps(&self) -> Result<f64, GpuError>; fn compute_unit_count(&self) -> u32; fn active_compute_units(&self) -> Result<u32, GpuError>; fn pcie_tx_bytes_per_sec(&self) -> Result<u64, GpuError>; fn pcie_rx_bytes_per_sec(&self) -> Result<u64, GpuError>; fn pcie_generation(&self) -> u8; fn pcie_width(&self) -> u8; fn refresh(&mut self) -> Result<(), GpuError>; // Provided methods fn memory_usage_percent(&self) -> Result<f64, GpuError> { ... } fn memory_available_bytes(&self) -> Result<u64, GpuError> { ... } fn memory_used_mb(&self) -> Result<u64, GpuError> { ... } fn memory_total_mb(&self) -> Result<u64, GpuError> { ... } fn memory_total_gb(&self) -> Result<f64, GpuError> { ... } fn power_usage_percent(&self) -> Result<f64, GpuError> { ... } fn is_thermal_throttling(&self) -> Result<bool, GpuError> { ... } fn is_power_throttling(&self) -> Result<bool, GpuError> { ... }
}
Expand description

Unified compute device abstraction

All compute devices (CPU, NVIDIA GPU, AMD GPU) implement this trait for consistent monitoring across heterogeneous hardware.

§Example

use trueno_gpu::monitor::{ComputeDevice, CpuDevice};

let cpu = CpuDevice::new();
println!("CPU: {} @ {:.1}%", cpu.device_name(), cpu.compute_utilization()?);

Required Methods§

Source

fn device_id(&self) -> DeviceId

Get the unique device identifier

Source

fn device_name(&self) -> &str

Get the device name (e.g., “NVIDIA GeForce RTX 4090”)

Source

fn device_type(&self) -> DeviceType

Get the device type

Source

fn compute_utilization(&self) -> Result<f64, GpuError>

Get compute utilization (0.0-100.0%)

Source

fn compute_clock_mhz(&self) -> Result<u32, GpuError>

Get compute clock speed in MHz

Source

fn compute_temperature_c(&self) -> Result<f64, GpuError>

Get compute temperature in Celsius

Source

fn compute_power_watts(&self) -> Result<f64, GpuError>

Get current power consumption in Watts

Source

fn compute_power_limit_watts(&self) -> Result<f64, GpuError>

Get power limit in Watts

Source

fn memory_used_bytes(&self) -> Result<u64, GpuError>

Get used memory in bytes

Source

fn memory_total_bytes(&self) -> Result<u64, GpuError>

Get total memory in bytes

Source

fn memory_bandwidth_gbps(&self) -> Result<f64, GpuError>

Get memory bandwidth in GB/s (if available)

Source

fn compute_unit_count(&self) -> u32

Get number of compute units (SMs for NVIDIA, CUs for AMD, cores for CPU)

Source

fn active_compute_units(&self) -> Result<u32, GpuError>

Get number of active compute units

Source

fn pcie_tx_bytes_per_sec(&self) -> Result<u64, GpuError>

Get PCIe TX bytes per second (GPU only)

Source

fn pcie_rx_bytes_per_sec(&self) -> Result<u64, GpuError>

Get PCIe RX bytes per second (GPU only)

Source

fn pcie_generation(&self) -> u8

Get PCIe generation (1, 2, 3, 4, 5)

Source

fn pcie_width(&self) -> u8

Get PCIe width (x1, x4, x8, x16)

Source

fn refresh(&mut self) -> Result<(), GpuError>

Refresh metrics from hardware

Provided Methods§

Source

fn memory_usage_percent(&self) -> Result<f64, GpuError>

Get memory usage percentage (0.0-100.0)

Source

fn memory_available_bytes(&self) -> Result<u64, GpuError>

Get available memory in bytes

Source

fn memory_used_mb(&self) -> Result<u64, GpuError>

Get memory used in MB

Source

fn memory_total_mb(&self) -> Result<u64, GpuError>

Get memory total in MB

Source

fn memory_total_gb(&self) -> Result<f64, GpuError>

Get memory total in GB

Source

fn power_usage_percent(&self) -> Result<f64, GpuError>

Get power usage percentage (current/limit * 100)

Source

fn is_thermal_throttling(&self) -> Result<bool, GpuError>

Check if device is throttling due to temperature

Source

fn is_power_throttling(&self) -> Result<bool, GpuError>

Check if device is throttling due to power

Implementors§