diff --git a/projects/amdsmi/CHANGELOG.md b/projects/amdsmi/CHANGELOG.md index 96cbd5a07c..7d637843aa 100644 --- a/projects/amdsmi/CHANGELOG.md +++ b/projects/amdsmi/CHANGELOG.md @@ -18,6 +18,19 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr - Increasing available JPEG engines to 40. Current ASICs may not support all 40. These will be indicated as UINT16_MAX or N/A in CLI. +## amd_smi_lib for ROCm 6.4.1 + +### Removed + +- **Removed `sensor_ind` in `amdsmi_get_power_info()` for backwards compatibility**. + - This change breaks 6.4.0 C API change, but makes it backwards compatible with 6.3 + - Python API still accepts `sensor_ind` as an optional argument + - Changed AMDSMI version from 25.2 to 25.3 + +### Added + +- **Added `amdsmi_get_power_info_v2()` with `sensor_ind`**. + ## amd_smi_lib for ROCm 6.4.0 ### Added @@ -31,7 +44,7 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr uint32_t drm_card; // the graphic card device under /sys/class/drm/card* uint32_t hsa_id; // the HSA enumeration ID uint32_t hip_id; // the HIP enumeration ID - char hip_uuid[AMDSMI_MAX_STRING_LENGTH]; // the HIP unique identifer + char hip_uuid[AMDSMI_MAX_STRING_LENGTH]; // the HIP unique identifier } amdsmi_enumeration_info_t; ``` @@ -198,7 +211,7 @@ Updated `amdsmi_get_gpu_metrics_info()` and structure `amdsmi_gpu_metrics_t` to - **Added an additional argument `sensor_ind` to `amdsmi_get_power_info()`**. - This change breaks previous C API calls and will require a change - - Python API now accepts `sensor_ind` as an optional argument, does not imapact previous usage + - Python API now accepts `sensor_ind` as an optional argument, does not impact previous usage - **Depricated enum `AMDSMI_NORMAL_STRING_LENGTH` in favor of `AMDSMI_MAX_STRING_LENGTH`**. diff --git a/projects/amdsmi/CMakeLists.txt b/projects/amdsmi/CMakeLists.txt index 4439b25dbf..945fcadbf5 100644 --- a/projects/amdsmi/CMakeLists.txt +++ b/projects/amdsmi/CMakeLists.txt @@ -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.2.0" ${PKG_VERSION_GIT_TAG_PREFIX} GIT) +get_package_version_number("25.3.0" ${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}") diff --git a/projects/amdsmi/docs/doxygen/Doxyfile b/projects/amdsmi/docs/doxygen/Doxyfile index 9225f76510..fb75266d2e 100644 --- a/projects/amdsmi/docs/doxygen/Doxyfile +++ b/projects/amdsmi/docs/doxygen/Doxyfile @@ -48,7 +48,7 @@ PROJECT_NAME = AMD SMI # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "25.2.0" +PROJECT_NUMBER = "25.3.0" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/projects/amdsmi/docs/how-to/amdsmi-cli-tool.md b/projects/amdsmi/docs/how-to/amdsmi-cli-tool.md index 6d59803657..abb6a7128a 100644 --- a/projects/amdsmi/docs/how-to/amdsmi-cli-tool.md +++ b/projects/amdsmi/docs/how-to/amdsmi-cli-tool.md @@ -35,7 +35,7 @@ detected: ~$ amd-smi usage: amd-smi [-h] ... -AMD System Management Interface | Version: 25.2.0 | ROCm version: 6.4.0 | Platform: Linux Baremetal +AMD System Management Interface | Version: 25.3.0 | ROCm version: 6.4.0 | Platform: Linux Baremetal options: -h, --help show this help message and exit diff --git a/projects/amdsmi/example/amd_smi_drm_example.cc b/projects/amdsmi/example/amd_smi_drm_example.cc index 847cada398..a4bb945bb3 100644 --- a/projects/amdsmi/example/amd_smi_drm_example.cc +++ b/projects/amdsmi/example/amd_smi_drm_example.cc @@ -566,7 +566,7 @@ int main() { // Get power measure amdsmi_power_info_t power_measure = {}; - ret = amdsmi_get_power_info(processor_handles[j], 0, &power_measure); + ret = amdsmi_get_power_info(processor_handles[j], &power_measure); CHK_AMDSMI_RET(ret) printf(" Output of amdsmi_get_power_info:\n"); printf("\tCurrent GFX Voltage: %d\n", diff --git a/projects/amdsmi/goamdsmi_shim/smiwrapper/amdsmi_go_shim.c b/projects/amdsmi/goamdsmi_shim/smiwrapper/amdsmi_go_shim.c index 003838d425..faddd048b6 100644 --- a/projects/amdsmi/goamdsmi_shim/smiwrapper/amdsmi_go_shim.c +++ b/projects/amdsmi/goamdsmi_shim/smiwrapper/amdsmi_go_shim.c @@ -467,7 +467,7 @@ uint64_t goamdsmi_gpu_dev_power_get(uint32_t dv_ind) uint64_t gpu_power_temp = GOAMDSMI_UINT64_MAX; amdsmi_power_info_t amdsmi_power_info_temp = {0}; - if((dv_ind < num_gpu_devices_inAllSocket) && (AMDSMI_STATUS_SUCCESS == amdsmi_get_power_info(amdsmi_processor_handle_all_gpu_device_across_socket[dv_ind], 0, &amdsmi_power_info_temp))) + if((dv_ind < num_gpu_devices_inAllSocket) && (AMDSMI_STATUS_SUCCESS == amdsmi_get_power_info(amdsmi_processor_handle_all_gpu_device_across_socket[dv_ind], &amdsmi_power_info_temp))) { gpu_power_temp = amdsmi_power_info_temp.average_socket_power; if (enable_debug_level(GOAMDSMI_DEBUG_LEVEL_2)) {printf("AMDSMI, Success for Gpu:%d, GpuPowerAverage:%llu, GpuPowerAverageinWatt:%.6f\n", dv_ind, (unsigned long long)(gpu_power_temp), ((double)(gpu_power_temp))/1000000);} diff --git a/projects/amdsmi/include/amd_smi/amdsmi.h b/projects/amdsmi/include/amd_smi/amdsmi.h index efe1e184a3..08e6203f5d 100644 --- a/projects/amdsmi/include/amd_smi/amdsmi.h +++ b/projects/amdsmi/include/amd_smi/amdsmi.h @@ -202,7 +202,7 @@ typedef enum { #define AMDSMI_LIB_VERSION_MAJOR 25 //! Minor version should be updated for each API change, but without changing headers -#define AMDSMI_LIB_VERSION_MINOR 2 +#define AMDSMI_LIB_VERSION_MINOR 3 //! Release version should be set to 0 as default and can be updated by the PMs for each CSP point release #define AMDSMI_LIB_VERSION_RELEASE 0 @@ -5969,7 +5969,24 @@ amdsmi_get_gpu_activity(amdsmi_processor_handle processor_handle, amdsmi_engine_ * * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail */ -amdsmi_status_t amdsmi_get_power_info(amdsmi_processor_handle processor_handle, uint32_t sensor_ind, amdsmi_power_info_t *info); +amdsmi_status_t amdsmi_get_power_info_v2(amdsmi_processor_handle processor_handle, uint32_t sensor_ind, amdsmi_power_info_t *info); + +/** + * @brief Returns the current power and voltage of the GPU. + * + * @ingroup tagGPUMonitor + * + * @platform{gpu_bm_linux} @platform{host} @platform{guest_windows} + * + * @note amdsmi_power_info_t::socket_power metric can rarely spike above the socket power limit in some cases + * + * @param[in] processor_handle PF of a processor for which to query + * + * @param[out] info Reference to the gpu power structure. Must be allocated by user. + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_power_info(amdsmi_processor_handle processor_handle, amdsmi_power_info_t *info); /** * @brief Returns is power management enabled diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index b12ee72fa5..c3dfaacd0a 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -2378,6 +2378,8 @@ def amdsmi_get_gpu_driver_info( return driver_info +# NOTE: this uses amdsmi_get_power_info_v2 under the hood because the C api +# needs to be backwards compatible def amdsmi_get_power_info( processor_handle: amdsmi_wrapper.amdsmi_processor_handle, sensor_ind: int = 0 @@ -2389,7 +2391,7 @@ def amdsmi_get_power_info( power_measure = amdsmi_wrapper.amdsmi_power_info_t() _check_res( - amdsmi_wrapper.amdsmi_get_power_info( + amdsmi_wrapper.amdsmi_get_power_info_v2( processor_handle, sensor_ind, ctypes.byref(power_measure) ) ) diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py b/projects/amdsmi/py-interface/amdsmi_wrapper.py index be427c1312..576fc5a8ea 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py @@ -2619,9 +2619,12 @@ amdsmi_get_gpu_vbios_info.argtypes = [amdsmi_processor_handle, ctypes.POINTER(st amdsmi_get_gpu_activity = _libraries['libamd_smi.so'].amdsmi_get_gpu_activity amdsmi_get_gpu_activity.restype = amdsmi_status_t amdsmi_get_gpu_activity.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_amdsmi_engine_usage_t)] +amdsmi_get_power_info_v2 = _libraries['libamd_smi.so'].amdsmi_get_power_info_v2 +amdsmi_get_power_info_v2.restype = amdsmi_status_t +amdsmi_get_power_info_v2.argtypes = [amdsmi_processor_handle, uint32_t, ctypes.POINTER(struct_amdsmi_power_info_t)] amdsmi_get_power_info = _libraries['libamd_smi.so'].amdsmi_get_power_info amdsmi_get_power_info.restype = amdsmi_status_t -amdsmi_get_power_info.argtypes = [amdsmi_processor_handle, uint32_t, ctypes.POINTER(struct_amdsmi_power_info_t)] +amdsmi_get_power_info.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_amdsmi_power_info_t)] amdsmi_is_gpu_power_management_enabled = _libraries['libamd_smi.so'].amdsmi_is_gpu_power_management_enabled amdsmi_is_gpu_power_management_enabled.restype = amdsmi_status_t amdsmi_is_gpu_power_management_enabled.argtypes = [amdsmi_processor_handle, ctypes.POINTER(ctypes.c_bool)] @@ -3063,7 +3066,7 @@ __all__ = \ 'amdsmi_get_link_metrics', 'amdsmi_get_link_topology_nearest', 'amdsmi_get_minmax_bandwidth_between_processors', 'amdsmi_get_pcie_info', 'amdsmi_get_power_cap_info', - 'amdsmi_get_power_info', + 'amdsmi_get_power_info', 'amdsmi_get_power_info_v2', 'amdsmi_get_processor_count_from_handles', 'amdsmi_get_processor_handle_from_bdf', 'amdsmi_get_processor_handles', diff --git a/projects/amdsmi/rust-interface/src/amdsmi.rs b/projects/amdsmi/rust-interface/src/amdsmi.rs index 581b66ad46..13df4ded8e 100644 --- a/projects/amdsmi/rust-interface/src/amdsmi.rs +++ b/projects/amdsmi/rust-interface/src/amdsmi.rs @@ -5723,7 +5723,60 @@ pub fn amdsmi_get_gpu_activity( /// let sensor_ind = 0 /// /// // Retrieve the power information -/// match amdsmi_get_power_info(processor_handle, sensor_ind) { +/// match amdsmi_get_power_info_v2(processor_handle, sensor_ind) { +/// Ok(info) => println!("Power information: {:?}", info), +/// Err(e) => panic!("Failed to get power information: {}", 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_power_info_v2` call fails. +pub fn amdsmi_get_power_info_v2( + processor_handle: AmdsmiProcessorHandle, + sensor_ind: u32, +) -> AmdsmiResult { + let mut info = MaybeUninit::::uninit(); + call_unsafe!(amdsmi_wrapper::amdsmi_get_power_info_v2( + processor_handle, + sensor_ind, + info.as_mut_ptr() + )); + let info = unsafe { info.assume_init() }; + Ok(info) +} + +/// Get the power information for the device with the specified processor handle. +/// +/// Given a processor handle `processor_handle`, this function retrieves the power information +/// for the specified processor. +/// +/// # Arguments +/// +/// * `processor_handle` - A handle to the processor for which the power information is being queried. +/// +/// # Returns +/// +/// * `AmdsmiResult` - Returns `Ok(AmdsmiPowerInfoT)` containing the [`AmdsmiPowerInfoT`] 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 power information +/// match amdsmi_get_power_info(processor_handle) { /// Ok(info) => println!("Power information: {:?}", info), /// Err(e) => panic!("Failed to get power information: {}", e), /// } @@ -5738,12 +5791,10 @@ pub fn amdsmi_get_gpu_activity( /// This function will return the error in [`AmdsmiStatusT`] if the underlying `amdsmi_wrapper::amdsmi_get_power_info` call fails. pub fn amdsmi_get_power_info( processor_handle: AmdsmiProcessorHandle, - sensor_ind: u32, ) -> AmdsmiResult { let mut info = MaybeUninit::::uninit(); call_unsafe!(amdsmi_wrapper::amdsmi_get_power_info( processor_handle, - sensor_ind, info.as_mut_ptr() )); let info = unsafe { info.assume_init() }; diff --git a/projects/amdsmi/rust-interface/src/amdsmi_wrapper.rs b/projects/amdsmi/rust-interface/src/amdsmi_wrapper.rs index 58c4817807..e132cf5cf1 100644 --- a/projects/amdsmi/rust-interface/src/amdsmi_wrapper.rs +++ b/projects/amdsmi/rust-interface/src/amdsmi_wrapper.rs @@ -3018,12 +3018,18 @@ extern "C" { ) -> AmdsmiStatusT; } extern "C" { - pub fn amdsmi_get_power_info( + pub fn amdsmi_get_power_info_v2( processor_handle: AmdsmiProcessorHandle, sensor_ind: u32, info: *mut AmdsmiPowerInfoT, ) -> AmdsmiStatusT; } +extern "C" { + pub fn amdsmi_get_power_info( + processor_handle: AmdsmiProcessorHandle, + info: *mut AmdsmiPowerInfoT, + ) -> AmdsmiStatusT; +} extern "C" { pub fn amdsmi_is_gpu_power_management_enabled( processor_handle: AmdsmiProcessorHandle, diff --git a/projects/amdsmi/src/amd_smi/amd_smi.cc b/projects/amdsmi/src/amd_smi/amd_smi.cc index 769484626b..7b0af47977 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi.cc @@ -3588,7 +3588,7 @@ amdsmi_get_gpu_process_list(amdsmi_processor_handle processor_handle, uint32_t * } amdsmi_status_t -amdsmi_get_power_info(amdsmi_processor_handle processor_handle, __attribute__((unused)) uint32_t sensor_ind, amdsmi_power_info_t *info) { +amdsmi_get_power_info_v2(amdsmi_processor_handle processor_handle, __attribute__((unused)) uint32_t sensor_ind, amdsmi_power_info_t *info) { AMDSMI_CHECK_INIT(); @@ -3628,6 +3628,11 @@ amdsmi_get_power_info(amdsmi_processor_handle processor_handle, __attribute__((u return status; } +amdsmi_status_t +amdsmi_get_power_info(amdsmi_processor_handle processor_handle, amdsmi_power_info_t *info) { + return amdsmi_get_power_info_v2(processor_handle, 0, info); +} + amdsmi_status_t amdsmi_get_gpu_driver_info(amdsmi_processor_handle processor_handle, amdsmi_driver_info_t *info) { AMDSMI_CHECK_INIT();