Aligned cache property enum with Host

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


[ROCm/amdsmi commit: 703fdb0ed2]
This commit is contained in:
Maisam Arif
2024-02-20 04:56:52 -06:00
parent bc4d2bc383
commit c3bfdbe806
6 changed files with 59 additions and 56 deletions
+4 -8
View File
@@ -476,8 +476,7 @@ Schema:
```JSON
{
cache: {"type" : "number"},
cache_properties:
cache_properties:
{
"type" : "array",
"items" : {"type" : "string"}
@@ -491,7 +490,6 @@ Schema:
Field | Description
---|---
`cache` | cache index from 0-9
`cache_properties` | list of up to 4 cache property type strings. Ex. data ("DATA_CACHE"), instruction ("INST_CACHE"), CPU ("CPU_CACHE"), or SIMD ("SIMD_CACHE").
`cache_size` | size of cache in KB
`cache_level` | level of cache
@@ -515,13 +513,11 @@ try:
for device in devices:
cache_info = amdsmi_get_gpu_cache_info(device)
for cache_index, cache_values in cache_info.items():
print(cache_index)
print(cache_values['cache_properties'])
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'])
print(cache_values['max_num_cu_shared'])
print(cache_values['num_cache_instance'])
except AmdSmiException as e:
print(e)
```
@@ -1670,7 +1670,6 @@ def amdsmi_get_gpu_cache_info(
for cache_index in range(cache_info_struct.num_cache_types):
# Put cache_properties at the start of the dictionary for readability
cache_dict = {
"cache": cache_index,
"cache_properties": [], # This will be a list of strings
"cache_size": cache_info_struct.cache[cache_index].cache_size,
"cache_level": cache_info_struct.cache[cache_index].cache_level,
@@ -1680,17 +1679,17 @@ def amdsmi_get_gpu_cache_info(
# Check against cache properties bitmask
cache_properties = cache_info_struct.cache[cache_index].cache_properties
data_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTIES_DATA_CACHE
inst_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTIES_INST_CACHE
cpu_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTIES_CPU_CACHE
simd_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTIES_SIMD_CACHE
data_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTY_DATA_CACHE
inst_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTY_INST_CACHE
cpu_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTY_CPU_CACHE
simd_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTY_SIMD_CACHE
cache_properties_status = [data_cache, inst_cache, cpu_cache, simd_cache]
cache_property_list = []
for cache_property in cache_properties_status:
if cache_property:
property_name = amdsmi_wrapper.amdsmi_cache_properties_type_t__enumvalues[cache_property]
property_name = property_name.replace("AMDSMI_CACHE_PROPERTIES_", "")
property_name = amdsmi_wrapper.amdsmi_cache_property_type_t__enumvalues[cache_property]
property_name = property_name.replace("AMDSMI_CACHE_PROPERTY_", "")
cache_property_list.append(property_name)
cache_dict["cache_properties"] = cache_property_list
@@ -1699,7 +1698,9 @@ def amdsmi_get_gpu_cache_info(
if not cache_info_list:
raise AmdSmiLibraryException(amdsmi_wrapper.AMDSMI_STATUS_NO_DATA)
return cache_info_list
return {
"cache": cache_info_list
}
def amdsmi_get_gpu_vbios_info(
+22 -22
View File
@@ -813,20 +813,20 @@ struct_amdsmi_vbios_info_t._fields_ = [
amdsmi_vbios_info_t = struct_amdsmi_vbios_info_t
# values for enumeration 'amdsmi_cache_properties_type_t'
amdsmi_cache_properties_type_t__enumvalues = {
1: 'AMDSMI_CACHE_PROPERTIES_ENABLED',
2: 'AMDSMI_CACHE_PROPERTIES_DATA_CACHE',
4: 'AMDSMI_CACHE_PROPERTIES_INST_CACHE',
8: 'AMDSMI_CACHE_PROPERTIES_CPU_CACHE',
16: 'AMDSMI_CACHE_PROPERTIES_SIMD_CACHE',
# values for enumeration 'amdsmi_cache_property_type_t'
amdsmi_cache_property_type_t__enumvalues = {
1: 'AMDSMI_CACHE_PROPERTY_ENABLED',
2: 'AMDSMI_CACHE_PROPERTY_DATA_CACHE',
4: 'AMDSMI_CACHE_PROPERTY_INST_CACHE',
8: 'AMDSMI_CACHE_PROPERTY_CPU_CACHE',
16: 'AMDSMI_CACHE_PROPERTY_SIMD_CACHE',
}
AMDSMI_CACHE_PROPERTIES_ENABLED = 1
AMDSMI_CACHE_PROPERTIES_DATA_CACHE = 2
AMDSMI_CACHE_PROPERTIES_INST_CACHE = 4
AMDSMI_CACHE_PROPERTIES_CPU_CACHE = 8
AMDSMI_CACHE_PROPERTIES_SIMD_CACHE = 16
amdsmi_cache_properties_type_t = ctypes.c_uint32 # enum
AMDSMI_CACHE_PROPERTY_ENABLED = 1
AMDSMI_CACHE_PROPERTY_DATA_CACHE = 2
AMDSMI_CACHE_PROPERTY_INST_CACHE = 4
AMDSMI_CACHE_PROPERTY_CPU_CACHE = 8
AMDSMI_CACHE_PROPERTY_SIMD_CACHE = 16
amdsmi_cache_property_type_t = ctypes.c_uint32 # enum
class struct_amdsmi_gpu_cache_info_t(Structure):
pass
@@ -2308,14 +2308,14 @@ amdsmi_get_esmi_err_msg.restype = amdsmi_status_t
amdsmi_get_esmi_err_msg.argtypes = [amdsmi_status_t, ctypes.POINTER(ctypes.POINTER(ctypes.c_char))]
__all__ = \
['AGG_BW0', 'AMDSMI_ARG_PTR_NULL', 'AMDSMI_AVERAGE_POWER',
'AMDSMI_CACHE_PROPERTIES_CPU_CACHE',
'AMDSMI_CACHE_PROPERTIES_DATA_CACHE',
'AMDSMI_CACHE_PROPERTIES_ENABLED',
'AMDSMI_CACHE_PROPERTIES_INST_CACHE',
'AMDSMI_CACHE_PROPERTIES_SIMD_CACHE',
'AMDSMI_CARD_FORM_FACTOR_OAM', 'AMDSMI_CARD_FORM_FACTOR_PCIE',
'AMDSMI_CARD_FORM_FACTOR_UNKNOWN', 'AMDSMI_CNTR_CMD_START',
'AMDSMI_CNTR_CMD_STOP', 'AMDSMI_COARSE_GRAIN_GFX_ACTIVITY',
'AMDSMI_CACHE_PROPERTY_CPU_CACHE',
'AMDSMI_CACHE_PROPERTY_DATA_CACHE',
'AMDSMI_CACHE_PROPERTY_ENABLED',
'AMDSMI_CACHE_PROPERTY_INST_CACHE',
'AMDSMI_CACHE_PROPERTY_SIMD_CACHE', 'AMDSMI_CARD_FORM_FACTOR_OAM',
'AMDSMI_CARD_FORM_FACTOR_PCIE', 'AMDSMI_CARD_FORM_FACTOR_UNKNOWN',
'AMDSMI_CNTR_CMD_START', 'AMDSMI_CNTR_CMD_STOP',
'AMDSMI_COARSE_GRAIN_GFX_ACTIVITY',
'AMDSMI_COARSE_GRAIN_MEM_ACTIVITY', 'AMDSMI_CURRENT_POWER',
'AMDSMI_DEV_PERF_LEVEL_AUTO', 'AMDSMI_DEV_PERF_LEVEL_DETERMINISM',
'AMDSMI_DEV_PERF_LEVEL_FIRST', 'AMDSMI_DEV_PERF_LEVEL_HIGH',
@@ -2477,7 +2477,7 @@ __all__ = \
'VRAM_TYPE_GDDR6', 'VRAM_TYPE_HBM', '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_cache_properties_type_t',
'amdsmi_board_info_t', 'amdsmi_cache_property_type_t',
'amdsmi_card_form_factor_t', 'amdsmi_clk_info_t',
'amdsmi_clk_type_t', 'amdsmi_compute_partition_type_t',
'amdsmi_container_types_t', 'amdsmi_counter_command_t',