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§
Sourcefn device_name(&self) -> &str
fn device_name(&self) -> &str
Get the device name (e.g., “NVIDIA GeForce RTX 4090”)
Sourcefn device_type(&self) -> DeviceType
fn device_type(&self) -> DeviceType
Get the device type
Sourcefn compute_utilization(&self) -> Result<f64, GpuError>
fn compute_utilization(&self) -> Result<f64, GpuError>
Get compute utilization (0.0-100.0%)
Sourcefn compute_clock_mhz(&self) -> Result<u32, GpuError>
fn compute_clock_mhz(&self) -> Result<u32, GpuError>
Get compute clock speed in MHz
Sourcefn compute_temperature_c(&self) -> Result<f64, GpuError>
fn compute_temperature_c(&self) -> Result<f64, GpuError>
Get compute temperature in Celsius
Sourcefn compute_power_watts(&self) -> Result<f64, GpuError>
fn compute_power_watts(&self) -> Result<f64, GpuError>
Get current power consumption in Watts
Sourcefn compute_power_limit_watts(&self) -> Result<f64, GpuError>
fn compute_power_limit_watts(&self) -> Result<f64, GpuError>
Get power limit in Watts
Sourcefn memory_used_bytes(&self) -> Result<u64, GpuError>
fn memory_used_bytes(&self) -> Result<u64, GpuError>
Get used memory in bytes
Sourcefn memory_total_bytes(&self) -> Result<u64, GpuError>
fn memory_total_bytes(&self) -> Result<u64, GpuError>
Get total memory in bytes
Sourcefn memory_bandwidth_gbps(&self) -> Result<f64, GpuError>
fn memory_bandwidth_gbps(&self) -> Result<f64, GpuError>
Get memory bandwidth in GB/s (if available)
Sourcefn compute_unit_count(&self) -> u32
fn compute_unit_count(&self) -> u32
Get number of compute units (SMs for NVIDIA, CUs for AMD, cores for CPU)
Sourcefn active_compute_units(&self) -> Result<u32, GpuError>
fn active_compute_units(&self) -> Result<u32, GpuError>
Get number of active compute units
Sourcefn pcie_tx_bytes_per_sec(&self) -> Result<u64, GpuError>
fn pcie_tx_bytes_per_sec(&self) -> Result<u64, GpuError>
Get PCIe TX bytes per second (GPU only)
Sourcefn pcie_rx_bytes_per_sec(&self) -> Result<u64, GpuError>
fn pcie_rx_bytes_per_sec(&self) -> Result<u64, GpuError>
Get PCIe RX bytes per second (GPU only)
Sourcefn pcie_generation(&self) -> u8
fn pcie_generation(&self) -> u8
Get PCIe generation (1, 2, 3, 4, 5)
Sourcefn pcie_width(&self) -> u8
fn pcie_width(&self) -> u8
Get PCIe width (x1, x4, x8, x16)
Provided Methods§
Sourcefn memory_usage_percent(&self) -> Result<f64, GpuError>
fn memory_usage_percent(&self) -> Result<f64, GpuError>
Get memory usage percentage (0.0-100.0)
Sourcefn memory_available_bytes(&self) -> Result<u64, GpuError>
fn memory_available_bytes(&self) -> Result<u64, GpuError>
Get available memory in bytes
Sourcefn memory_used_mb(&self) -> Result<u64, GpuError>
fn memory_used_mb(&self) -> Result<u64, GpuError>
Get memory used in MB
Sourcefn memory_total_mb(&self) -> Result<u64, GpuError>
fn memory_total_mb(&self) -> Result<u64, GpuError>
Get memory total in MB
Sourcefn memory_total_gb(&self) -> Result<f64, GpuError>
fn memory_total_gb(&self) -> Result<f64, GpuError>
Get memory total in GB
Sourcefn power_usage_percent(&self) -> Result<f64, GpuError>
fn power_usage_percent(&self) -> Result<f64, GpuError>
Get power usage percentage (current/limit * 100)
Sourcefn is_thermal_throttling(&self) -> Result<bool, GpuError>
fn is_thermal_throttling(&self) -> Result<bool, GpuError>
Check if device is throttling due to temperature
Sourcefn is_power_throttling(&self) -> Result<bool, GpuError>
fn is_power_throttling(&self) -> Result<bool, GpuError>
Check if device is throttling due to power