Skip to content
Merged
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
14 changes: 11 additions & 3 deletions nvml-wrapper/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1990,7 +1990,7 @@ impl<'nvml> Device<'nvml> {

unsafe {
let last_seen_timestamp = last_seen_timestamp.into().unwrap_or(0);
let mut count = match self.process_utilization_stats_count()? {
let mut count = match self.process_utilization_stats_count(last_seen_timestamp)? {
0 => return Ok(vec![]),
v => v,
};
Expand All @@ -2012,13 +2012,21 @@ impl<'nvml> Device<'nvml> {
}
}

fn process_utilization_stats_count(&self) -> Result<c_uint, NvmlError> {
fn process_utilization_stats_count(
&self,
last_seen_timestamp: u64,
) -> Result<c_uint, NvmlError> {
let sym = nvml_sym(self.nvml.lib.nvmlDeviceGetProcessUtilization.as_ref())?;

unsafe {
let mut count: c_uint = 0;

match sym(self.device, ptr::null_mut(), &mut count, 0) {
match sym(
self.device,
ptr::null_mut(),
&mut count,
last_seen_timestamp,
) {
// Despite being undocumented, this appears to be the correct behavior
nvmlReturn_enum_NVML_ERROR_INSUFFICIENT_SIZE => Ok(count),
other => nvml_try(other).map(|_| 0),
Expand Down