diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index f8f049dd64..741f78b960 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -466,9 +466,18 @@ class AMDSMICommands(): if args.cache: try: cache_info = amdsmi_interface.amdsmi_get_gpu_cache_info(args.gpu) + for cache_key, cache_dict in cache_info.items(): + for key, value in cache_dict.items(): + if key == 'cache_size' or key == 'cache_level': + continue + if value: + cache_info[cache_key][key] = "ENABLED" + else: + cache_info[cache_key][key] = "DISABLED" if self.logger.is_human_readable_format(): for _ , cache_values in cache_info.items(): cache_values['cache_size'] = f"{cache_values['cache_size']} KB" + except amdsmi_exception.AmdSmiLibraryException as e: cache_info = "N/A" logging.debug("Failed to get cache info for gpu %s | %s", gpu_id, e.get_error_info()) diff --git a/projects/amdsmi/py-interface/README.md b/projects/amdsmi/py-interface/README.md index 636aa02e0f..c3033ef149 100644 --- a/projects/amdsmi/py-interface/README.md +++ b/projects/amdsmi/py-interface/README.md @@ -478,6 +478,10 @@ Field | Description `cache #` | upt 10 caches will be available `cache_size` | size of cache in KB `cache_level` | level of cache +`data_cache` | True if data cache is enabled, false otherwise +`instruction_cache` | True if instruction cache is enabled, false otherwise +`cpu_cache` | True if cpu cache is enabled, false otherwise +`simd_cache` | True if simd cache is enabled, false otherwise Exceptions that can be thrown by `amdsmi_get_gpu_cache_info` function: @@ -499,6 +503,10 @@ try: print(cache_index) print(cache_values['cache_size']) print(cache_values['cache_level']) + print(cache_values['data_cache']) + print(cache_values['instruction_cache']) + print(cache_values['cpu_cache']) + print(cache_values['simd_cache']) except AmdSmiException as e: print(e) ``` diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index 97d4dbc269..1e37eb7adf 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -991,7 +991,7 @@ def amdsmi_get_gpu_vram_info( def amdsmi_get_gpu_cache_info( processor_handle: amdsmi_wrapper.amdsmi_processor_handle, -) -> Dict[str, Any]: +) -> Dict[str, Dict[str, Any]]: if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle): raise AmdSmiParameterException( processor_handle, amdsmi_wrapper.amdsmi_processor_handle @@ -1007,8 +1007,17 @@ def amdsmi_get_gpu_cache_info( for cache_index in range(cache_info.num_cache_types): cache_size = cache_info.cache[cache_index].cache_size_kb cache_level = cache_info.cache[cache_index].cache_level + cache_flags = cache_info.cache[cache_index].flags + data_cache = bool(cache_flags & amdsmi_wrapper.CACHE_FLAGS_DATA_CACHE) + inst_cache = bool(cache_flags & amdsmi_wrapper.CACHE_FLAGS_INST_CACHE) + cpu_cache = bool(cache_flags & amdsmi_wrapper.CACHE_FLAGS_CPU_CACHE) + simd_cache = bool(cache_flags & amdsmi_wrapper.CACHE_FLAGS_SIMD_CACHE) cache_info_dict[f"cache {cache_index}"] = {"cache_size": cache_size, - "cache_level": cache_level} + "cache_level": cache_level, + "data_cache": data_cache, + "instruction_cache": inst_cache, + "cpu_cache": cpu_cache, + "simd_cache": simd_cache} return cache_info_dict diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py.in b/projects/amdsmi/py-interface/amdsmi_wrapper.py.in index c6caa37c28..00ae691291 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py.in +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py.in @@ -751,6 +751,21 @@ struct_amdsmi_vbios_info_t._fields_ = [ ] amdsmi_vbios_info_t = struct_amdsmi_vbios_info_t + +# values for enumeration 'amdsmi_cache_flags_type_t' +amdsmi_cache_flags_type_t__enumvalues = { + 1: 'CACHE_FLAGS_ENABLED', + 2: 'CACHE_FLAGS_DATA_CACHE', + 4: 'CACHE_FLAGS_INST_CACHE', + 8: 'CACHE_FLAGS_CPU_CACHE', + 16: 'CACHE_FLAGS_SIMD_CACHE', +} +CACHE_FLAGS_ENABLED = 1 +CACHE_FLAGS_DATA_CACHE = 2 +CACHE_FLAGS_INST_CACHE = 4 +CACHE_FLAGS_CPU_CACHE = 8 +CACHE_FLAGS_SIMD_CACHE = 16 +amdsmi_cache_flags_type_t = ctypes.c_uint32 # enum class struct_amdsmi_gpu_cache_info_t(Structure): pass @@ -761,6 +776,7 @@ struct_cache_._pack_ = 1 # source:False struct_cache_._fields_ = [ ('cache_size_kb', ctypes.c_uint32), ('cache_level', ctypes.c_uint32), + ('flags', ctypes.c_uint32), ('reserved', ctypes.c_uint32 * 3), ] @@ -2193,22 +2209,24 @@ __all__ = \ 'AMDSMI_VRAM_VENDOR__WINBOND', 'AMDSMI_XGMI_STATUS_ERROR', 'AMDSMI_XGMI_STATUS_MULTIPLE_ERRORS', 'AMDSMI_XGMI_STATUS_NO_ERRORS', 'AMD_APU', 'AMD_CPU', - 'AMD_CPU_CORE', 'AMD_GPU', 'CLK_TYPE_DCEF', 'CLK_TYPE_DCLK0', - 'CLK_TYPE_DCLK1', 'CLK_TYPE_DF', 'CLK_TYPE_FIRST', 'CLK_TYPE_GFX', - 'CLK_TYPE_MEM', 'CLK_TYPE_PCIE', 'CLK_TYPE_SOC', 'CLK_TYPE_SYS', - 'CLK_TYPE_VCLK0', 'CLK_TYPE_VCLK1', 'CLK_TYPE__MAX', - 'COMPUTE_PARTITION_CPX', 'COMPUTE_PARTITION_DPX', - 'COMPUTE_PARTITION_INVALID', 'COMPUTE_PARTITION_QPX', - 'COMPUTE_PARTITION_SPX', 'COMPUTE_PARTITION_TPX', - 'CONTAINER_DOCKER', 'CONTAINER_LXC', 'FW_ID_ASD', 'FW_ID_CP_CE', - 'FW_ID_CP_ME', 'FW_ID_CP_MEC1', 'FW_ID_CP_MEC2', - 'FW_ID_CP_MEC_JT1', 'FW_ID_CP_MEC_JT2', 'FW_ID_CP_MES', - 'FW_ID_CP_PFP', 'FW_ID_CP_PM4', 'FW_ID_DFC', 'FW_ID_DMCU', - 'FW_ID_DMCU_ERAM', 'FW_ID_DMCU_ISR', 'FW_ID_DRV_CAP', - 'FW_ID_FIRST', 'FW_ID_IMU_DRAM', 'FW_ID_IMU_IRAM', 'FW_ID_ISP', - 'FW_ID_MC', 'FW_ID_MES_KIQ', 'FW_ID_MES_STACK', - 'FW_ID_MES_THREAD1', 'FW_ID_MES_THREAD1_STACK', 'FW_ID_MMSCH', - 'FW_ID_PPTABLE', 'FW_ID_PSP_BL', 'FW_ID_PSP_DBG', + 'AMD_CPU_CORE', 'AMD_GPU', 'CACHE_FLAGS_CPU_CACHE', + 'CACHE_FLAGS_DATA_CACHE', 'CACHE_FLAGS_ENABLED', + 'CACHE_FLAGS_INST_CACHE', 'CACHE_FLAGS_SIMD_CACHE', + 'CLK_TYPE_DCEF', 'CLK_TYPE_DCLK0', 'CLK_TYPE_DCLK1', + 'CLK_TYPE_DF', 'CLK_TYPE_FIRST', 'CLK_TYPE_GFX', 'CLK_TYPE_MEM', + 'CLK_TYPE_PCIE', 'CLK_TYPE_SOC', 'CLK_TYPE_SYS', 'CLK_TYPE_VCLK0', + 'CLK_TYPE_VCLK1', 'CLK_TYPE__MAX', 'COMPUTE_PARTITION_CPX', + 'COMPUTE_PARTITION_DPX', 'COMPUTE_PARTITION_INVALID', + 'COMPUTE_PARTITION_QPX', 'COMPUTE_PARTITION_SPX', + 'COMPUTE_PARTITION_TPX', 'CONTAINER_DOCKER', 'CONTAINER_LXC', + 'FW_ID_ASD', 'FW_ID_CP_CE', 'FW_ID_CP_ME', 'FW_ID_CP_MEC1', + 'FW_ID_CP_MEC2', 'FW_ID_CP_MEC_JT1', 'FW_ID_CP_MEC_JT2', + 'FW_ID_CP_MES', 'FW_ID_CP_PFP', 'FW_ID_CP_PM4', 'FW_ID_DFC', + 'FW_ID_DMCU', 'FW_ID_DMCU_ERAM', 'FW_ID_DMCU_ISR', + 'FW_ID_DRV_CAP', 'FW_ID_FIRST', 'FW_ID_IMU_DRAM', + 'FW_ID_IMU_IRAM', 'FW_ID_ISP', 'FW_ID_MC', 'FW_ID_MES_KIQ', + 'FW_ID_MES_STACK', 'FW_ID_MES_THREAD1', 'FW_ID_MES_THREAD1_STACK', + 'FW_ID_MMSCH', 'FW_ID_PPTABLE', 'FW_ID_PSP_BL', 'FW_ID_PSP_DBG', 'FW_ID_PSP_INTF', 'FW_ID_PSP_KEYDB', 'FW_ID_PSP_SOC', 'FW_ID_PSP_SOSDRV', 'FW_ID_PSP_SPL', 'FW_ID_PSP_SYSDRV', 'FW_ID_PSP_TOC', 'FW_ID_REG_ACCESS_WHITELIST', 'FW_ID_RLC', @@ -2242,12 +2260,12 @@ __all__ = \ 'VRAM_TYPE_UNKNOWN', 'VRAM_TYPE__MAX', 'WR_BW0', 'amd_metrics_table_header_t', 'amdsmi_asic_info_t', 'amdsmi_bdf_t', 'amdsmi_bit_field_t', 'amdsmi_board_info_t', - 'amdsmi_clk_info_t', 'amdsmi_clk_type_t', - 'amdsmi_compute_partition_type_t', 'amdsmi_container_types_t', - 'amdsmi_counter_command_t', 'amdsmi_counter_value_t', - 'amdsmi_cpu_apb_disable', 'amdsmi_cpu_apb_enable', - 'amdsmi_cpusocket_handle', 'amdsmi_ddr_bw_metrics_t', - 'amdsmi_dev_compute_partition_get', + 'amdsmi_cache_flags_type_t', 'amdsmi_clk_info_t', + 'amdsmi_clk_type_t', 'amdsmi_compute_partition_type_t', + 'amdsmi_container_types_t', 'amdsmi_counter_command_t', + 'amdsmi_counter_value_t', 'amdsmi_cpu_apb_disable', + 'amdsmi_cpu_apb_enable', 'amdsmi_cpusocket_handle', + 'amdsmi_ddr_bw_metrics_t', 'amdsmi_dev_compute_partition_get', 'amdsmi_dev_compute_partition_reset', 'amdsmi_dev_compute_partition_set', 'amdsmi_dev_memory_partition_get',