From 9b4f0f1d2bd6fcfff0f408b8aad80fa71bfc27eb Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Thu, 11 Apr 2024 05:11:54 -0500 Subject: [PATCH 1/5] SWDEV-455131 - Updated process APIs - Removed amdsmi_get_gpu_process_info from python API - Updated documentation - Aligned process --json output format to unit & value format Signed-off-by: Maisam Arif Change-Id: I82bba1b6df71020b4a5995ff63b9aa62611ce4fe [ROCm/amdsmi commit: c551c3caedbd903ba828e7fdffa5b56d475a15e7] --- projects/amdsmi/CHANGELOG.md | 3 + projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 34 +++++++---- projects/amdsmi/py-interface/README.md | 57 ++++--------------- projects/amdsmi/py-interface/__init__.py | 1 - .../amdsmi/py-interface/amdsmi_interface.py | 47 ++++++--------- 5 files changed, 53 insertions(+), 89 deletions(-) diff --git a/projects/amdsmi/CHANGELOG.md b/projects/amdsmi/CHANGELOG.md index bea6fc8981..03ee2bbe02 100644 --- a/projects/amdsmi/CHANGELOG.md +++ b/projects/amdsmi/CHANGELOG.md @@ -12,6 +12,9 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/]( ### Changed +- **Removed `amdsmi_get_gpu_process_info` from python library** +amdsmi_get_gpu_process_info was removed from the C library in an earlier build, but the API was still in the python interface + - **Updated metrics --clocks** Output for `amd-smi metric --clock` is updated to reflect each engine and bug fixes for the clock lock status and deep sleep status. diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index ee6159e5ed..31c32f0aa4 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -2576,28 +2576,38 @@ class AMDSMICommands(): raise e filtered_process_values = [] - for process in process_list: - try: - process_info = amdsmi_interface.amdsmi_get_gpu_process_info(args.gpu, process) - except amdsmi_exception.AmdSmiLibraryException as e: - process_info = "N/A" - logging.debug("Failed to get process info for process %s on gpu %s | %s", process, gpu_id, e.get_error_info()) - filtered_process_values.append({'process_info': process_info}) - continue - + for process_info in process_list: process_info['mem_usage'] = process_info.pop('mem') process_info['usage'] = process_info.pop('engine_usage') + engine_usage_unit = "ns" + memory_usage_unit = "B" + if self.logger.is_human_readable_format(): process_info['mem_usage'] = self.helpers.convert_bytes_to_readable(process_info['mem_usage']) - engine_usage_unit = "ns" for usage_metric in process_info['usage']: process_info['usage'][usage_metric] = f"{process_info['usage'][usage_metric]} {engine_usage_unit}" for usage_metric in process_info['memory_usage']: process_info['memory_usage'][usage_metric] = self.helpers.convert_bytes_to_readable(process_info['memory_usage'][usage_metric]) + elif self.logger.is_json_format(): + process_info['mem_usage'] = {"value" : process_info['mem_usage'], + "unit" : memory_usage_unit} + for usage_metric in process_info['usage']: + process_info['usage'][usage_metric] = {"value" : process_info['usage'][usage_metric], + "unit" : engine_usage_unit} + + for usage_metric in process_info['memory_usage']: + process_info['memory_usage'][usage_metric] = {"value" : process_info['memory_usage'][usage_metric], + "unit" : memory_usage_unit} + + filtered_process_values.append({'process_info': process_info}) + + if not filtered_process_values: + process_info = "N/A" + logging.debug("Failed to detect any process on gpu %s", gpu_id) filtered_process_values.append({'process_info': process_info}) # Arguments will filter the populated processes @@ -2641,7 +2651,7 @@ class AMDSMICommands(): # Convert and store output by pid for csv format if self.logger.is_csv_format(): # Check for empty list first - if filtered_process_values == []: + if not filtered_process_values: self.logger.store_output(args.gpu, 'process_info', 'No running processes detected') else: for process_info in filtered_process_values: @@ -2660,7 +2670,7 @@ class AMDSMICommands(): self.logger.store_output(args.gpu, 'timestamp', int(time.time())) # Store values in logger.output - if filtered_process_values == []: + if not filtered_process_values: self.logger.store_output(args.gpu, 'process_info', 'No running processes detected') else: for process_info in filtered_process_values: diff --git a/projects/amdsmi/py-interface/README.md b/projects/amdsmi/py-interface/README.md index 19454121ae..41468bd9a3 100644 --- a/projects/amdsmi/py-interface/README.md +++ b/projects/amdsmi/py-interface/README.md @@ -882,13 +882,21 @@ except AmdSmiException as e: ### amdsmi_get_gpu_process_list -Description: Returns the list of processes running on the target GPU. +Description: Returns the list of processes running on the target GPU; May require root level access Input parameters: * `processor_handle` device which to query -Output: List of `amdsmi_proc_info_t` process objects running on the target GPU; can be empty +Output: List of Dictionaries with the corresponding fields; empty list if no running process are detected + +Field | Description +---|--- +`name` | Name of process +`pid` | Process ID +`mem` | Process memory usage +`engine_usage` |
Subfield Description
`gfx`GFX engine usage in ns
`enc`Encode engine usage in ns
+`memory_usage` |
Subfield Description
`gtt_mem`GTT memory usage
`cpu_mem`CPU memory usage
`vram_mem`VRAM memory usage
Exceptions that can be thrown by `amdsmi_get_gpu_process_list` function: @@ -910,50 +918,7 @@ try: print("No processes running on this GPU") else: for process in processes: - print(amdsmi_get_gpu_process_info(device, process)) -except AmdSmiException as e: - print(e) -``` - -### amdsmi_get_gpu_process_info - -Description: Returns info about process given the target GPU and the corresponding `amdsmi_proc_info_t` object - -Input parameters: - -* `processor_handle` device which to query - -Output: Dictionary with fields - -Field | Description ----|--- -`name` | Name of process -`pid` | Process ID -`mem` | Process memory usage -`engine_usage` |
Subfield Description
`gfx`GFX engine usage in ns
`enc`Encode engine usage in ns
-`memory_usage` |
Subfield Description
`gtt_mem`GTT memory usage
`cpu_mem`CPU memory usage
`vram_mem`VRAM memory usage
Dict[str, Any]: - if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle): - raise AmdSmiParameterException( - processor_handle, amdsmi_wrapper.amdsmi_processor_handle - ) - - if not isinstance(process, amdsmi_wrapper.amdsmi_proc_info_t): - raise AmdSmiParameterException( - process, amdsmi_wrapper.amdsmi_proc_info_t) - - return { - "name": process.name.decode("utf-8"), - "pid": process.pid, - "mem": process.mem, - "engine_usage": { - "gfx": process.engine_usage.gfx, - "enc": process.engine_usage.enc - }, - "memory_usage": { - "gtt_mem": process.memory_usage.gtt_mem, - "cpu_mem": process.memory_usage.cpu_mem, - "vram_mem": process.memory_usage.vram_mem, - }, - } - - def amdsmi_get_gpu_device_uuid(processor_handle: amdsmi_wrapper.amdsmi_processor_handle) -> str: if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle): raise AmdSmiParameterException( From cebb07e795f17545f6fb6fb8adf4a205976e10bb Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Fri, 12 Apr 2024 12:43:32 -0500 Subject: [PATCH 2/5] Added new ecc blocks and adjusted metric --ecc-block filtering Signed-off-by: Maisam Arif Change-Id: Ib2f69c7d59ee5108024794434fb202b5e4f58738 [ROCm/amdsmi commit: 1bd18c1a658f2dad854c594375f21d3ed5465152] --- projects/amdsmi/CHANGELOG.md | 41 ++++++++++++- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 5 +- projects/amdsmi/include/amd_smi/amdsmi.h | 13 ++-- .../amdsmi/py-interface/amdsmi_interface.py | 8 ++- .../amdsmi/py-interface/amdsmi_wrapper.py | 60 +++++++++++-------- .../rocm_smi/include/rocm_smi/rocm_smi.h | 7 ++- .../rocm_smi/python_smi_tools/rsmiBindings.py | 41 ++++++++----- .../amdsmi/tests/amd_smi_test/test_common.cc | 7 ++- 8 files changed, 132 insertions(+), 50 deletions(-) diff --git a/projects/amdsmi/CHANGELOG.md b/projects/amdsmi/CHANGELOG.md index 03ee2bbe02..4d09bb5ea9 100644 --- a/projects/amdsmi/CHANGELOG.md +++ b/projects/amdsmi/CHANGELOG.md @@ -12,10 +12,47 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/]( ### Changed -- **Removed `amdsmi_get_gpu_process_info` from python library** +- **Updated `amd-smi metric --ecc-blocks` output** +The ecc blocks arguement was outputing blocks without counters available, updated the filtering show blocks that counters are available for: + +``` shell +$ amd-smi metric --ecc-block +GPU: 0 + ECC_BLOCKS: + UMC: + CORRECTABLE_COUNT: 0 + UNCORRECTABLE_COUNT: 0 + DEFERRED_COUNT: 0 + SDMA: + CORRECTABLE_COUNT: 0 + UNCORRECTABLE_COUNT: 0 + DEFERRED_COUNT: 0 + GFX: + CORRECTABLE_COUNT: 0 + UNCORRECTABLE_COUNT: 0 + DEFERRED_COUNT: 0 + MMHUB: + CORRECTABLE_COUNT: 0 + UNCORRECTABLE_COUNT: 0 + DEFERRED_COUNT: 0 + PCIE_BIF: + CORRECTABLE_COUNT: 0 + UNCORRECTABLE_COUNT: 0 + DEFERRED_COUNT: 0 + HDP: + CORRECTABLE_COUNT: 0 + UNCORRECTABLE_COUNT: 0 + DEFERRED_COUNT: 0 + XGMI_WAFL: + CORRECTABLE_COUNT: 0 + UNCORRECTABLE_COUNT: 0 + DEFERRED_COUNT: 0 +``` + +- **Removed `amdsmi_get_gpu_process_info` from python library** amdsmi_get_gpu_process_info was removed from the C library in an earlier build, but the API was still in the python interface -- **Updated metrics --clocks** +- **Updated metrics --clocks** Output for `amd-smi metric --clock` is updated to reflect each engine and bug fixes for the clock lock status and deep sleep status. ``` shell diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index 31c32f0aa4..17427ff34e 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -1692,14 +1692,15 @@ class AMDSMICommands(): if "ecc_blocks" in current_platform_args: if args.ecc_blocks: ecc_dict = {} - uncountable_blocks = ["ATHUB", "DF", "SMN", "SEM", "FUSE"] + sysfs_blocks = ["UMC", "SDMA", "GFX", "MMHUB", "PCIE_BIF", "HDP", "XGMI_WAFL"] try: ras_states = amdsmi_interface.amdsmi_get_gpu_ras_block_features_enabled(args.gpu) for state in ras_states: + # Only add enabled blocks that are also in sysfs if state['status'] == amdsmi_interface.AmdSmiRasErrState.ENABLED.name: gpu_block = amdsmi_interface.AmdSmiGpuBlock[state['block']] # if the blocks are uncountable do not add them at all. - if gpu_block.name not in uncountable_blocks: + if gpu_block.name in sysfs_blocks: try: ecc_count = amdsmi_interface.amdsmi_get_gpu_ecc_count(args.gpu, gpu_block) ecc_dict[state['block']] = {'correctable_count' : ecc_count['correctable_count'], diff --git a/projects/amdsmi/include/amd_smi/amdsmi.h b/projects/amdsmi/include/amd_smi/amdsmi.h index ba73c093b9..c5adb70252 100644 --- a/projects/amdsmi/include/amd_smi/amdsmi.h +++ b/projects/amdsmi/include/amd_smi/amdsmi.h @@ -964,10 +964,10 @@ typedef enum { */ typedef enum { AMDSMI_GPU_BLOCK_INVALID = 0x0000000000000000, //!< Used to indicate an - //!< invalid block + //!< invalid block AMDSMI_GPU_BLOCK_FIRST = 0x0000000000000001, - AMDSMI_GPU_BLOCK_UMC = AMDSMI_GPU_BLOCK_FIRST, //!< UMC block + AMDSMI_GPU_BLOCK_UMC = AMDSMI_GPU_BLOCK_FIRST, //!< UMC block AMDSMI_GPU_BLOCK_SDMA = 0x0000000000000002, //!< SDMA block AMDSMI_GPU_BLOCK_GFX = 0x0000000000000004, //!< GFX block AMDSMI_GPU_BLOCK_MMHUB = 0x0000000000000008, //!< MMHUB block @@ -981,9 +981,14 @@ typedef enum { AMDSMI_GPU_BLOCK_MP0 = 0x0000000000000800, //!< MP0 block AMDSMI_GPU_BLOCK_MP1 = 0x0000000000001000, //!< MP1 block AMDSMI_GPU_BLOCK_FUSE = 0x0000000000002000, //!< Fuse block + AMDSMI_GPU_BLOCK_MCA = 0x0000000000004000, //!< MCA block + AMDSMI_GPU_BLOCK_VCN = 0x0000000000008000, //!< VCN block + AMDSMI_GPU_BLOCK_JPEG = 0x0000000000010000, //!< JPEG block + AMDSMI_GPU_BLOCK_IH = 0x0000000000020000, //!< IH block + AMDSMI_GPU_BLOCK_MPIO = 0x0000000000040000, //!< MPIO block - AMDSMI_GPU_BLOCK_LAST = AMDSMI_GPU_BLOCK_FUSE, //!< The highest bit position - //!< for supported blocks + AMDSMI_GPU_BLOCK_LAST = AMDSMI_GPU_BLOCK_MPIO, //!< The highest bit position + //!< for supported blocks AMDSMI_GPU_BLOCK_RESERVED = 0x8000000000000000 } amdsmi_gpu_block_t; diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index 6245f194a3..31bf22adae 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -300,6 +300,11 @@ class AmdSmiGpuBlock(IntEnum): MP0 = amdsmi_wrapper.AMDSMI_GPU_BLOCK_MP0 MP1 = amdsmi_wrapper.AMDSMI_GPU_BLOCK_MP1 FUSE = amdsmi_wrapper.AMDSMI_GPU_BLOCK_FUSE + MCA = amdsmi_wrapper.AMDSMI_GPU_BLOCK_MCA + VCN = amdsmi_wrapper.AMDSMI_GPU_BLOCK_VCN + JPEG = amdsmi_wrapper.AMDSMI_GPU_BLOCK_JPEG + IH = amdsmi_wrapper.AMDSMI_GPU_BLOCK_IH + MPIO = amdsmi_wrapper.AMDSMI_GPU_BLOCK_MPIO RESERVED = amdsmi_wrapper.AMDSMI_GPU_BLOCK_RESERVED @@ -1906,7 +1911,7 @@ def amdsmi_get_gpu_ras_block_features_enabled( if gpu_block.name == "RESERVED" or gpu_block.name == "INVALID": continue if gpu_block.name == "LAST": - gpu_block.name = "FUSE" + gpu_block.name = "MPIO" _check_res( amdsmi_wrapper.amdsmi_get_gpu_ras_block_features_enabled( processor_handle, @@ -1959,6 +1964,7 @@ def amdsmi_get_gpu_process_list( "vram_mem": process_list[index].memory_usage.vram_mem, }, }) + print(result) return result diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py b/projects/amdsmi/py-interface/amdsmi_wrapper.py index d9116193fc..06ae08ce18 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py @@ -748,6 +748,19 @@ 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 @@ -766,19 +779,6 @@ struct_pcie_metric_._fields_ = [ ('reserved', ctypes.c_uint64 * 13), ] -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_), @@ -1300,7 +1300,12 @@ amdsmi_gpu_block_t__enumvalues = { 2048: 'AMDSMI_GPU_BLOCK_MP0', 4096: 'AMDSMI_GPU_BLOCK_MP1', 8192: 'AMDSMI_GPU_BLOCK_FUSE', - 8192: 'AMDSMI_GPU_BLOCK_LAST', + 16384: 'AMDSMI_GPU_BLOCK_MCA', + 32768: 'AMDSMI_GPU_BLOCK_VCN', + 65536: 'AMDSMI_GPU_BLOCK_JPEG', + 131072: 'AMDSMI_GPU_BLOCK_IH', + 262144: 'AMDSMI_GPU_BLOCK_MPIO', + 262144: 'AMDSMI_GPU_BLOCK_LAST', 9223372036854775808: 'AMDSMI_GPU_BLOCK_RESERVED', } AMDSMI_GPU_BLOCK_INVALID = 0 @@ -1319,7 +1324,12 @@ AMDSMI_GPU_BLOCK_SEM = 1024 AMDSMI_GPU_BLOCK_MP0 = 2048 AMDSMI_GPU_BLOCK_MP1 = 4096 AMDSMI_GPU_BLOCK_FUSE = 8192 -AMDSMI_GPU_BLOCK_LAST = 8192 +AMDSMI_GPU_BLOCK_MCA = 16384 +AMDSMI_GPU_BLOCK_VCN = 32768 +AMDSMI_GPU_BLOCK_JPEG = 65536 +AMDSMI_GPU_BLOCK_IH = 131072 +AMDSMI_GPU_BLOCK_MPIO = 262144 +AMDSMI_GPU_BLOCK_LAST = 262144 AMDSMI_GPU_BLOCK_RESERVED = 9223372036854775808 amdsmi_gpu_block_t = ctypes.c_uint64 # enum @@ -2380,17 +2390,19 @@ __all__ = \ 'AMDSMI_GPU_BLOCK_ATHUB', 'AMDSMI_GPU_BLOCK_DF', 'AMDSMI_GPU_BLOCK_FIRST', 'AMDSMI_GPU_BLOCK_FUSE', 'AMDSMI_GPU_BLOCK_GFX', 'AMDSMI_GPU_BLOCK_HDP', - 'AMDSMI_GPU_BLOCK_INVALID', 'AMDSMI_GPU_BLOCK_LAST', - 'AMDSMI_GPU_BLOCK_MMHUB', 'AMDSMI_GPU_BLOCK_MP0', - 'AMDSMI_GPU_BLOCK_MP1', 'AMDSMI_GPU_BLOCK_PCIE_BIF', + 'AMDSMI_GPU_BLOCK_IH', 'AMDSMI_GPU_BLOCK_INVALID', + 'AMDSMI_GPU_BLOCK_JPEG', 'AMDSMI_GPU_BLOCK_LAST', + 'AMDSMI_GPU_BLOCK_MCA', 'AMDSMI_GPU_BLOCK_MMHUB', + 'AMDSMI_GPU_BLOCK_MP0', 'AMDSMI_GPU_BLOCK_MP1', + 'AMDSMI_GPU_BLOCK_MPIO', 'AMDSMI_GPU_BLOCK_PCIE_BIF', 'AMDSMI_GPU_BLOCK_RESERVED', 'AMDSMI_GPU_BLOCK_SDMA', 'AMDSMI_GPU_BLOCK_SEM', 'AMDSMI_GPU_BLOCK_SMN', - 'AMDSMI_GPU_BLOCK_UMC', 'AMDSMI_GPU_BLOCK_XGMI_WAFL', - 'AMDSMI_HSMP_TIMEOUT', 'AMDSMI_INIT_ALL_PROCESSORS', - 'AMDSMI_INIT_AMD_APUS', 'AMDSMI_INIT_AMD_CPUS', - 'AMDSMI_INIT_AMD_GPUS', 'AMDSMI_INIT_NON_AMD_CPUS', - 'AMDSMI_INIT_NON_AMD_GPUS', 'AMDSMI_INVALID_POWER', - 'AMDSMI_IOLINK_TYPE_NUMIOLINKTYPES', + 'AMDSMI_GPU_BLOCK_UMC', 'AMDSMI_GPU_BLOCK_VCN', + 'AMDSMI_GPU_BLOCK_XGMI_WAFL', 'AMDSMI_HSMP_TIMEOUT', + 'AMDSMI_INIT_ALL_PROCESSORS', 'AMDSMI_INIT_AMD_APUS', + 'AMDSMI_INIT_AMD_CPUS', 'AMDSMI_INIT_AMD_GPUS', + 'AMDSMI_INIT_NON_AMD_CPUS', 'AMDSMI_INIT_NON_AMD_GPUS', + 'AMDSMI_INVALID_POWER', 'AMDSMI_IOLINK_TYPE_NUMIOLINKTYPES', 'AMDSMI_IOLINK_TYPE_PCIEXPRESS', 'AMDSMI_IOLINK_TYPE_SIZE', 'AMDSMI_IOLINK_TYPE_UNDEFINED', 'AMDSMI_IOLINK_TYPE_XGMI', 'AMDSMI_LINK_TYPE_NOT_APPLICABLE', 'AMDSMI_LINK_TYPE_PCIE', diff --git a/projects/amdsmi/rocm_smi/include/rocm_smi/rocm_smi.h b/projects/amdsmi/rocm_smi/include/rocm_smi/rocm_smi.h index b6420d7933..3749690067 100755 --- a/projects/amdsmi/rocm_smi/include/rocm_smi/rocm_smi.h +++ b/projects/amdsmi/rocm_smi/include/rocm_smi/rocm_smi.h @@ -608,8 +608,13 @@ typedef enum { RSMI_GPU_BLOCK_MP0 = 0x0000000000000800, //!< MP0 block RSMI_GPU_BLOCK_MP1 = 0x0000000000001000, //!< MP1 block RSMI_GPU_BLOCK_FUSE = 0x0000000000002000, //!< Fuse block + RSMI_GPU_BLOCK_MCA = 0x0000000000004000, //!< MCA block + RSMI_GPU_BLOCK_VCN = 0x0000000000008000, //!< VCN block + RSMI_GPU_BLOCK_JPEG = 0x0000000000010000, //!< JPEG block + RSMI_GPU_BLOCK_IH = 0x0000000000020000, //!< IH block + RSMI_GPU_BLOCK_MPIO = 0x0000000000040000, //!< MPIO block - RSMI_GPU_BLOCK_LAST = RSMI_GPU_BLOCK_FUSE, //!< The highest bit position + RSMI_GPU_BLOCK_LAST = RSMI_GPU_BLOCK_MPIO, //!< The highest bit position //!< for supported blocks RSMI_GPU_BLOCK_RESERVED = 0x8000000000000000 } rsmi_gpu_block_t; diff --git a/projects/amdsmi/rocm_smi/python_smi_tools/rsmiBindings.py b/projects/amdsmi/rocm_smi/python_smi_tools/rsmiBindings.py index 884793468f..94d493d7ea 100644 --- a/projects/amdsmi/rocm_smi/python_smi_tools/rsmiBindings.py +++ b/projects/amdsmi/rocm_smi/python_smi_tools/rsmiBindings.py @@ -331,7 +331,13 @@ class rsmi_gpu_block_t(c_int): RSMI_GPU_BLOCK_MP0 = 0x0000000000000800 RSMI_GPU_BLOCK_MP1 = 0x0000000000001000 RSMI_GPU_BLOCK_FUSE = 0x0000000000002000 - RSMI_GPU_BLOCK_LAST = RSMI_GPU_BLOCK_FUSE + RSMI_GPU_BLOCK_MCA = 0x0000000000004000 + RSMI_GPU_BLOCK_VCN = 0x0000000000008000 + RSMI_GPU_BLOCK_JPEG = 0x0000000000010000 + RSMI_GPU_BLOCK_IH = 0x0000000000020000 + RSMI_GPU_BLOCK_MPIO = 0x0000000000040000 + + RSMI_GPU_BLOCK_LAST = RSMI_GPU_BLOCK_MPIO RSMI_GPU_BLOCK_RESERVED = 0x8000000000000000 @@ -340,20 +346,25 @@ rsmi_gpu_block = rsmi_gpu_block_t # The following dictionary correlates with rsmi_gpu_block_t enum rsmi_gpu_block_d = { - 'UMC' : 0x0000000000000001, - 'SDMA' : 0x0000000000000002, - 'GFX' : 0x0000000000000004, - 'MMHUB': 0x0000000000000008, - 'ATHUB': 0x0000000000000010, - 'PCIE_BIF': 0x0000000000000020, - 'HDP': 0x0000000000000040, - 'XGMI_WAFL': 0x0000000000000080, - 'DF': 0x0000000000000100, - 'SMN': 0x0000000000000200, - 'SEM': 0x0000000000000400, - 'MP0': 0x0000000000000800, - 'MP1': 0x0000000000001000, - 'FUSE': 0x0000000000002000 + 'UMC' : 0x0000000000000001, + 'SDMA' : 0x0000000000000002, + 'GFX' : 0x0000000000000004, + 'MMHUB' : 0x0000000000000008, + 'ATHUB' : 0x0000000000000010, + 'PCIE_BIF' : 0x0000000000000020, + 'HDP' : 0x0000000000000040, + 'XGMI_WAFL' : 0x0000000000000080, + 'DF' : 0x0000000000000100, + 'SMN' : 0x0000000000000200, + 'SEM' : 0x0000000000000400, + 'MP0' : 0x0000000000000800, + 'MP1' : 0x0000000000001000, + 'FUSE' : 0x0000000000002000, + 'MCA' : 0x0000000000004000, + 'VCN' : 0x0000000000008000, + 'JPEG' : 0x0000000000010000, + 'IH' : 0x0000000000020000, + 'MPIO' : 0x0000000000040000, } diff --git a/projects/amdsmi/tests/amd_smi_test/test_common.cc b/projects/amdsmi/tests/amd_smi_test/test_common.cc index 7237e4cc89..669c8186f1 100644 --- a/projects/amdsmi/tests/amd_smi_test/test_common.cc +++ b/projects/amdsmi/tests/amd_smi_test/test_common.cc @@ -91,8 +91,13 @@ static const std::map kBlockNameMap = { {AMDSMI_GPU_BLOCK_MP0, "MP0"}, {AMDSMI_GPU_BLOCK_MP1, "MP1"}, {AMDSMI_GPU_BLOCK_FUSE, "FUSE"}, + {AMDSMI_GPU_BLOCK_MCA, "MCA"}, + {AMDSMI_GPU_BLOCK_VCN, "VCN"}, + {AMDSMI_GPU_BLOCK_JPEG, "JPEG"}, + {AMDSMI_GPU_BLOCK_IH, "IH"}, + {AMDSMI_GPU_BLOCK_MPIO, "MPIO"}, }; -static_assert(AMDSMI_GPU_BLOCK_LAST == AMDSMI_GPU_BLOCK_FUSE, +static_assert(AMDSMI_GPU_BLOCK_LAST == AMDSMI_GPU_BLOCK_MPIO, "kBlockNameMap needs to be updated"); static const char * kRasErrStateStrings[] = { From e7814472bf27b6f95d1d557089ac00112d3eea8a Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Tue, 23 Apr 2024 04:41:43 -0500 Subject: [PATCH 3/5] Updated Sphinx to include Changelog Signed-off-by: Maisam Arif Change-Id: I858d0579ab0e8ba9f228373b6d31dfd3088703ae [ROCm/amdsmi commit: e81051a72490d9554b24dba5a363c69d986e968e] --- projects/amdsmi/docs/amdsmi_changelog_link.md | 2 ++ projects/amdsmi/docs/conf.py | 13 ------------- projects/amdsmi/docs/esmi_lib_readme_link.md | 3 --- projects/amdsmi/docs/sphinx/_toc.yml.in | 6 +++--- 4 files changed, 5 insertions(+), 19 deletions(-) create mode 100644 projects/amdsmi/docs/amdsmi_changelog_link.md delete mode 100644 projects/amdsmi/docs/esmi_lib_readme_link.md diff --git a/projects/amdsmi/docs/amdsmi_changelog_link.md b/projects/amdsmi/docs/amdsmi_changelog_link.md new file mode 100644 index 0000000000..66efc0fecd --- /dev/null +++ b/projects/amdsmi/docs/amdsmi_changelog_link.md @@ -0,0 +1,2 @@ +```{include} ../CHANGELOG.md +``` diff --git a/projects/amdsmi/docs/conf.py b/projects/amdsmi/docs/conf.py index 4e4806d16c..2b84ea8ce5 100644 --- a/projects/amdsmi/docs/conf.py +++ b/projects/amdsmi/docs/conf.py @@ -6,21 +6,8 @@ import subprocess -import urllib from rocm_docs import ROCmDocs -esmi_readme_link = "https://raw.githubusercontent.com/amd/esmi_ib_library/master/docs/README.md" -try: - # Try to override esmi_lib_readme_link.md with the github esmi readme contents - with urllib.request.urlopen(esmi_readme_link) as f: - esmi_readme = f.read().decode('utf-8') - - with open("./esmi_lib_readme_link.md", "w", encoding='utf-8') as f: - f.write(esmi_readme) -except urllib.error.URLError: - # don't care about the error because there is backup link in the file already - pass - get_version_year = r'sed -n -e "s/^#define\ AMDSMI_LIB_VERSION_YEAR\ //p" ../include/amd_smi/amdsmi.h' get_version_major = r'sed -n -e "s/^#define\ AMDSMI_LIB_VERSION_MAJOR\ //p" ../include/amd_smi/amdsmi.h' get_version_minor = r'sed -n -e "s/^#define\ AMDSMI_LIB_VERSION_MINOR\ //p" ../include/amd_smi/amdsmi.h' diff --git a/projects/amdsmi/docs/esmi_lib_readme_link.md b/projects/amdsmi/docs/esmi_lib_readme_link.md deleted file mode 100644 index 559434f106..0000000000 --- a/projects/amdsmi/docs/esmi_lib_readme_link.md +++ /dev/null @@ -1,3 +0,0 @@ -# ESMI Library README - -For more information, see the [ESMI Library README](https://raw.githubusercontent.com/amd/esmi_ib_library/master/docs/README.md) diff --git a/projects/amdsmi/docs/sphinx/_toc.yml.in b/projects/amdsmi/docs/sphinx/_toc.yml.in index c05c3bfbf0..fabff6292c 100644 --- a/projects/amdsmi/docs/sphinx/_toc.yml.in +++ b/projects/amdsmi/docs/sphinx/_toc.yml.in @@ -17,10 +17,10 @@ subtrees: title: Python CLI Tool - file: amdsmi_release_notes_link title: Python CLI Release Notes - - caption: Libraries + - caption: Changelog entries: - - file: esmi_lib_readme_link - title: ESMI Library + - file: amdsmi_changelog_link + title: AMD-SMI Changelog - caption: About entries: - file: license From 2838dad477da0146b190a2bc3d05e6b3b812f343 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Tue, 23 Apr 2024 04:49:47 -0500 Subject: [PATCH 4/5] Removed print in python interface Signed-off-by: Maisam Arif Change-Id: I80e8cf18dc7631c66d4863251438327b8853cead [ROCm/amdsmi commit: 0d6626db0d7a20857a5eece3d26ac1a8e413b11f] --- projects/amdsmi/py-interface/README.md | 6 +++--- projects/amdsmi/py-interface/amdsmi_interface.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/amdsmi/py-interface/README.md b/projects/amdsmi/py-interface/README.md index 41468bd9a3..e165eb2860 100644 --- a/projects/amdsmi/py-interface/README.md +++ b/projects/amdsmi/py-interface/README.md @@ -88,7 +88,7 @@ Initialize GPUs only example: ```python try: # by default we initalize with AmdSmiInitFlags.INIT_AMD_GPUS - init_flag = amdsmi_init() + ret = amdsmi_init() # continue with amdsmi except AmdSmiException as e: print("Init GPUs failed") @@ -99,7 +99,7 @@ Initialize CPUs only example: ```python try: - init_flag = amdsmi_init(AmdSmiInitFlags.INIT_AMD_CPUS) + ret = amdsmi_init(AmdSmiInitFlags.INIT_AMD_CPUS) # continue with amdsmi except AmdSmiException as e: print("Init CPUs failed") @@ -110,7 +110,7 @@ Initialize both GPUs and CPUs example: ```python try: - init_flag = amdsmi_init(AmdSmiInitFlags.INIT_AMD_APUS) + ret = amdsmi_init(AmdSmiInitFlags.INIT_AMD_APUS) # continue with amdsmi except AmdSmiException as e: print("Init both GPUs & CPUs failed") diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index 31bf22adae..61222340bb 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -1964,7 +1964,7 @@ def amdsmi_get_gpu_process_list( "vram_mem": process_list[index].memory_usage.vram_mem, }, }) - print(result) + return result From 2233d3295825588ec8a1373a46d4f7e11aea7484 Mon Sep 17 00:00:00 2001 From: "Oliveira, Daniel" Date: Tue, 23 Apr 2024 18:18:45 -0500 Subject: [PATCH 5/5] fix: [SWDEV-458102] [rocm/amd_smi_lib] Drops checks that are invalid with the new pp_od_clk_voltage format Code changes related to the following: * get_od_clk_volt_info() * get_od_clk_volt_curve_regions() Change-Id: I534c920e00fa3dacdb980f431db5eef260ac93f5 Signed-off-by: Oliveira, Daniel [ROCm/amdsmi commit: 1ae3a5b6cb610f1f2e76056893e30b7a7b113dcc] --- projects/amdsmi/rocm_smi/src/rocm_smi.cc | 53 +++--------------------- 1 file changed, 5 insertions(+), 48 deletions(-) diff --git a/projects/amdsmi/rocm_smi/src/rocm_smi.cc b/projects/amdsmi/rocm_smi/src/rocm_smi.cc index 6aa0d86fce..9511a2942f 100755 --- a/projects/amdsmi/rocm_smi/src/rocm_smi.cc +++ b/projects/amdsmi/rocm_smi/src/rocm_smi.cc @@ -1425,6 +1425,7 @@ constexpr uint32_t kOD_VDDC_CURVE_start_index = kOD_OD_RANGE_label_array_index + 3; // constexpr uint32_t kOD_VDDC_CURVE_num_lines = // kOD_VDDC_CURVE_start_index + 4; +constexpr uint32_t kMIN_VALID_LINES = 2; static rsmi_status_t get_od_clk_volt_info(uint32_t dv_ind, rsmi_od_volt_freq_data_t *p) { @@ -1444,7 +1445,7 @@ static rsmi_status_t get_od_clk_volt_info(uint32_t dv_ind, // This is a work-around to handle systems where kDevPowerODVoltage is not // fully supported yet. - if (val_vec.size() < 2) { + if (val_vec.size() < kMIN_VALID_LINES) { return RSMI_STATUS_NOT_YET_IMPLEMENTED; } @@ -1455,6 +1456,7 @@ static rsmi_status_t get_od_clk_volt_info(uint32_t dv_ind, return RSMI_STATUS_UNEXPECTED_DATA; } + // find last_item but skip empty lines int last_item = val_vec.size()-1; while (val_vec[last_item].empty() || val_vec[last_item][0] == 0) @@ -1500,39 +1502,9 @@ static rsmi_status_t get_od_clk_volt_info(uint32_t dv_ind, if (val_vec.size() < kOD_VDDC_CURVE_label_array_index) { return RSMI_STATUS_UNEXPECTED_SIZE; } - assert(val_vec[kOD_VDDC_CURVE_label_array_index] == "OD_VDDC_CURVE:"); - if (val_vec[kOD_VDDC_CURVE_label_array_index] != "OD_VDDC_CURVE:") { - return RSMI_STATUS_UNEXPECTED_DATA; - } - - uint32_t tmp = kOD_VDDC_CURVE_label_array_index + 1; - if (val_vec.size() < (tmp + RSMI_NUM_VOLTAGE_CURVE_POINTS)) { - return RSMI_STATUS_UNEXPECTED_SIZE; - } - for (uint32_t i = 0; i < RSMI_NUM_VOLTAGE_CURVE_POINTS; ++i) { - freq_volt_string_to_point(val_vec[tmp + i], &(p->curve.vc_points[i])); - } - - if (val_vec.size() < (kOD_OD_RANGE_label_array_index + 2)) { - return RSMI_STATUS_UNEXPECTED_SIZE; - } - assert(val_vec[kOD_OD_RANGE_label_array_index] == "OD_RANGE:"); - if (val_vec[kOD_OD_RANGE_label_array_index] != "OD_RANGE:") { - return RSMI_STATUS_UNEXPECTED_DATA; - } - - od_value_pair_str_to_range(val_vec[kOD_OD_RANGE_label_array_index + 1], - &(p->sclk_freq_limits)); - od_value_pair_str_to_range(val_vec[kOD_OD_RANGE_label_array_index + 2], - &(p->mclk_freq_limits)); - - assert((val_vec.size() - kOD_VDDC_CURVE_start_index)%2 == 0); - if ((val_vec.size() - kOD_VDDC_CURVE_start_index)%2 != 0) { - return RSMI_STATUS_UNEXPECTED_SIZE; - } p->num_regions = - static_cast((val_vec.size() - kOD_VDDC_CURVE_start_index) / 2); + static_cast((val_vec.size()) / 2); return RSMI_STATUS_SUCCESS; CATCH @@ -1766,28 +1738,13 @@ static rsmi_status_t get_od_clk_volt_curve_regions(uint32_t dv_ind, uint32_t val_vec_size = static_cast(val_vec.size()); assert((val_vec_size - kOD_VDDC_CURVE_start_index) > 0); - assert((val_vec_size - kOD_VDDC_CURVE_start_index)%2 == 0); ss << __PRETTY_FUNCTION__ << " | val_vec_size = " << std::dec << val_vec_size << " | kOD_VDDC_CURVE_start_index = " << kOD_VDDC_CURVE_start_index; LOG_DEBUG(ss); - if (((val_vec_size - kOD_VDDC_CURVE_start_index) <= 0) || - (((val_vec_size - kOD_VDDC_CURVE_start_index)%2 != 0))) { - ss << __PRETTY_FUNCTION__ << " | Issue: od vdd curve returned unexpected " - << "data" << "; returning " - << getRSMIStatusString(RSMI_STATUS_UNEXPECTED_SIZE); - LOG_ERROR(ss); - throw amd::smi::rsmi_exception(RSMI_STATUS_UNEXPECTED_SIZE, __FUNCTION__); - } - - *num_regions = std::min((val_vec_size - kOD_VDDC_CURVE_start_index) / 2, - *num_regions); - - for (uint32_t i=0; i < *num_regions; ++i) { - get_vc_region(kOD_VDDC_CURVE_start_index + i*2, &val_vec, p + i); - } + *num_regions = std::min((val_vec_size) / 2, *num_regions); return RSMI_STATUS_SUCCESS; CATCH