diff --git a/projects/amdsmi/CHANGELOG.md b/projects/amdsmi/CHANGELOG.md index 7757192d54..a3376c6d7d 100644 --- a/projects/amdsmi/CHANGELOG.md +++ b/projects/amdsmi/CHANGELOG.md @@ -13,6 +13,9 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr - **Changed the `power` parameter in `amdsmi_get_energy_count()` to `energy_accumulator`**. Changes propagate forwards into the python interface as well, however we are maintaing backwards compatibility and keeping the `power` field in the python API until ROCm 6.4. +- **Added GPU memory overdrive percentage to `amd-smi metric -o`**. +Added `amdsmi_get_gpu_mem_overdrive_level()` function to amd-smi C and Python Libraries. + ### Removals - N/A diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index 284b093da9..c259d37636 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -1851,18 +1851,19 @@ class AMDSMICommands(): if args.overdrive: try: overdrive_level = amdsmi_interface.amdsmi_get_gpu_overdrive_level(args.gpu) - od_unit = '%' - if self.logger.is_human_readable_format(): - overdrive_level = f"{overdrive_level} {od_unit}" - if self.logger.is_json_format(): - overdrive_level = {"value" : overdrive_level, - "unit" : od_unit} - - values_dict['overdrive'] = overdrive_level + values_dict['overdrive'] = self.helpers.unit_format(self.logger, overdrive_level, od_unit) except amdsmi_exception.AmdSmiLibraryException as e: values_dict['overdrive'] = "N/A" - logging.debug("Failed to get overdrive level for gpu %s | %s", gpu_id, e.get_error_info()) + logging.debug("Failed to get gpu overdrive level for gpu %s | %s", gpu_id, e.get_error_info()) + + try: + mem_overdrive_level = amdsmi_interface.amdsmi_get_gpu_mem_overdrive_level(args.gpu) + od_unit = '%' + values_dict['mem_overdrive'] = self.helpers.unit_format(self.logger, mem_overdrive_level, od_unit) + except amdsmi_exception.AmdSmiLibraryException as e: + values_dict['mem_overdrive'] = "N/A" + logging.debug("Failed to get mem overdrive level for gpu %s | %s", gpu_id, e.get_error_info()) if "perf_level" in current_platform_args: if args.perf_level: try: diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_parser.py b/projects/amdsmi/amdsmi_cli/amdsmi_parser.py index be80ece190..0a85ee7b01 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_parser.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_parser.py @@ -740,7 +740,7 @@ class AMDSMIParser(argparse.ArgumentParser): # Help text for Arguments only on Linux Baremetal platforms fan_help = "Current fan speed" vc_help = "Display voltage curve" - overdrive_help = "Current GPU clock overdrive level" + overdrive_help = "Current GPU clock overdrive and GPU memory clock overdrive level" perf_level_help = "Current DPM performance level" xgmi_err_help = "XGMI error information since last read" energy_help = "Amount of energy consumed" diff --git a/projects/amdsmi/docs/how-to/using-amdsmi-for-python.md b/projects/amdsmi/docs/how-to/using-amdsmi-for-python.md index 6611d7b444..7a454b1025 100644 --- a/projects/amdsmi/docs/how-to/using-amdsmi-for-python.md +++ b/projects/amdsmi/docs/how-to/using-amdsmi-for-python.md @@ -1610,7 +1610,7 @@ except AmdSmiException as e: ### amdsmi_set_gpu_od_clk_info -Description: This function sets the clock frequency information +Description: This function sets the clock frequency information. It is not supported on virtual machine guest Input parameters: @@ -2156,6 +2156,38 @@ except AmdSmiException as e: print(e) ``` +### amdsmi_get_gpu_mem_overdrive_level + +Description: Get the GPU memory clock overdrive percent associated with the device with provided +device handle. It is not supported on virtual machine guest + +Input parameters: + +* `processor_handle` handle for the given device + +Output: Overdrive percentage as integer + +Exceptions that can be thrown by `amdsmi_get_gpu_mem_overdrive_level` function: + +* `AmdSmiLibraryException` +* `AmdSmiRetryException` +* `AmdSmiParameterException` + +Example: + +```python +try: + devices = amdsmi_get_processor_handles() + if len(devices) == 0: + print("No GPUs on machine") + else: + for device in devices: + od_level = amdsmi_get_gpu_mem_overdrive_level(dev) + print(od_level) +except AmdSmiException as e: + print(e) +``` + ### amdsmi_get_clk_freq Description: Get the list of possible system clock speeds of device for a diff --git a/projects/amdsmi/include/amd_smi/amdsmi.h b/projects/amdsmi/include/amd_smi/amdsmi.h index 2268b303b2..9e5b988614 100644 --- a/projects/amdsmi/include/amd_smi/amdsmi.h +++ b/projects/amdsmi/include/amd_smi/amdsmi.h @@ -2957,6 +2957,30 @@ amdsmi_set_gpu_perf_determinism_mode(amdsmi_processor_handle processor_handle, u amdsmi_status_t amdsmi_get_gpu_overdrive_level(amdsmi_processor_handle processor_handle, uint32_t *od); +/** + * @brief Get the GPU memory clock overdrive percent associated with the device with provided + * processor handle. It is not supported on virtual machine guest + * + * @platform{gpu_bm_linux} + * + * @details Given a processor handle @p processor_handle and a pointer to a uint32_t @p od, + * this function will write the overdrive percentage to the uint32_t pointed + * to by @p od + * + * @param[in] processor_handle a processor handle + * + * @param[in,out] od a pointer to uint32_t to which the GPU memory clock overdrive percentage + * will be written + * If this parameter is nullptr, this function will return + * ::AMDSMI_STATUS_INVAL if the function is supported with the provided, + * arguments and ::AMDSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_gpu_mem_overdrive_level(amdsmi_processor_handle processor_handle, + uint32_t *od); + /** * @brief Get the list of possible system clock speeds of device for a * specified clock type. It is not supported on virtual machine guest diff --git a/projects/amdsmi/py-interface/README.md b/projects/amdsmi/py-interface/README.md index 3bbaa7d40d..7a454b1025 100644 --- a/projects/amdsmi/py-interface/README.md +++ b/projects/amdsmi/py-interface/README.md @@ -2156,6 +2156,38 @@ except AmdSmiException as e: print(e) ``` +### amdsmi_get_gpu_mem_overdrive_level + +Description: Get the GPU memory clock overdrive percent associated with the device with provided +device handle. It is not supported on virtual machine guest + +Input parameters: + +* `processor_handle` handle for the given device + +Output: Overdrive percentage as integer + +Exceptions that can be thrown by `amdsmi_get_gpu_mem_overdrive_level` function: + +* `AmdSmiLibraryException` +* `AmdSmiRetryException` +* `AmdSmiParameterException` + +Example: + +```python +try: + devices = amdsmi_get_processor_handles() + if len(devices) == 0: + print("No GPUs on machine") + else: + for device in devices: + od_level = amdsmi_get_gpu_mem_overdrive_level(dev) + print(od_level) +except AmdSmiException as e: + print(e) +``` + ### amdsmi_get_clk_freq Description: Get the list of possible system clock speeds of device for a diff --git a/projects/amdsmi/py-interface/__init__.py b/projects/amdsmi/py-interface/__init__.py index e52de77bb6..5e208aadcc 100644 --- a/projects/amdsmi/py-interface/__init__.py +++ b/projects/amdsmi/py-interface/__init__.py @@ -150,6 +150,7 @@ from .amdsmi_interface import amdsmi_get_gpu_volt_metric from .amdsmi_interface import amdsmi_get_utilization_count from .amdsmi_interface import amdsmi_get_gpu_perf_level from .amdsmi_interface import amdsmi_get_gpu_overdrive_level +from .amdsmi_interface import amdsmi_get_gpu_mem_overdrive_level from .amdsmi_interface import amdsmi_get_clk_freq from .amdsmi_interface import amdsmi_get_gpu_od_volt_info from .amdsmi_interface import amdsmi_get_gpu_metrics_info diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index 548a95eb7d..3a2c1198d7 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -3458,6 +3458,24 @@ def amdsmi_get_gpu_overdrive_level( return od_level.value +def amdsmi_get_gpu_mem_overdrive_level( + processor_handle: amdsmi_wrapper.amdsmi_processor_handle, +) -> int: + if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle): + raise AmdSmiParameterException( + processor_handle, amdsmi_wrapper.amdsmi_processor_handle + ) + + mem_od_level = ctypes.c_uint32() + _check_res( + amdsmi_wrapper.amdsmi_get_gpu_mem_overdrive_level( + processor_handle, ctypes.byref(mem_od_level) + ) + ) + + return mem_od_level.value + + def amdsmi_get_clk_freq( processor_handle: amdsmi_wrapper.amdsmi_processor_handle, clk_type: AmdSmiClkType ) -> Dict[str, Any]: diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py b/projects/amdsmi/py-interface/amdsmi_wrapper.py index 57fc962a0a..805d8d88d8 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py @@ -2060,6 +2060,9 @@ amdsmi_set_gpu_perf_determinism_mode.argtypes = [amdsmi_processor_handle, uint64 amdsmi_get_gpu_overdrive_level = _libraries['libamd_smi.so'].amdsmi_get_gpu_overdrive_level amdsmi_get_gpu_overdrive_level.restype = amdsmi_status_t amdsmi_get_gpu_overdrive_level.argtypes = [amdsmi_processor_handle, ctypes.POINTER(ctypes.c_uint32)] +amdsmi_get_gpu_mem_overdrive_level = _libraries['libamd_smi.so'].amdsmi_get_gpu_mem_overdrive_level +amdsmi_get_gpu_mem_overdrive_level.restype = amdsmi_status_t +amdsmi_get_gpu_mem_overdrive_level.argtypes = [amdsmi_processor_handle, ctypes.POINTER(ctypes.c_uint32)] amdsmi_get_clk_freq = _libraries['libamd_smi.so'].amdsmi_get_clk_freq amdsmi_get_clk_freq.restype = amdsmi_status_t amdsmi_get_clk_freq.argtypes = [amdsmi_processor_handle, amdsmi_clk_type_t, ctypes.POINTER(struct_amdsmi_frequencies_t)] @@ -2671,7 +2674,8 @@ __all__ = \ 'amdsmi_get_gpu_ecc_enabled', 'amdsmi_get_gpu_ecc_status', 'amdsmi_get_gpu_event_notification', 'amdsmi_get_gpu_fan_rpms', 'amdsmi_get_gpu_fan_speed', 'amdsmi_get_gpu_fan_speed_max', - 'amdsmi_get_gpu_id', 'amdsmi_get_gpu_memory_partition', + 'amdsmi_get_gpu_id', 'amdsmi_get_gpu_mem_overdrive_level', + 'amdsmi_get_gpu_memory_partition', 'amdsmi_get_gpu_memory_reserved_pages', 'amdsmi_get_gpu_memory_total', 'amdsmi_get_gpu_memory_usage', 'amdsmi_get_gpu_metrics_header_info', diff --git a/projects/amdsmi/src/amd_smi/amd_smi.cc b/projects/amdsmi/src/amd_smi/amd_smi.cc index d2c84fd19b..c2650c8dcf 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi.cc @@ -1506,6 +1506,12 @@ amdsmi_status_t amdsmi_get_gpu_overdrive_level( return rsmi_wrapper(rsmi_dev_overdrive_level_get, processor_handle, od); } +amdsmi_status_t amdsmi_get_gpu_mem_overdrive_level( + amdsmi_processor_handle processor_handle, + uint32_t *od) { + return rsmi_wrapper(rsmi_dev_mem_overdrive_level_get, processor_handle, od); +} + amdsmi_status_t amdsmi_set_gpu_overdrive_level( amdsmi_processor_handle processor_handle, uint32_t od) { return rsmi_wrapper(rsmi_dev_overdrive_level_set_v1, processor_handle, od);