From b6745a4eaa02e68dd876b8fc3b5c14b9652b5455 Mon Sep 17 00:00:00 2001 From: JYX Date: Thu, 13 Oct 2022 10:54:20 +0800 Subject: [PATCH 1/2] Fix running_compute_processes count handling Consistent with running_graphics_processes --- nvml-wrapper/src/device.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nvml-wrapper/src/device.rs b/nvml-wrapper/src/device.rs index 71c4e25..9fe9958 100644 --- a/nvml-wrapper/src/device.rs +++ b/nvml-wrapper/src/device.rs @@ -565,7 +565,7 @@ impl<'nvml> Device<'nvml> { unsafe { let mut count: c_uint = match self.running_compute_processes_count()? { 0 => return Ok(vec![]), - value => value + 5, + value => value, }; // Add a bit of headroom in case more processes are launched in // between the above call to get the expected count and the time we @@ -575,6 +575,7 @@ impl<'nvml> Device<'nvml> { nvml_try(sym(self.device, &mut count, processes.as_mut_ptr()))?; + processes.truncate(count as usize); Ok(processes.into_iter().map(ProcessInfo::from).collect()) } } From 1992820ecd3288584239c1a613cad5f0a9dccc7b Mon Sep 17 00:00:00 2001 From: Jarek Samic Date: Fri, 25 Nov 2022 20:00:35 -0500 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6817e1c..423def8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,13 @@ This file describes the changes / additions / fixes between wrapper releases, tr * `Brand` * Added new variants ([#35](https://github.com/Cldfire/nvml-wrapper/pull/35) - @nemosupremo) +### Fixed + +* `Device` + * `running_compute_processes()` + * Fixed count handling ([#36](https://github.com/Cldfire/nvml-wrapper/pull/36) - @jjyyxx) + * This bug would have caused five blank process information structs to be returned in addition to actual process information if there were any running compute processes. + ### Internal * SPDX expressions in `Cargo.toml` files have been updated to avoid using the now-deprecated slash syntax ([#32](https://github.com/Cldfire/nvml-wrapper/pull/32) - @KisaragiEffective)