-
Notifications
You must be signed in to change notification settings - Fork 32
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
Support for querying scoped fields #53
Comments
Thanks for the heads up, looks like What do you think about changing: pub fn field_values_for(
&self,
id_slice: &[FieldId],
) -> Result<Vec<Result<FieldValueSample, NvmlError>>, NvmlError> { to: pub fn field_values_for(
&self,
requests_slice: &[FieldValueRequest],
) -> Result<Vec<Result<FieldValueSample, NvmlError>>, NvmlError> { Where /// Specify a field ID and an optional scope ID for requesting data samples
/// from a device.
///
/// Used in [`crate::struct_wrappers::device::FieldValueSample`] and
/// [`crate::device::Device::field_values_for()`].
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct FieldValueRequest {
/// Populate this newtype with the constants `nvml_wrapper::sys_exports::field_id::*`.
pub id: FieldId,
/// Optionally populate this with a `scopeId` appropriate for the associated [`FieldId`].
///
/// See NVIDIA's field ID constant docs (`NVML_FI_*`) to understand what scope
/// IDs may be valid for which field IDs.
pub scope_id: Option<ScopeId>,
}
impl FieldValueRequest {
pub fn id(id: FieldId) -> Self {
Self { id, scope_id: None }
}
pub fn id_with_scope(id: FieldId, scope_id: ScopeId) -> Self {
Self {
id,
scope_id: Some(scope_id),
}
}
} |
That makes sense. I have submitted PR #55 which changes |
The current implementation of
Device::field_values_for
is too limiting. The caller can only pass in a slice of field IDs to populatenvmlFieldValue_t::fieldId
while all other struct members are set to zero, whilenvmlDeviceGetFieldValues
actually also usesnvmlFieldValue_t::scopeId
as input when querying several fields such as NVLink remote IDs, NVLink ECC counters, or power draw and power limits.I would like to contribute a function that allows passing in both
fieldId
andscopeId
and was wondering whether that should replaceDevice::field_values_for
or be a separate function, e.g.Device::scoped_field_values_for
.The text was updated successfully, but these errors were encountered: