diff --git a/projects/amdsmi/CHANGELOG.md b/projects/amdsmi/CHANGELOG.md index 808b81a3cd..8036e3ea2c 100644 --- a/projects/amdsmi/CHANGELOG.md +++ b/projects/amdsmi/CHANGELOG.md @@ -139,6 +139,21 @@ GPU: 0 ### Changed +- **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 + +- **Depricated enum `AMDSMI_NORMAL_STRING_LENGTH` in favor of `AMDSMI_MAX_STRING_LENGTH`**. + +- **Changed amdsmi_vram_vendor_type_t enum names impacting amdsmi_vram_info_t structure**. +This also change impacts usage of the vram_vendor output of `amdsmi_get_gpu_vram_info()` + +- **Changed `amdsmi_nps_caps_t` struct impacting `amdsmi_memory_partition_config_t`, `amdsmi_accelerator_partition_t`, `amdsmi_accelerator_partition_profile_config_t`**. + - Functions affected by struct change are: + - `amdsmi_get_gpu_memory_partition_config()` + - `amdsmi_get_gpu_accelerator_partition_profile()` + - `amdsmi_get_gpu_accelerator_partition_profile_config()` + - **Corrected CLI CPU argument name**. - `--cpu-pwr-svi-telemtry-rails` to `--cpu-pwr-svi-telemetry-rails` @@ -2282,3 +2297,4 @@ Now the information is displayed as a table by each GPU's BDF, which closer rese - **Fix for driver not initialized**. If driver module is not loaded, user retrieve error reponse indicating amdgpu module is not loaded. + diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index 622d1a5254..723bbd7659 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -811,7 +811,7 @@ class AMDSMICommands(): vram_vendor = "N/A" else: # Remove amdsmi enum prefix - vram_vendor = vram_vendor.replace('AMDSMI_VRAM_VENDOR__', '') + vram_vendor = vram_vendor.replace('AMDSMI_VRAM_VENDOR_', '') # Assign cleaned values to vram_info_dict vram_info_dict['type'] = vram_type diff --git a/projects/amdsmi/docs/reference/amdsmi-py-api.md b/projects/amdsmi/docs/reference/amdsmi-py-api.md index 9b8e6e555d..845dbe119a 100644 --- a/projects/amdsmi/docs/reference/amdsmi-py-api.md +++ b/projects/amdsmi/docs/reference/amdsmi-py-api.md @@ -656,6 +656,7 @@ It is not supported on virtual machine guest Input parameters: * `processor_handle` device which to query +* `sensor_ind` optional argument that defaults to 0 Output: Dictionary with fields @@ -684,6 +685,8 @@ try: else: for device in devices: power_measure = amdsmi_get_power_info(device) + # Example with using sensor_ind + # power_measure = amdsmi_get_power_info(device, 0) print(power_measure['current_socket_power']) print(power_measure['average_socket_power']) print(power_measure['gfx_voltage']) diff --git a/projects/amdsmi/example/amd_smi_drm_example.cc b/projects/amdsmi/example/amd_smi_drm_example.cc index e07671582c..d58df30180 100644 --- a/projects/amdsmi/example/amd_smi_drm_example.cc +++ b/projects/amdsmi/example/amd_smi_drm_example.cc @@ -330,7 +330,7 @@ int main() { // Get power measure amdsmi_power_info_t power_measure = {}; - ret = amdsmi_get_power_info(processor_handles[j], &power_measure); + ret = amdsmi_get_power_info(processor_handles[j], 0, &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 faddd048b6..003838d425 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], &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], 0, &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 ed80f4a40c..4120ed0296 100644 --- a/projects/amdsmi/include/amd_smi/amdsmi.h +++ b/projects/amdsmi/include/amd_smi/amdsmi.h @@ -577,22 +577,17 @@ typedef enum { * @cond @tag{gpu_bm_linux} @tag{host} @endcond */ typedef enum { - AMDSMI_VRAM_VENDOR__PLACEHOLDER0, - AMDSMI_VRAM_VENDOR__SAMSUNG, - AMDSMI_VRAM_VENDOR__INFINEON, - AMDSMI_VRAM_VENDOR__ELPIDA, - AMDSMI_VRAM_VENDOR__ETRON, - AMDSMI_VRAM_VENDOR__NANYA, - AMDSMI_VRAM_VENDOR__HYNIX, - AMDSMI_VRAM_VENDOR__MOSEL, - AMDSMI_VRAM_VENDOR__WINBOND, - AMDSMI_VRAM_VENDOR__ESMT, - AMDSMI_VRAM_VENDOR__PLACEHOLDER1, - AMDSMI_VRAM_VENDOR__PLACEHOLDER2, - AMDSMI_VRAM_VENDOR__PLACEHOLDER3, - AMDSMI_VRAM_VENDOR__PLACEHOLDER4, - AMDSMI_VRAM_VENDOR__PLACEHOLDER5, - AMDSMI_VRAM_VENDOR__MICRON, + AMDSMI_VRAM_VENDOR_SAMSUNG, + AMDSMI_VRAM_VENDOR_INFINEON, + AMDSMI_VRAM_VENDOR_ELPIDA, + AMDSMI_VRAM_VENDOR_ETRON, + AMDSMI_VRAM_VENDOR_NANYA, + AMDSMI_VRAM_VENDOR_HYNIX, + AMDSMI_VRAM_VENDOR_MOSEL, + AMDSMI_VRAM_VENDOR_WINBOND, + AMDSMI_VRAM_VENDOR_ESMT, + AMDSMI_VRAM_VENDOR_MICRON, + AMDSMI_VRAM_VENDOR_UNKNOWN } amdsmi_vram_vendor_type_t; /** @@ -832,20 +827,19 @@ typedef struct { } amdsmi_kfd_info_t; /** - * @brief Possible Memory Partition Capabilities. - * This union holds memory partition bitmask. + * @brief This union holds memory partition bitmask. * * @cond @tag{gpu_bm_linux} @tag{host} @endcond */ typedef union { - struct nps_flags_ { - uint32_t nps1_cap :1; //!< bool 1 = true; 0 = false - uint32_t nps2_cap :1; //!< bool 1 = true; 0 = false - uint32_t nps4_cap :1; //!< bool 1 = true; 0 = false - uint32_t nps8_cap :1; //!< bool 1 = true; 0 = false - uint32_t reserved :28; - } amdsmi_nps_flags_t; - uint32_t nps_cap_mask; + struct nps_flags_ { + uint32_t nps1_cap :1; //!< bool 1 = true; 0 = false + uint32_t nps2_cap :1; //!< bool 1 = true; 0 = false + uint32_t nps4_cap :1; //!< bool 1 = true; 0 = false + uint32_t nps8_cap :1; //!< bool 1 = true; 0 = false + uint32_t reserved :28; + } nps_flags; + uint32_t nps_cap_mask; } amdsmi_nps_caps_t; /** @@ -5886,9 +5880,7 @@ amdsmi_status_t amdsmi_get_gpu_activity(amdsmi_processor_handle processor_handle, amdsmi_engine_usage_t *info); /** - * @brief Returns the current power and voltage of the GPU. - * The voltage is in units of mV and the power in units of W. - * It is not supported on virtual machine guest + * @brief Returns the current power and voltage of the GPU. * * @ingroup tagGPUMonitor * @@ -5896,13 +5888,17 @@ amdsmi_get_gpu_activity(amdsmi_processor_handle processor_handle, amdsmi_engine_ * * @note amdsmi_power_info_t::socket_power metric can rarely spike above the socket power limit in some cases * - * @param[in] processor_handle Device which to query + * @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. + * @param[in] sensor_ind a 0-based sensor index. Normally, this will be 0. + * If a processor has more than one sensor, it could be greater than 0. + * Parameter @p sensor_ind is unused on @platform{host}. + * + * @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); +amdsmi_status_t amdsmi_get_power_info(amdsmi_processor_handle processor_handle, uint32_t sensor_ind, amdsmi_power_info_t *info); /** * @brief Returns is power management enabled diff --git a/projects/amdsmi/py-interface/README.md b/projects/amdsmi/py-interface/README.md index c3c6b5ca83..a653c94781 100644 --- a/projects/amdsmi/py-interface/README.md +++ b/projects/amdsmi/py-interface/README.md @@ -11,13 +11,13 @@ with AMD hardware through a user-friendly API. Find the documentation in the ## Online documentation Explore the latest documentation on the [ROCm documentation -portal](https://rocm.docs.amd.com/projects/en/latest/index.html). +portal](https://rocm.docs.amd.com/projects/amdsmi/en/latest/index.html). - [Install AMD - SMI](https://rocm.docs.amd.com/projects/en/latest/install/install.html) + SMI](https://rocm.docs.amd.com/projects/amdsmi/en/latest/install/install.html) - [Python library - usage](https://rocm.docs.amd.com/projects/en/latest/how-to/amdsmi-py-lib.html). + usage](https://rocm.docs.amd.com/projects/amdsmi/en/latest/how-to/amdsmi-py-lib.html). - [Python API - reference](https://rocm.docs.amd.com/projects/en/latest/reference/amdsmi-py-api.html). + reference](https://rocm.docs.amd.com/projects/amdsmi/en/latest/reference/amdsmi-py-api.html). diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index 26af01b47e..3423a8268f 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -62,7 +62,6 @@ AMDSMI_NUM_VOLTAGE_CURVE_POINTS = 3 AMDSMI_MAX_MM_IP_COUNT = 8 AMDSMI_MAX_DATE_LENGTH = 32 AMDSMI_MAX_STRING_LENGTH = 64 -AMDSMI_NORMAL_STRING_LENGTH = 32 AMDSMI_MAX_DEVICES = 32 AMDSMI_MAX_NAME = 32 AMDSMI_MAX_DRIVER_VERSION_LENGTH = 80 @@ -2307,6 +2306,7 @@ def amdsmi_get_gpu_driver_info( def amdsmi_get_power_info( processor_handle: amdsmi_wrapper.amdsmi_processor_handle, + sensor_ind: int = 0 ) -> Dict[str, ctypes.c_uint32]: if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle): raise AmdSmiParameterException( @@ -2316,7 +2316,7 @@ def amdsmi_get_power_info( power_measure = amdsmi_wrapper.amdsmi_power_info_t() _check_res( amdsmi_wrapper.amdsmi_get_power_info( - processor_handle, ctypes.byref(power_measure) + 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 8651d81291..f6f12dfaf5 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py @@ -675,39 +675,29 @@ amdsmi_vram_type_t = ctypes.c_uint32 # enum # values for enumeration 'amdsmi_vram_vendor_type_t' amdsmi_vram_vendor_type_t__enumvalues = { - 0: 'AMDSMI_VRAM_VENDOR__PLACEHOLDER0', - 1: 'AMDSMI_VRAM_VENDOR__SAMSUNG', - 2: 'AMDSMI_VRAM_VENDOR__INFINEON', - 3: 'AMDSMI_VRAM_VENDOR__ELPIDA', - 4: 'AMDSMI_VRAM_VENDOR__ETRON', - 5: 'AMDSMI_VRAM_VENDOR__NANYA', - 6: 'AMDSMI_VRAM_VENDOR__HYNIX', - 7: 'AMDSMI_VRAM_VENDOR__MOSEL', - 8: 'AMDSMI_VRAM_VENDOR__WINBOND', - 9: 'AMDSMI_VRAM_VENDOR__ESMT', - 10: 'AMDSMI_VRAM_VENDOR__PLACEHOLDER1', - 11: 'AMDSMI_VRAM_VENDOR__PLACEHOLDER2', - 12: 'AMDSMI_VRAM_VENDOR__PLACEHOLDER3', - 13: 'AMDSMI_VRAM_VENDOR__PLACEHOLDER4', - 14: 'AMDSMI_VRAM_VENDOR__PLACEHOLDER5', - 15: 'AMDSMI_VRAM_VENDOR__MICRON', + 0: 'AMDSMI_VRAM_VENDOR_SAMSUNG', + 1: 'AMDSMI_VRAM_VENDOR_INFINEON', + 2: 'AMDSMI_VRAM_VENDOR_ELPIDA', + 3: 'AMDSMI_VRAM_VENDOR_ETRON', + 4: 'AMDSMI_VRAM_VENDOR_NANYA', + 5: 'AMDSMI_VRAM_VENDOR_HYNIX', + 6: 'AMDSMI_VRAM_VENDOR_MOSEL', + 7: 'AMDSMI_VRAM_VENDOR_WINBOND', + 8: 'AMDSMI_VRAM_VENDOR_ESMT', + 9: 'AMDSMI_VRAM_VENDOR_MICRON', + 10: 'AMDSMI_VRAM_VENDOR_UNKNOWN', } -AMDSMI_VRAM_VENDOR__PLACEHOLDER0 = 0 -AMDSMI_VRAM_VENDOR__SAMSUNG = 1 -AMDSMI_VRAM_VENDOR__INFINEON = 2 -AMDSMI_VRAM_VENDOR__ELPIDA = 3 -AMDSMI_VRAM_VENDOR__ETRON = 4 -AMDSMI_VRAM_VENDOR__NANYA = 5 -AMDSMI_VRAM_VENDOR__HYNIX = 6 -AMDSMI_VRAM_VENDOR__MOSEL = 7 -AMDSMI_VRAM_VENDOR__WINBOND = 8 -AMDSMI_VRAM_VENDOR__ESMT = 9 -AMDSMI_VRAM_VENDOR__PLACEHOLDER1 = 10 -AMDSMI_VRAM_VENDOR__PLACEHOLDER2 = 11 -AMDSMI_VRAM_VENDOR__PLACEHOLDER3 = 12 -AMDSMI_VRAM_VENDOR__PLACEHOLDER4 = 13 -AMDSMI_VRAM_VENDOR__PLACEHOLDER5 = 14 -AMDSMI_VRAM_VENDOR__MICRON = 15 +AMDSMI_VRAM_VENDOR_SAMSUNG = 0 +AMDSMI_VRAM_VENDOR_INFINEON = 1 +AMDSMI_VRAM_VENDOR_ELPIDA = 2 +AMDSMI_VRAM_VENDOR_ETRON = 3 +AMDSMI_VRAM_VENDOR_NANYA = 4 +AMDSMI_VRAM_VENDOR_HYNIX = 5 +AMDSMI_VRAM_VENDOR_MOSEL = 6 +AMDSMI_VRAM_VENDOR_WINBOND = 7 +AMDSMI_VRAM_VENDOR_ESMT = 8 +AMDSMI_VRAM_VENDOR_MICRON = 9 +AMDSMI_VRAM_VENDOR_UNKNOWN = 10 amdsmi_vram_vendor_type_t = ctypes.c_uint32 # enum class struct_amdsmi_range_t(Structure): pass @@ -825,19 +815,6 @@ amdsmi_card_form_factor_t = ctypes.c_uint32 # enum class struct_amdsmi_pcie_info_t(Structure): pass -class struct_pcie_static_(Structure): - pass - -struct_pcie_static_._pack_ = 1 # source:False -struct_pcie_static_._fields_ = [ - ('max_pcie_width', ctypes.c_uint16), - ('PADDING_0', ctypes.c_ubyte * 2), - ('max_pcie_speed', ctypes.c_uint32), - ('pcie_interface_version', ctypes.c_uint32), - ('slot_type', amdsmi_card_form_factor_t), - ('reserved', ctypes.c_uint64 * 10), -] - class struct_pcie_metric_(Structure): pass @@ -858,6 +835,19 @@ struct_pcie_metric_._fields_ = [ ('reserved', ctypes.c_uint64 * 12), ] +class struct_pcie_static_(Structure): + pass + +struct_pcie_static_._pack_ = 1 # source:False +struct_pcie_static_._fields_ = [ + ('max_pcie_width', ctypes.c_uint16), + ('PADDING_0', ctypes.c_ubyte * 2), + ('max_pcie_speed', ctypes.c_uint32), + ('pcie_interface_version', ctypes.c_uint32), + ('slot_type', amdsmi_card_form_factor_t), + ('reserved', ctypes.c_uint64 * 10), +] + struct_amdsmi_pcie_info_t._pack_ = 1 # source:False struct_amdsmi_pcie_info_t._fields_ = [ ('pcie_static', struct_pcie_static_), @@ -1005,7 +995,7 @@ struct_nps_flags_._fields_ = [ union_amdsmi_nps_caps_t._pack_ = 1 # source:False union_amdsmi_nps_caps_t._fields_ = [ - ('amdsmi_nps_flags_t', struct_nps_flags_), + ('nps_flags', struct_nps_flags_), ('nps_cap_mask', ctypes.c_uint32), ] @@ -2240,6 +2230,9 @@ amdsmi_get_gpu_subsystem_id.argtypes = [amdsmi_processor_handle, ctypes.POINTER( amdsmi_get_gpu_subsystem_name = _libraries['libamd_smi.so'].amdsmi_get_gpu_subsystem_name amdsmi_get_gpu_subsystem_name.restype = amdsmi_status_t amdsmi_get_gpu_subsystem_name.argtypes = [amdsmi_processor_handle, ctypes.POINTER(ctypes.c_char), size_t] +amdsmi_get_gpu_virtualization_mode = _libraries['libamd_smi.so'].amdsmi_get_gpu_virtualization_mode +amdsmi_get_gpu_virtualization_mode.restype = amdsmi_status_t +amdsmi_get_gpu_virtualization_mode.argtypes = [amdsmi_processor_handle, ctypes.POINTER(amdsmi_virtualization_mode_t)] amdsmi_get_gpu_pci_bandwidth = _libraries['libamd_smi.so'].amdsmi_get_gpu_pci_bandwidth amdsmi_get_gpu_pci_bandwidth.restype = amdsmi_status_t amdsmi_get_gpu_pci_bandwidth.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_amdsmi_pcie_bandwidth_t)] @@ -2573,7 +2566,7 @@ 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 = _libraries['libamd_smi.so'].amdsmi_get_power_info amdsmi_get_power_info.restype = amdsmi_status_t -amdsmi_get_power_info.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_amdsmi_power_info_t)] +amdsmi_get_power_info.argtypes = [amdsmi_processor_handle, uint32_t, 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)] @@ -2905,17 +2898,12 @@ __all__ = \ 'AMDSMI_VRAM_TYPE_HBM', 'AMDSMI_VRAM_TYPE_HBM2', 'AMDSMI_VRAM_TYPE_HBM2E', 'AMDSMI_VRAM_TYPE_HBM3', 'AMDSMI_VRAM_TYPE_UNKNOWN', 'AMDSMI_VRAM_TYPE__MAX', - 'AMDSMI_VRAM_VENDOR__ELPIDA', 'AMDSMI_VRAM_VENDOR__ESMT', - 'AMDSMI_VRAM_VENDOR__ETRON', 'AMDSMI_VRAM_VENDOR__HYNIX', - 'AMDSMI_VRAM_VENDOR__INFINEON', 'AMDSMI_VRAM_VENDOR__MICRON', - 'AMDSMI_VRAM_VENDOR__MOSEL', 'AMDSMI_VRAM_VENDOR__NANYA', - 'AMDSMI_VRAM_VENDOR__PLACEHOLDER0', - 'AMDSMI_VRAM_VENDOR__PLACEHOLDER1', - 'AMDSMI_VRAM_VENDOR__PLACEHOLDER2', - 'AMDSMI_VRAM_VENDOR__PLACEHOLDER3', - 'AMDSMI_VRAM_VENDOR__PLACEHOLDER4', - 'AMDSMI_VRAM_VENDOR__PLACEHOLDER5', 'AMDSMI_VRAM_VENDOR__SAMSUNG', - 'AMDSMI_VRAM_VENDOR__WINBOND', 'AMDSMI_XGMI_LINK_DISABLE', + 'AMDSMI_VRAM_VENDOR_ELPIDA', 'AMDSMI_VRAM_VENDOR_ESMT', + 'AMDSMI_VRAM_VENDOR_ETRON', 'AMDSMI_VRAM_VENDOR_HYNIX', + 'AMDSMI_VRAM_VENDOR_INFINEON', 'AMDSMI_VRAM_VENDOR_MICRON', + 'AMDSMI_VRAM_VENDOR_MOSEL', 'AMDSMI_VRAM_VENDOR_NANYA', + 'AMDSMI_VRAM_VENDOR_SAMSUNG', 'AMDSMI_VRAM_VENDOR_UNKNOWN', + 'AMDSMI_VRAM_VENDOR_WINBOND', 'AMDSMI_XGMI_LINK_DISABLE', 'AMDSMI_XGMI_LINK_DOWN', 'AMDSMI_XGMI_LINK_UP', 'AMDSMI_XGMI_STATUS_ERROR', 'AMDSMI_XGMI_STATUS_MULTIPLE_ERRORS', 'AMDSMI_XGMI_STATUS_NO_ERRORS', 'CLK_LIMIT_MAX', 'CLK_LIMIT_MIN', @@ -3009,9 +2997,11 @@ __all__ = \ 'amdsmi_get_gpu_subsystem_id', 'amdsmi_get_gpu_subsystem_name', 'amdsmi_get_gpu_topo_numa_affinity', 'amdsmi_get_gpu_total_ecc_count', 'amdsmi_get_gpu_vbios_info', - 'amdsmi_get_gpu_vendor_name', 'amdsmi_get_gpu_volt_metric', - 'amdsmi_get_gpu_vram_info', 'amdsmi_get_gpu_vram_usage', - 'amdsmi_get_gpu_vram_vendor', 'amdsmi_get_gpu_xgmi_link_status', + 'amdsmi_get_gpu_vendor_name', + 'amdsmi_get_gpu_virtualization_mode', + 'amdsmi_get_gpu_volt_metric', 'amdsmi_get_gpu_vram_info', + 'amdsmi_get_gpu_vram_usage', 'amdsmi_get_gpu_vram_vendor', + 'amdsmi_get_gpu_xgmi_link_status', 'amdsmi_get_hsmp_metrics_table', 'amdsmi_get_hsmp_metrics_table_version', 'amdsmi_get_lib_version', 'amdsmi_get_link_metrics', 'amdsmi_get_link_topology_nearest', diff --git a/projects/amdsmi/rust-interface/src/amdsmi.rs b/projects/amdsmi/rust-interface/src/amdsmi.rs index 7f88844478..ef68a7ff96 100644 --- a/projects/amdsmi/rust-interface/src/amdsmi.rs +++ b/projects/amdsmi/rust-interface/src/amdsmi.rs @@ -5720,9 +5720,10 @@ pub fn amdsmi_get_gpu_activity( /// # /// // Example processor_handle, assuming the number of processors is greater than zero /// let processor_handle = amdsmi_get_processor_handles!()[0]; +/// let sensor_ind = 0 /// /// // Retrieve the power information -/// match amdsmi_get_power_info(processor_handle) { +/// match amdsmi_get_power_info(processor_handle, sensor_ind) { /// Ok(info) => println!("Power information: {:?}", info), /// Err(e) => panic!("Failed to get power information: {}", e), /// } @@ -5741,6 +5742,7 @@ pub fn amdsmi_get_power_info( 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 72077f4834..08d5808b38 100644 --- a/projects/amdsmi/rust-interface/src/amdsmi_wrapper.rs +++ b/projects/amdsmi/rust-interface/src/amdsmi_wrapper.rs @@ -104,7 +104,6 @@ where pub const AMDSMI_MAX_MM_IP_COUNT: u32 = 8; pub const AMDSMI_MAX_DATE_LENGTH: u32 = 32; pub const AMDSMI_MAX_STRING_LENGTH: u32 = 256; -pub const AMDSMI_NORMAL_STRING_LENGTH: u32 = 256; pub const AMDSMI_256_LENGTH: u32 = 256; pub const AMDSMI_MAX_DEVICES: u32 = 32; pub const AMDSMI_MAX_NAME: u32 = 32; @@ -3022,6 +3021,7 @@ extern "C" { extern "C" { pub fn amdsmi_get_power_info( processor_handle: AmdsmiProcessorHandle, + sensor_ind: u32, info: *mut AmdsmiPowerInfoT, ) -> AmdsmiStatusT; } diff --git a/projects/amdsmi/src/amd_smi/amd_smi.cc b/projects/amdsmi/src/amd_smi/amd_smi.cc index 0385c87844..1165b8ddae 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi.cc @@ -572,7 +572,7 @@ amdsmi_status_t amdsmi_get_gpu_board_info(amdsmi_processor_handle processor_hand board_info->product_name, AMDSMI_256_LENGTH); status = rsmi_wrapper(rsmi_dev_serial_number_get, processor_handle, 0, - board_info->product_serial, AMDSMI_NORMAL_STRING_LENGTH); + board_info->product_serial, AMDSMI_MAX_STRING_LENGTH); } std::ostringstream ss; @@ -587,10 +587,10 @@ amdsmi_status_t amdsmi_get_gpu_board_info(amdsmi_processor_handle processor_hand if (board_info->product_serial[0] == '\0') { status = rsmi_wrapper(rsmi_dev_serial_number_get, processor_handle, 0, - board_info->product_serial, AMDSMI_NORMAL_STRING_LENGTH); + board_info->product_serial, AMDSMI_MAX_STRING_LENGTH); if (status != AMDSMI_STATUS_SUCCESS) { memset(board_info->product_serial, 0, - AMDSMI_NORMAL_STRING_LENGTH * sizeof(board_info->product_serial[0])); + AMDSMI_MAX_STRING_LENGTH * sizeof(board_info->product_serial[0])); } ss << __PRETTY_FUNCTION__ << " | [rsmi_correction] board_info->product_serial= |" << board_info->product_serial << "|"; @@ -1401,7 +1401,7 @@ amdsmi_status_t amdsmi_get_gpu_vram_info( // init the info structure with default value info->vram_type = AMDSMI_VRAM_TYPE_UNKNOWN; info->vram_size = 0; - info->vram_vendor = AMDSMI_VRAM_VENDOR__PLACEHOLDER0; + info->vram_vendor = AMDSMI_VRAM_VENDOR_UNKNOWN; info->vram_bit_width = std::numeric_limitsvram_bit_width)>::max(); info->vram_max_bandwidth = std::numeric_limitsvram_max_bandwidth)>::max(); @@ -1434,25 +1434,25 @@ amdsmi_status_t amdsmi_get_gpu_vram_info( brand, 255); if (r == AMDSMI_STATUS_SUCCESS) { if (strcasecmp(brand, "SAMSUNG") == 0) - info->vram_vendor = AMDSMI_VRAM_VENDOR__SAMSUNG; + info->vram_vendor = AMDSMI_VRAM_VENDOR_SAMSUNG; if (strcasecmp(brand, "INFINEON") == 0) - info->vram_vendor = AMDSMI_VRAM_VENDOR__INFINEON; + info->vram_vendor = AMDSMI_VRAM_VENDOR_INFINEON; if (strcasecmp(brand, "ELPIDA") == 0) - info->vram_vendor = AMDSMI_VRAM_VENDOR__ELPIDA; + info->vram_vendor = AMDSMI_VRAM_VENDOR_ELPIDA; if (strcasecmp(brand, "ETRON") == 0) - info->vram_vendor = AMDSMI_VRAM_VENDOR__ETRON; + info->vram_vendor = AMDSMI_VRAM_VENDOR_ETRON; if (strcasecmp(brand, "NANYA") == 0) - info->vram_vendor = AMDSMI_VRAM_VENDOR__NANYA; + info->vram_vendor = AMDSMI_VRAM_VENDOR_NANYA; if (strcasecmp(brand, "HYNIX") == 0) - info->vram_vendor = AMDSMI_VRAM_VENDOR__HYNIX; + info->vram_vendor = AMDSMI_VRAM_VENDOR_HYNIX; if (strcasecmp(brand, "MOSEL") == 0) - info->vram_vendor = AMDSMI_VRAM_VENDOR__MOSEL; + info->vram_vendor = AMDSMI_VRAM_VENDOR_MOSEL; if (strcasecmp(brand, "WINBOND") == 0) - info->vram_vendor = AMDSMI_VRAM_VENDOR__WINBOND; + info->vram_vendor = AMDSMI_VRAM_VENDOR_WINBOND; if (strcasecmp(brand, "ESMT") == 0) - info->vram_vendor = AMDSMI_VRAM_VENDOR__ESMT; + info->vram_vendor = AMDSMI_VRAM_VENDOR_ESMT; if (strcasecmp(brand, "MICRON") == 0) - info->vram_vendor = AMDSMI_VRAM_VENDOR__MICRON; + info->vram_vendor = AMDSMI_VRAM_VENDOR_MICRON; } uint64_t total = 0; r = rsmi_wrapper(rsmi_dev_memory_total_get, processor_handle, 0, @@ -1806,10 +1806,10 @@ amdsmi_get_gpu_memory_partition_config(amdsmi_processor_handle processor_handle, // initialization for devices which do not support partitions amdsmi_nps_caps_t flags; - flags.amdsmi_nps_flags_t.nps1_cap = 0; - flags.amdsmi_nps_flags_t.nps2_cap = 0; - flags.amdsmi_nps_flags_t.nps4_cap = 0; - flags.amdsmi_nps_flags_t.nps8_cap = 0; + flags.nps_flags.nps1_cap = 0; + flags.nps_flags.nps2_cap = 0; + flags.nps_flags.nps4_cap = 0; + flags.nps_flags.nps8_cap = 0; config->partition_caps = flags; config->mp_mode = AMDSMI_MEMORY_PARTITION_UNKNOWN; @@ -1851,16 +1851,16 @@ amdsmi_get_gpu_memory_partition_config(amdsmi_processor_handle processor_handle, if (status == AMDSMI_STATUS_SUCCESS) { memory_caps_str = std::string(memory_caps); if (memory_caps_str.find("NPS1") != std::string::npos) { - flags.amdsmi_nps_flags_t.nps1_cap = 1; + flags.nps_flags.nps1_cap = 1; } if (memory_caps_str.find("NPS2") != std::string::npos) { - flags.amdsmi_nps_flags_t.nps2_cap = 1; + flags.nps_flags.nps2_cap = 1; } if (memory_caps_str.find("NPS4") != std::string::npos) { - flags.amdsmi_nps_flags_t.nps4_cap = 1; + flags.nps_flags.nps4_cap = 1; } if (memory_caps_str.find("NPS8") != std::string::npos) { - flags.amdsmi_nps_flags_t.nps8_cap = 1; + flags.nps_flags.nps8_cap = 1; } } config->partition_caps = flags; @@ -1900,10 +1900,10 @@ amdsmi_get_gpu_accelerator_partition_profile_config(amdsmi_processor_handle proc profile_config->resource_profiles->partition_resource = 0; profile_config->resource_profiles->num_partitions_share_resource = 0; amdsmi_nps_caps_t flags; - flags.amdsmi_nps_flags_t.nps1_cap = 0; - flags.amdsmi_nps_flags_t.nps2_cap = 0; - flags.amdsmi_nps_flags_t.nps4_cap = 0; - flags.amdsmi_nps_flags_t.nps8_cap = 0; + flags.nps_flags.nps1_cap = 0; + flags.nps_flags.nps2_cap = 0; + flags.nps_flags.nps4_cap = 0; + flags.nps_flags.nps8_cap = 0; ss << __PRETTY_FUNCTION__ << " | 1"; @@ -2070,16 +2070,16 @@ amdsmi_get_gpu_accelerator_partition_profile_config(amdsmi_processor_handle proc supported_nps_caps_str = std::string(supported_nps_configs); } if (supported_nps_caps_str.find("NPS1") != std::string::npos) { - profile_config->profiles[i].memory_caps.amdsmi_nps_flags_t.nps1_cap = 1; + profile_config->profiles[i].memory_caps.nps_flags.nps1_cap = 1; } if (supported_nps_caps_str.find("NPS2") != std::string::npos) { - profile_config->profiles[i].memory_caps.amdsmi_nps_flags_t.nps2_cap = 1; + profile_config->profiles[i].memory_caps.nps_flags.nps2_cap = 1; } if (supported_nps_caps_str.find("NPS4") != std::string::npos) { - profile_config->profiles[i].memory_caps.amdsmi_nps_flags_t.nps4_cap = 1; + profile_config->profiles[i].memory_caps.nps_flags.nps4_cap = 1; } if (supported_nps_caps_str.find("NPS8") != std::string::npos) { - profile_config->profiles[i].memory_caps.amdsmi_nps_flags_t.nps8_cap = 1; + profile_config->profiles[i].memory_caps.nps_flags.nps8_cap = 1; } // 2) get resource profiles for (auto r = static_cast(RSMI_ACCELERATOR_XCC); @@ -2123,7 +2123,7 @@ amdsmi_get_gpu_accelerator_partition_profile_config(amdsmi_processor_handle proc } auto current_resource_idx = (resource_index >= 1) ? resource_index - 1 : 0; std::string nps_caps = "N/A"; - if (profile_config->profiles[i].memory_caps.amdsmi_nps_flags_t.nps1_cap == 1) { + if (profile_config->profiles[i].memory_caps.nps_flags.nps1_cap == 1) { if (nps_caps == "N/A") { nps_caps.clear(); nps_caps = "NPS1"; @@ -2131,7 +2131,7 @@ amdsmi_get_gpu_accelerator_partition_profile_config(amdsmi_processor_handle proc nps_caps += ", NPS1"; } } - if (profile_config->profiles[i].memory_caps.amdsmi_nps_flags_t.nps2_cap == 1) { + if (profile_config->profiles[i].memory_caps.nps_flags.nps2_cap == 1) { if (nps_caps == "N/A") { nps_caps.clear(); nps_caps = "NPS2"; @@ -2139,7 +2139,7 @@ amdsmi_get_gpu_accelerator_partition_profile_config(amdsmi_processor_handle proc nps_caps += ", NPS2"; } } - if (profile_config->profiles[i].memory_caps.amdsmi_nps_flags_t.nps4_cap == 1) { + if (profile_config->profiles[i].memory_caps.nps_flags.nps4_cap == 1) { if (nps_caps == "N/A") { nps_caps.clear(); nps_caps = "NPS4"; @@ -2147,7 +2147,7 @@ amdsmi_get_gpu_accelerator_partition_profile_config(amdsmi_processor_handle proc nps_caps += ", NPS4"; } } - if (profile_config->profiles[i].memory_caps.amdsmi_nps_flags_t.nps8_cap == 1) { + if (profile_config->profiles[i].memory_caps.nps_flags.nps8_cap == 1) { if (nps_caps == "N/A") { nps_caps.clear(); nps_caps = "NPS8"; @@ -2209,10 +2209,10 @@ amdsmi_get_gpu_accelerator_partition_profile(amdsmi_processor_handle processor_h profile->num_resources = 0; amdsmi_nps_caps_t flags; - flags.amdsmi_nps_flags_t.nps1_cap = 0; - flags.amdsmi_nps_flags_t.nps2_cap = 0; - flags.amdsmi_nps_flags_t.nps4_cap = 0; - flags.amdsmi_nps_flags_t.nps8_cap = 0; + flags.nps_flags.nps1_cap = 0; + flags.nps_flags.nps2_cap = 0; + flags.nps_flags.nps4_cap = 0; + flags.nps_flags.nps8_cap = 0; profile->memory_caps = flags; // TODO(amdsmi_team): add resources here ^ @@ -2357,16 +2357,16 @@ amdsmi_get_gpu_accelerator_partition_profile(amdsmi_processor_handle processor_h if (status == AMDSMI_STATUS_SUCCESS) { memory_caps_str = std::string(memory_caps); if (memory_caps_str.find("NPS1") != std::string::npos) { - flags.amdsmi_nps_flags_t.nps1_cap = 1; + flags.nps_flags.nps1_cap = 1; } if (memory_caps_str.find("NPS2") != std::string::npos) { - flags.amdsmi_nps_flags_t.nps2_cap = 1; + flags.nps_flags.nps2_cap = 1; } if (memory_caps_str.find("NPS4") != std::string::npos) { - flags.amdsmi_nps_flags_t.nps4_cap = 1; + flags.nps_flags.nps4_cap = 1; } if (memory_caps_str.find("NPS8") != std::string::npos) { - flags.amdsmi_nps_flags_t.nps8_cap = 1; + flags.nps_flags.nps8_cap = 1; } } profile->memory_caps = flags; @@ -2989,20 +2989,20 @@ amdsmi_get_gpu_vbios_info(amdsmi_processor_handle processor_handle, amdsmi_vbios strncpy(info->name, (char *) vbios.name, AMDSMI_MAX_STRING_LENGTH); strncpy(info->build_date, (char *) vbios.date, AMDSMI_MAX_DATE_LENGTH); strncpy(info->part_number, (char *) vbios.vbios_pn, AMDSMI_MAX_STRING_LENGTH); - strncpy(info->version, (char *) vbios.vbios_ver_str, AMDSMI_NORMAL_STRING_LENGTH); + strncpy(info->version, (char *) vbios.vbios_ver_str, AMDSMI_MAX_STRING_LENGTH); } } else { // get vbios version string from rocm_smi - char vbios_version[AMDSMI_NORMAL_STRING_LENGTH]; + char vbios_version[AMDSMI_MAX_STRING_LENGTH]; status = rsmi_wrapper(rsmi_dev_vbios_version_get, processor_handle, 0, vbios_version, - AMDSMI_NORMAL_STRING_LENGTH); + AMDSMI_MAX_STRING_LENGTH); // ignore the errors so that it can populate as many fields as possible. if (status == AMDSMI_STATUS_SUCCESS) { strncpy(info->version, - vbios_version, AMDSMI_NORMAL_STRING_LENGTH); + vbios_version, AMDSMI_MAX_STRING_LENGTH); } } @@ -3319,7 +3319,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, amdsmi_power_info_t *info) { +amdsmi_get_power_info(amdsmi_processor_handle processor_handle, uint32_t sensor_ind, amdsmi_power_info_t *info) { AMDSMI_CHECK_INIT(); if (info == nullptr) { @@ -3447,7 +3447,7 @@ amdsmi_status_t amdsmi_get_pcie_info(amdsmi_processor_handle processor_handle, a SMIGPUDEVICE_MUTEX(gpu_device->get_mutex()) - char buff[AMDSMI_NORMAL_STRING_LENGTH]; + char buff[AMDSMI_MAX_STRING_LENGTH]; FILE* fp; double pcie_speed = 0; unsigned pcie_width = 0; diff --git a/projects/amdsmi/src/amd_smi/fdinfo.cc b/projects/amdsmi/src/amd_smi/fdinfo.cc index 235194e852..116aff2789 100644 --- a/projects/amdsmi/src/amd_smi/fdinfo.cc +++ b/projects/amdsmi/src/amd_smi/fdinfo.cc @@ -235,7 +235,7 @@ amdsmi_status_t gpuvsmi_get_pid_info(const amdsmi_bdf_t &bdf, long int pid, return AMDSMI_STATUS_API_FAILED; strncpy(info.name, name.c_str(), std::min( - (unsigned long) AMDSMI_NORMAL_STRING_LENGTH, + (unsigned long) AMDSMI_MAX_STRING_LENGTH, name.length())); for (int i = 0; i < AMDSMI_MAX_CONTAINER_TYPE; i++) { diff --git a/projects/amdsmi/tests/python_unittest/integration_test.py b/projects/amdsmi/tests/python_unittest/integration_test.py index 8d482e0202..6c4f8c8169 100755 --- a/projects/amdsmi/tests/python_unittest/integration_test.py +++ b/projects/amdsmi/tests/python_unittest/integration_test.py @@ -545,7 +545,7 @@ class TestAmdSmiPythonInterface(unittest.TestCase): bdf = amdsmi.amdsmi_get_gpu_device_bdf(processors[i]) print("\n\n###Test Processor {}, bdf: {}".format(i, bdf)) print("\n###Test amdsmi_get_power_info \n") - power_info = amdsmi.amdsmi_get_power_info(processors[i]) + power_info = amdsmi.amdsmi_get_power_info(processors[i], 0) print(" power_info['current_socket_power'] is: {}".format( power_info['current_socket_power'])) print(" power_info['average_socket_power'] is: {}".format(