Struct libdrm_amdgpu_sys::AMDGPU::ThrottleStatus

source ·
pub struct ThrottleStatus(/* private fields */);

Implementations§

source§

impl ThrottleStatus

source

pub fn new(val: u64) -> Self

source

pub fn check_throttler(&self, thr: ThrottlerBit) -> bool

source

pub fn get_all_throttler(&self) -> Vec<ThrottlerBit>

Examples found in repository?
examples/gpu_metrics.rs (line 24)
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
fn main() {
    let device_path = std::env::var("AMDGPU_PATH").unwrap_or("/dev/dri/renderD128".to_string());
    let (amdgpu_dev, _, _) = {
        use std::os::fd::IntoRawFd;

        let f = File::open(device_path).unwrap();

        AMDGPU::DeviceHandle::init(f.into_raw_fd()).unwrap()
    };

    let path = amdgpu_dev.get_sysfs_path().unwrap();

    if let Ok(metrics) = amdgpu_dev.get_gpu_metrics_from_sysfs_path(&path) {
        println!("{:#?}", metrics);

        if let Some(socket_power) = metrics.get_average_socket_power() {
            println!("Average Socket Power: {socket_power} W");
        }

        if let Some(thr) = metrics.get_throttle_status_info() {
            println!("Throttle Status: {:?}", thr.get_all_throttler());
        }
    } else {
        let ext_info = amdgpu_dev.device_info().unwrap();
        let asic_name = ext_info.get_asic_name();

        println!("{asic_name} dose not support GPU metrics.");
        println!("Vega12 (dGPU) or later, Renoir (APU) or later supports GPU metrics.")
    }
}
source

pub fn get_all_throttler_type(&self) -> Vec<ThrottlerType>

source

pub fn get_all_throttler_type_from_slice( thrs: &[ThrottlerBit] ) -> Vec<ThrottlerType>

Trait Implementations§

source§

impl Clone for ThrottleStatus

source§

fn clone(&self) -> ThrottleStatus

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ThrottleStatus

source§

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

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

impl Copy for ThrottleStatus

Auto Trait Implementations§

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.