Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix running_compute_processes count handling #36

Merged
merged 2 commits into from
Nov 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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