SWDEV-417117 - Added Cache Flags

Signed-off-by: Maisam Arif <maisarif@amd.com>
Change-Id: I78836ba5f87c2859b82f17a7564df6f99ac77ad7


[ROCm/amdsmi commit: aeef485034]
This commit is contained in:
Maisam Arif
2023-11-02 05:38:44 -05:00
والد e05f594cba
کامیت cf0098c16f
4فایلهای تغییر یافته به همراه68 افزوده شده و 24 حذف شده
@@ -466,9 +466,18 @@ class AMDSMICommands():
if args.cache: if args.cache:
try: try:
cache_info = amdsmi_interface.amdsmi_get_gpu_cache_info(args.gpu) 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(): if self.logger.is_human_readable_format():
for _ , cache_values in cache_info.items(): for _ , cache_values in cache_info.items():
cache_values['cache_size'] = f"{cache_values['cache_size']} KB" cache_values['cache_size'] = f"{cache_values['cache_size']} KB"
except amdsmi_exception.AmdSmiLibraryException as e: except amdsmi_exception.AmdSmiLibraryException as e:
cache_info = "N/A" cache_info = "N/A"
logging.debug("Failed to get cache info for gpu %s | %s", gpu_id, e.get_error_info()) logging.debug("Failed to get cache info for gpu %s | %s", gpu_id, e.get_error_info())
@@ -478,6 +478,10 @@ Field | Description
`cache #` | upt 10 caches will be available `cache #` | upt 10 caches will be available
`cache_size` | size of cache in KB `cache_size` | size of cache in KB
`cache_level` | level of cache `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: Exceptions that can be thrown by `amdsmi_get_gpu_cache_info` function:
@@ -499,6 +503,10 @@ try:
print(cache_index) print(cache_index)
print(cache_values['cache_size']) print(cache_values['cache_size'])
print(cache_values['cache_level']) 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: except AmdSmiException as e:
print(e) print(e)
``` ```
@@ -991,7 +991,7 @@ def amdsmi_get_gpu_vram_info(
def amdsmi_get_gpu_cache_info( def amdsmi_get_gpu_cache_info(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle, 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): if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle):
raise AmdSmiParameterException( raise AmdSmiParameterException(
processor_handle, amdsmi_wrapper.amdsmi_processor_handle 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): for cache_index in range(cache_info.num_cache_types):
cache_size = cache_info.cache[cache_index].cache_size_kb cache_size = cache_info.cache[cache_index].cache_size_kb
cache_level = cache_info.cache[cache_index].cache_level 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_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 return cache_info_dict
@@ -751,6 +751,21 @@ struct_amdsmi_vbios_info_t._fields_ = [
] ]
amdsmi_vbios_info_t = struct_amdsmi_vbios_info_t 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): class struct_amdsmi_gpu_cache_info_t(Structure):
pass pass
@@ -761,6 +776,7 @@ struct_cache_._pack_ = 1 # source:False
struct_cache_._fields_ = [ struct_cache_._fields_ = [
('cache_size_kb', ctypes.c_uint32), ('cache_size_kb', ctypes.c_uint32),
('cache_level', ctypes.c_uint32), ('cache_level', ctypes.c_uint32),
('flags', ctypes.c_uint32),
('reserved', ctypes.c_uint32 * 3), ('reserved', ctypes.c_uint32 * 3),
] ]
@@ -2193,22 +2209,24 @@ __all__ = \
'AMDSMI_VRAM_VENDOR__WINBOND', 'AMDSMI_XGMI_STATUS_ERROR', 'AMDSMI_VRAM_VENDOR__WINBOND', 'AMDSMI_XGMI_STATUS_ERROR',
'AMDSMI_XGMI_STATUS_MULTIPLE_ERRORS', 'AMDSMI_XGMI_STATUS_MULTIPLE_ERRORS',
'AMDSMI_XGMI_STATUS_NO_ERRORS', 'AMD_APU', 'AMD_CPU', 'AMDSMI_XGMI_STATUS_NO_ERRORS', 'AMD_APU', 'AMD_CPU',
'AMD_CPU_CORE', 'AMD_GPU', 'CLK_TYPE_DCEF', 'CLK_TYPE_DCLK0', 'AMD_CPU_CORE', 'AMD_GPU', 'CACHE_FLAGS_CPU_CACHE',
'CLK_TYPE_DCLK1', 'CLK_TYPE_DF', 'CLK_TYPE_FIRST', 'CLK_TYPE_GFX', 'CACHE_FLAGS_DATA_CACHE', 'CACHE_FLAGS_ENABLED',
'CLK_TYPE_MEM', 'CLK_TYPE_PCIE', 'CLK_TYPE_SOC', 'CLK_TYPE_SYS', 'CACHE_FLAGS_INST_CACHE', 'CACHE_FLAGS_SIMD_CACHE',
'CLK_TYPE_VCLK0', 'CLK_TYPE_VCLK1', 'CLK_TYPE__MAX', 'CLK_TYPE_DCEF', 'CLK_TYPE_DCLK0', 'CLK_TYPE_DCLK1',
'COMPUTE_PARTITION_CPX', 'COMPUTE_PARTITION_DPX', 'CLK_TYPE_DF', 'CLK_TYPE_FIRST', 'CLK_TYPE_GFX', 'CLK_TYPE_MEM',
'COMPUTE_PARTITION_INVALID', 'COMPUTE_PARTITION_QPX', 'CLK_TYPE_PCIE', 'CLK_TYPE_SOC', 'CLK_TYPE_SYS', 'CLK_TYPE_VCLK0',
'COMPUTE_PARTITION_SPX', 'COMPUTE_PARTITION_TPX', 'CLK_TYPE_VCLK1', 'CLK_TYPE__MAX', 'COMPUTE_PARTITION_CPX',
'CONTAINER_DOCKER', 'CONTAINER_LXC', 'FW_ID_ASD', 'FW_ID_CP_CE', 'COMPUTE_PARTITION_DPX', 'COMPUTE_PARTITION_INVALID',
'FW_ID_CP_ME', 'FW_ID_CP_MEC1', 'FW_ID_CP_MEC2', 'COMPUTE_PARTITION_QPX', 'COMPUTE_PARTITION_SPX',
'FW_ID_CP_MEC_JT1', 'FW_ID_CP_MEC_JT2', 'FW_ID_CP_MES', 'COMPUTE_PARTITION_TPX', 'CONTAINER_DOCKER', 'CONTAINER_LXC',
'FW_ID_CP_PFP', 'FW_ID_CP_PM4', 'FW_ID_DFC', 'FW_ID_DMCU', 'FW_ID_ASD', 'FW_ID_CP_CE', 'FW_ID_CP_ME', 'FW_ID_CP_MEC1',
'FW_ID_DMCU_ERAM', 'FW_ID_DMCU_ISR', 'FW_ID_DRV_CAP', 'FW_ID_CP_MEC2', 'FW_ID_CP_MEC_JT1', 'FW_ID_CP_MEC_JT2',
'FW_ID_FIRST', 'FW_ID_IMU_DRAM', 'FW_ID_IMU_IRAM', 'FW_ID_ISP', 'FW_ID_CP_MES', 'FW_ID_CP_PFP', 'FW_ID_CP_PM4', 'FW_ID_DFC',
'FW_ID_MC', 'FW_ID_MES_KIQ', 'FW_ID_MES_STACK', 'FW_ID_DMCU', 'FW_ID_DMCU_ERAM', 'FW_ID_DMCU_ISR',
'FW_ID_MES_THREAD1', 'FW_ID_MES_THREAD1_STACK', 'FW_ID_MMSCH', 'FW_ID_DRV_CAP', 'FW_ID_FIRST', 'FW_ID_IMU_DRAM',
'FW_ID_PPTABLE', 'FW_ID_PSP_BL', 'FW_ID_PSP_DBG', '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_INTF', 'FW_ID_PSP_KEYDB', 'FW_ID_PSP_SOC',
'FW_ID_PSP_SOSDRV', 'FW_ID_PSP_SPL', 'FW_ID_PSP_SYSDRV', 'FW_ID_PSP_SOSDRV', 'FW_ID_PSP_SPL', 'FW_ID_PSP_SYSDRV',
'FW_ID_PSP_TOC', 'FW_ID_REG_ACCESS_WHITELIST', 'FW_ID_RLC', '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', 'VRAM_TYPE_UNKNOWN', 'VRAM_TYPE__MAX', 'WR_BW0',
'amd_metrics_table_header_t', 'amdsmi_asic_info_t', 'amd_metrics_table_header_t', 'amdsmi_asic_info_t',
'amdsmi_bdf_t', 'amdsmi_bit_field_t', 'amdsmi_board_info_t', 'amdsmi_bdf_t', 'amdsmi_bit_field_t', 'amdsmi_board_info_t',
'amdsmi_clk_info_t', 'amdsmi_clk_type_t', 'amdsmi_cache_flags_type_t', 'amdsmi_clk_info_t',
'amdsmi_compute_partition_type_t', 'amdsmi_container_types_t', 'amdsmi_clk_type_t', 'amdsmi_compute_partition_type_t',
'amdsmi_counter_command_t', 'amdsmi_counter_value_t', 'amdsmi_container_types_t', 'amdsmi_counter_command_t',
'amdsmi_cpu_apb_disable', 'amdsmi_cpu_apb_enable', 'amdsmi_counter_value_t', 'amdsmi_cpu_apb_disable',
'amdsmi_cpusocket_handle', 'amdsmi_ddr_bw_metrics_t', 'amdsmi_cpu_apb_enable', 'amdsmi_cpusocket_handle',
'amdsmi_dev_compute_partition_get', 'amdsmi_ddr_bw_metrics_t', 'amdsmi_dev_compute_partition_get',
'amdsmi_dev_compute_partition_reset', 'amdsmi_dev_compute_partition_reset',
'amdsmi_dev_compute_partition_set', 'amdsmi_dev_compute_partition_set',
'amdsmi_dev_memory_partition_get', 'amdsmi_dev_memory_partition_get',