Skip to content

Commit

Permalink
Fix running_compute_processes count handling (#36)
Browse files Browse the repository at this point in the history
* Fix running_compute_processes count handling

Consistent with running_graphics_processes
  • Loading branch information
jjyyxx authored Nov 26, 2022
1 parent 6be9c14 commit b8e972b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion nvml-wrapper/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
}
}
Expand Down

0 comments on commit b8e972b

Please sign in to comment.