Skip to content

Commit

Permalink
Include support for new ivpu statistics coming with kernel 6.14
Browse files Browse the repository at this point in the history
  • Loading branch information
nokyan committed Jan 8, 2025
1 parent 167684d commit ef0ba7f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/utils/npu/intel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ impl NpuImpl for IntelNpu {
}

fn used_vram(&self) -> Result<usize> {
self.drm_used_vram().map(|usage| usage as usize)
self.drm_used_memory().map(|usage| usage as usize)
}

fn total_vram(&self) -> Result<usize> {
self.drm_total_vram().map(|usage| usage as usize)
self.drm_total_memory().map(|usage| usage as usize)
}

fn temperature(&self) -> Result<f64> {
Expand All @@ -103,7 +103,7 @@ impl NpuImpl for IntelNpu {
}

fn memory_frequency(&self) -> Result<f64> {
self.hwmon_vram_frequency()
self.hwmon_memory_frequency()
}

fn power_cap(&self) -> Result<f64> {
Expand Down
17 changes: 11 additions & 6 deletions src/utils/npu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,20 @@ pub trait NpuImpl {
}

fn drm_usage(&self) -> Result<isize> {
bail!("usage fallback not implemented")
// No NPU driver actually implements this yet, this is a guess for the future based on drm_usage() for GPUs
self.read_device_int("npu_busy_percent")
}

fn drm_used_vram(&self) -> Result<isize> {
self.read_device_int("mem_info_vram_used")
fn drm_used_memory(&self) -> Result<isize> {
// ivpu will implement this with kernel 6.14, using this as a fallback just in case other vendors start using
// this name as well
self.read_device_int("npu_memory_utilization")
}

fn drm_total_vram(&self) -> Result<isize> {
self.read_device_int("mem_info_vram_total")
fn drm_total_memory(&self) -> Result<isize> {
// No NPU driver actually implements this yet, this is a guess for the future based on ivpu's
// npu_memory_utilization
self.read_device_int("npu_memory_total")
}

fn hwmon_temperature(&self) -> Result<f64> {
Expand All @@ -177,7 +182,7 @@ pub trait NpuImpl {
Ok(self.read_hwmon_int("freq1_input")? as f64)
}

fn hwmon_vram_frequency(&self) -> Result<f64> {
fn hwmon_memory_frequency(&self) -> Result<f64> {
Ok(self.read_hwmon_int("freq2_input")? as f64)
}

Expand Down
6 changes: 3 additions & 3 deletions src/utils/npu/other.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ impl NpuImpl for OtherNpu {
}

fn used_vram(&self) -> Result<usize> {
self.drm_used_vram().map(|usage| usage as usize)
self.drm_used_memory().map(|usage| usage as usize)
}

fn total_vram(&self) -> Result<usize> {
self.drm_total_vram().map(|usage| usage as usize)
self.drm_total_memory().map(|usage| usage as usize)
}

fn temperature(&self) -> Result<f64> {
Expand All @@ -85,7 +85,7 @@ impl NpuImpl for OtherNpu {
}

fn memory_frequency(&self) -> Result<f64> {
self.hwmon_vram_frequency()
self.hwmon_memory_frequency()
}

fn power_cap(&self) -> Result<f64> {
Expand Down

0 comments on commit ef0ba7f

Please sign in to comment.