pub struct NvLink<'device, 'nvml: 'device> { /* private fields */ }
Expand description

Struct that represents a Device’s NvLink.

Obtain this via Device.link_wrapper_for().

Lifetimes are used to enforce that each NvLink instance cannot be used after the Device instance it was obtained from is dropped:

use nvml_wrapper::Nvml;

let nvml = Nvml::init()?;
let device = nvml.device_by_index(0)?;
let link = device.link_wrapper_for(0);

drop(device);

// This won't compile
link.is_active()?;

Note that I cannot test any NvLink methods myself as I do not have access to such a link setup. Test the functionality in this module before you use it.

Implementations§

source§

impl<'device, 'nvml: 'device> NvLink<'device, 'nvml>

source

pub fn device(&self) -> &Device<'_>

Obtain the Device reference stored within this struct.

Obtain the value of this struct’s link field.

source

pub fn is_active(&self) -> Result<bool, NvmlError>

Gets whether or not this Device’s NvLink is active.

§Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the link or Device within this NvLink struct instance is invalid
  • NotSupported, if this Device doesn’t support this feature
  • UnexpectedVariant, for which you can read the docs for
  • Unknown, on any unexpected error
§Device Support

Supports Pascal or newer fully supported devices.

source

pub fn version(&self) -> Result<u32, NvmlError>

Gets the NvLink version of this Device / NvLink.

§Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the link or Device within this NvLink struct instance is invalid
  • NotSupported, if this Device doesn’t support this feature
  • Unknown, on any unexpected error
§Device Support

Supports Pascal or newer fully supported devices.

source

pub fn has_capability(&self, cap_type: Capability) -> Result<bool, NvmlError>

Gets whether or not this Device / NvLink has a Capability.

§Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the link or Device within this NvLink struct instance is invalid
  • NotSupported, if this Device doesn’t support this feature
  • Unknown, on any unexpected error
§Device Support

Supports Pascal or newer fully supported devices.

source

pub fn remote_pci_info(&self) -> Result<PciInfo, NvmlError>

Gets the PCI information for this NvLink’s remote node.

§Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the link or Device within this NvLink struct instance is invalid
  • NotSupported, if this Device doesn’t support this feature
  • Unknown, on any unexpected error
§Device Support

Supports Pascal or newer fully supported devices.

source

pub fn error_counter(&self, counter: ErrorCounter) -> Result<u64, NvmlError>

Gets the specified ErrorCounter value.

§Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the link or Device within this NvLink struct instance is invalid
  • NotSupported, if this Device doesn’t support this feature
  • Unknown, on any unexpected error
§Device Support

Supports Pascal or newer fully supported devices.

source

pub fn reset_error_counters(&mut self) -> Result<(), NvmlError>

Resets all error counters to zero.

§Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the link or Device within this NvLink struct instance is invalid
  • NotSupported, if this Device doesn’t support this feature
  • Unknown, on any unexpected error
§Device Support

Supports Pascal or newer fully supported devices.

source

pub fn set_utilization_control( &mut self, counter: Counter, settings: UtilizationControl, reset_counters: bool ) -> Result<(), NvmlError>

Sets the NvLink utilization counter control information for the specified Counter.

The counters will be reset if reset_counters is true.

§Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the link or Device within this NvLink struct instance is invalid
  • NotSupported, if this Device doesn’t support this feature
  • Unknown, on any unexpected error
§Device Support

Supports Pascal or newer fully supported devices.

source

pub fn utilization_control( &self, counter: Counter ) -> Result<UtilizationControl, NvmlError>

Gets the NvLink utilization counter control information for the specified Counter.

§Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the link or Device within this NvLink struct instance is invalid
  • NotSupported, if this Device doesn’t support this feature
  • Unknown, on any unexpected error
§Device Support

Supports Pascal or newer fully supported devices.

source

pub fn utilization_counter( &self, counter: Counter ) -> Result<UtilizationCounter, NvmlError>

Gets the NvLink utilization counter for the given counter.

The retrieved values are based on the current controls set for the specified Counter. You should use .set_utilization_control() before calling this as the utilization counters have no default state.

I do not attempt to verify, statically or at runtime, that you have controls set for counter prior to calling this method on counter. NVIDIA says that it is “In general[,] good practice”, which does not sound to me as if it is in any way unsafe to make this call without having set controls. I don’t believe it’s worth the overhead of using a Mutex’d bool to track whether or not you have set controls, and it’s certainly not worth the effort to statically verify it via the type system.

That being said, I don’t know what exactly would happen, either, and I have no means of finding out. If you do and discover that garbage values are returned, for instance, I would love to hear about it; that would likely cause this decision to be reconsidered.

§Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the link or Device within this NvLink struct instance is invalid
  • NotSupported, if this Device doesn’t support this feature
  • Unknown, on any unexpected error
§Device Support

Supports Pascal or newer fully supported devices.

source

pub fn freeze_utilization_counter( &mut self, counter: Counter ) -> Result<(), NvmlError>

Freezes the specified NvLink utilization Counter.

Both the receive and send counters will be frozen (if I’m reading NVIDIA’s meaning correctly).

§Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the link or Device within this NvLink struct instance is invalid
  • NotSupported, if this Device doesn’t support this feature
  • Unknown, on any unexpected error
§Device Support

Supports Pascal or newer fully supported devices.

source

pub fn unfreeze_utilization_counter( &mut self, counter: Counter ) -> Result<(), NvmlError>

Unfreezes the specified NvLink utilization Counter.

Both the receive and send counters will be unfrozen (if I’m reading NVIDIA’s meaning correctly).

§Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the link or Device within this NvLink struct instance is invalid
  • NotSupported, if this Device doesn’t support this feature
  • Unknown, on any unexpected error
§Device Support

Supports Pascal or newer fully supported devices.

source

pub fn reset_utilization_counter( &mut self, counter: Counter ) -> Result<(), NvmlError>

Resets the specified NvLink utilization Counter.

Both the receive and send counters will be rest (if I’m reading NVIDIA’s meaning correctly).

§Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the link or Device within this NvLink struct instance is invalid
  • NotSupported, if this Device doesn’t support this feature
  • Unknown, on any unexpected error
§Device Support

Supports Pascal or newer fully supported devices.

Trait Implementations§

source§

impl<'device, 'nvml: 'device> Debug for NvLink<'device, 'nvml>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'device, 'nvml> !RefUnwindSafe for NvLink<'device, 'nvml>

§

impl<'device, 'nvml> Send for NvLink<'device, 'nvml>

§

impl<'device, 'nvml> Sync for NvLink<'device, 'nvml>

§

impl<'device, 'nvml> Unpin for NvLink<'device, 'nvml>

§

impl<'device, 'nvml> !UnwindSafe for NvLink<'device, 'nvml>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.