Add amdsmi_get_gpu_busy_percent
This is required for GPU busy percent in RDC Change-Id: Idf2ab72993ecc8227958e6eb47f36fc68c93759f Signed-off-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>
Этот коммит содержится в:
коммит произвёл
Arif, Maisam
родитель
7592ffa8f5
Коммит
955ceac78a
@@ -28,7 +28,7 @@ find_program(GIT NAMES git)
|
||||
|
||||
## Setup the package version based on git tags.
|
||||
set(PKG_VERSION_GIT_TAG_PREFIX "amdsmi_pkg_ver")
|
||||
get_package_version_number("25.4.0" ${PKG_VERSION_GIT_TAG_PREFIX} GIT)
|
||||
get_package_version_number("25.4.2" ${PKG_VERSION_GIT_TAG_PREFIX} GIT)
|
||||
message("Package version: ${PKG_VERSION_STR}")
|
||||
set(${AMD_SMI_LIBS_TARGET}_VERSION_MAJOR "${CPACK_PACKAGE_VERSION_MAJOR}")
|
||||
set(${AMD_SMI_LIBS_TARGET}_VERSION_MINOR "${CPACK_PACKAGE_VERSION_MINOR}")
|
||||
|
||||
@@ -3737,6 +3737,25 @@ amdsmi_status_t amdsmi_set_gpu_fan_speed(amdsmi_processor_handle processor_handl
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Get GPU busy percent from gpu_busy_percent sysfs file
|
||||
*
|
||||
* @ingroup tagClkPowerPerfQuery
|
||||
*
|
||||
* @platform{gpu_bm_linux}
|
||||
*
|
||||
* @details Given a processor handle @p processor_handle, this function returns GPU busy
|
||||
* percentage.
|
||||
*
|
||||
* @param[in] processor_handle a processor handle
|
||||
*
|
||||
* @param[in,out] gpu_busy_percent Direct output from the gpu_busy_percent sysfs file
|
||||
*
|
||||
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail
|
||||
*/
|
||||
amdsmi_status_t amdsmi_get_gpu_busy_percent(amdsmi_processor_handle processor_handle,
|
||||
uint32_t *gpu_busy_percent);
|
||||
|
||||
/**
|
||||
* @brief Get coarse grain utilization counter of the specified device
|
||||
*
|
||||
|
||||
@@ -2467,6 +2467,9 @@ amdsmi_reset_gpu_fan.argtypes = [amdsmi_processor_handle, uint32_t]
|
||||
amdsmi_set_gpu_fan_speed = _libraries['libamd_smi.so'].amdsmi_set_gpu_fan_speed
|
||||
amdsmi_set_gpu_fan_speed.restype = amdsmi_status_t
|
||||
amdsmi_set_gpu_fan_speed.argtypes = [amdsmi_processor_handle, uint32_t, uint64_t]
|
||||
amdsmi_get_gpu_busy_percent = _libraries['libamd_smi.so'].amdsmi_get_gpu_busy_percent
|
||||
amdsmi_get_gpu_busy_percent.restype = amdsmi_status_t
|
||||
amdsmi_get_gpu_busy_percent.argtypes = [amdsmi_processor_handle, ctypes.POINTER(ctypes.c_uint32)]
|
||||
amdsmi_get_utilization_count = _libraries['libamd_smi.so'].amdsmi_get_utilization_count
|
||||
amdsmi_get_utilization_count.restype = amdsmi_status_t
|
||||
amdsmi_get_utilization_count.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_amdsmi_utilization_counter_t), uint32_t, ctypes.POINTER(ctypes.c_uint64)]
|
||||
@@ -3212,8 +3215,8 @@ __all__ = \
|
||||
'amdsmi_get_gpu_available_counters',
|
||||
'amdsmi_get_gpu_bad_page_info',
|
||||
'amdsmi_get_gpu_bad_page_threshold', 'amdsmi_get_gpu_bdf_id',
|
||||
'amdsmi_get_gpu_board_info', 'amdsmi_get_gpu_cache_info',
|
||||
'amdsmi_get_gpu_compute_partition',
|
||||
'amdsmi_get_gpu_board_info', 'amdsmi_get_gpu_busy_percent',
|
||||
'amdsmi_get_gpu_cache_info', 'amdsmi_get_gpu_compute_partition',
|
||||
'amdsmi_get_gpu_compute_process_gpus',
|
||||
'amdsmi_get_gpu_compute_process_info',
|
||||
'amdsmi_get_gpu_compute_process_info_by_pid',
|
||||
|
||||
@@ -1940,6 +1940,57 @@ pub fn amdsmi_set_gpu_fan_speed(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get the GPU busy percent of the device with the specified processor handle.
|
||||
///
|
||||
/// Given a processor handle `processor_handle`, this function returns the GPU busy percent
|
||||
/// for the specified processor.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `processor_handle` - A handle to the processor which is being queried.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `AmdsmiResult<u32>` - Returns `Ok(u32)` containing the GPU busy percent if successful, or an error if it fails.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// # use amdsmi::*;
|
||||
/// #
|
||||
/// # fn main() {
|
||||
/// # // Initialize the AMD SMI library
|
||||
/// # amdsmi_init(AmdsmiInitFlagsT::AmdsmiInitAmdGpus).expect("Failed to initialize AMD SMI");
|
||||
/// #
|
||||
/// // Example processor_handle, assuming the number of processors is greater than zero
|
||||
/// let processor_handle = amdsmi_get_processor_handles!()[0];
|
||||
///
|
||||
/// // Retrieve the GPU busy percent
|
||||
/// match amdsmi_get_gpu_busy_percent(processor_handle) {
|
||||
/// Ok(gpu_busy_percent) => println!("GPU Busy Percent: {}", gpu_busy_percent),
|
||||
/// Err(AmdsmiStatusT::AmdsmiStatusNotSupported) => println!("amdsmi_get_gpu_busy_percent() not supported on this device"),
|
||||
/// Err(e) => panic!("Failed to get GPU busy_percent level: {}", e),
|
||||
/// }
|
||||
/// #
|
||||
/// # // Shut down the AMD SMI library
|
||||
/// # amdsmi_shut_down().expect("Failed to shut down AMD SMI");
|
||||
/// # }
|
||||
/// ```
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// This function will return the error in [`AmdsmiStatusT`] if the underlying `amdsmi_wrapper::amdsmi_get_gpu_busy_percent` call fails.
|
||||
pub fn amdsmi_get_gpu_busy_percent(
|
||||
processor_handle: AmdsmiProcessorHandle
|
||||
) -> AmdsmiResult<(u32)> {
|
||||
let mut gpu_busy_percent = 0;
|
||||
call_unsafe!(amdsmi_wrapper::amdsmi_get_gpu_busy_percent(
|
||||
processor_handle,
|
||||
&mut gpu_busy_percent
|
||||
));
|
||||
Ok(gpu_busy_percent)
|
||||
}
|
||||
|
||||
///
|
||||
/// Retrieves the utilization count for the specified processor handle and counter types.
|
||||
///
|
||||
|
||||
@@ -2556,6 +2556,12 @@ extern "C" {
|
||||
speed: u64,
|
||||
) -> AmdsmiStatusT;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn amdsmi_get_gpu_busy_percent(
|
||||
processor_handle: AmdsmiProcessorHandle,
|
||||
gpu_busy_percent: *mut u32,
|
||||
) -> AmdsmiStatusT;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn amdsmi_get_utilization_count(
|
||||
processor_handle: AmdsmiProcessorHandle,
|
||||
|
||||
@@ -3213,6 +3213,11 @@ amdsmi_status_t amdsmi_reset_gpu(amdsmi_processor_handle processor_handle) {
|
||||
return rsmi_wrapper(rsmi_dev_gpu_reset, processor_handle, 0);
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_get_gpu_busy_percent(amdsmi_processor_handle processor_handle,
|
||||
uint32_t *gpu_busy_percent) {
|
||||
return rsmi_wrapper(rsmi_dev_busy_percent_get, processor_handle, 0, gpu_busy_percent);
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_get_utilization_count(amdsmi_processor_handle processor_handle,
|
||||
amdsmi_utilization_counter_t utilization_counters[],
|
||||
uint32_t count,
|
||||
|
||||
Ссылка в новой задаче
Block a user