Skip to main content

GpmSample

Struct GpmSample 

Source
pub struct GpmSample<'nvml> { /* private fields */ }
Expand description

Handle to a GPM (GPU Performance Monitoring) sample.

GPM enables collecting fine-grained GPU performance metrics (SM occupancy, tensor utilization, PCIe/NVLink bandwidth, etc.) on Hopper+ GPUs. Metrics are computed by taking two time-separated samples and comparing them via gpm_metrics_get.

Operations on a sample are not thread-safe. It does not, therefore, implement Sync.

You can obtain a GpmSample via crate::Device::gpm_sample() or crate::Device::gpm_mig_sample().

Lifetimes are used to enforce that each GpmSample instance cannot be used after the Nvml instance it was obtained from is dropped.

Implementations§

Source§

impl<'nvml> GpmSample<'nvml>

Source

pub fn free(self) -> Result<(), NvmlError>

Use this to free the sample if you care about handling potential errors (the Drop implementation ignores errors!).

§Errors
  • Uninitialized, if the library has not been successfully initialized
  • Unknown, on any unexpected error
Source

pub unsafe fn handle(&self) -> nvmlGpmSample_t

Get the raw sample handle.

§Safety

This is unsafe to prevent it from being used without care. In particular, you must avoid creating a new GpmSample from this handle and allowing both this GpmSample and the newly created one to drop (which would result in a double-free).

Source

pub fn nvml(&self) -> &'nvml Nvml

Get a reference to the Nvml instance this sample was created from.

Trait Implementations§

Source§

impl<'nvml> Debug for GpmSample<'nvml>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'nvml> Drop for GpmSample<'nvml>

This Drop implementation ignores errors! Use the .free() method on the GpmSample struct if you care about handling them.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'nvml> Send for GpmSample<'nvml>

Auto Trait Implementations§

§

impl<'nvml> Freeze for GpmSample<'nvml>

§

impl<'nvml> !RefUnwindSafe for GpmSample<'nvml>

§

impl<'nvml> !Sync for GpmSample<'nvml>

§

impl<'nvml> Unpin for GpmSample<'nvml>

§

impl<'nvml> !UnwindSafe for GpmSample<'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>,

Source§

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>,

Source§

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.