Skip to content
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
29 changes: 29 additions & 0 deletions nvml-wrapper/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6234,6 +6234,35 @@ impl<'nvml> Device<'nvml> {
HostVgpuMode::try_from(mode)
}
}

/// Query the given vGPU capability
pub fn vgpu_capabilities(&self, cap: VgpuCapability) -> Result<u32, NvmlError> {
let sym = nvml_sym(self.nvml.lib.nvmlDeviceGetVgpuCapabilities.as_ref())?;

unsafe {
let mut res: c_uint = 0;
nvml_try(sym(self.device, cap.as_c(), &mut res))?;

Ok(res)
}
}

pub fn vgpu_set_capabilities(
&self,
cap: VgpuCapability,
enable: bool,
) -> Result<(), NvmlError> {
let sym = nvml_sym(self.nvml.lib.nvmlDeviceSetVgpuCapabilities.as_ref())?;

unsafe {
let state: nvmlEnableState_t = match enable {
true => nvmlEnableState_enum_NVML_FEATURE_ENABLED,
false => nvmlEnableState_enum_NVML_FEATURE_DISABLED,
};

nvml_try(sym(self.device, cap.as_c(), state))
}
}
}

#[cfg(test)]
Expand Down
21 changes: 21 additions & 0 deletions nvml-wrapper/src/enum_wrappers/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,3 +664,24 @@ pub enum HostVgpuMode {
#[wrap(c_variant = "NVML_HOST_VGPU_MODE_SRIOV")]
Sriov,
}

#[derive(EnumWrapper, Debug, Clone, Copy, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[wrap(c_enum = "nvmlDeviceVgpuCapability_enum")]
pub enum VgpuCapability {
/// Fractional vGPU profiles can be used in multi-vGPU settings
#[wrap(c_variant = "NVML_DEVICE_VGPU_CAP_FRACTIONAL_MULTI_VGPU")]
FractionalMultiVgpu,
/// Concurrent execution of timesliced vGPU profiles of different types
#[wrap(c_variant = "NVML_DEVICE_VGPU_CAP_HETEROGENEOUS_TIMESLICE_PROFILES")]
HeterogeneousTimesliceProfiles,
/// Concurrent execution of timesliced vGPU profiles of different framebuffer sizes
#[wrap(c_variant = "NVML_DEVICE_VGPU_CAP_HETEROGENEOUS_TIMESLICE_SIZES")]
HeterogeneousTimesliceSizes,
/// GPU read device buffer expected bandwidth (Mb/s)
#[wrap(c_variant = "NVML_DEVICE_VGPU_CAP_READ_DEVICE_BUFFER_BW")]
ReadDeviceBufferBw,
/// GPU write device buffer expected bandwidth (Mb/s)
#[wrap(c_variant = "NVML_DEVICE_VGPU_CAP_WRITE_DEVICE_BUFFER_BW")]
WriteDeviceBufferBw,
}