Aligned cache property enum with Host

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


[ROCm/amdsmi commit: 703fdb0ed2]
Этот коммит содержится в:
Maisam Arif
2024-02-20 04:56:52 -06:00
родитель bc4d2bc383
Коммит c3bfdbe806
6 изменённых файлов: 59 добавлений и 56 удалений
+13 -7
Просмотреть файл
@@ -550,11 +550,17 @@ class AMDSMICommands():
static_dict['vram'] = vram_info
if args.cache:
try:
cach_info_list = amdsmi_interface.amdsmi_get_gpu_cache_info(args.gpu)
logging.debug(f"cache_info dictionary = {cach_info_list}")
cache_info_list = amdsmi_interface.amdsmi_get_gpu_cache_info(args.gpu)['cache']
logging.debug(f"cache_info dictionary = {cache_info_list}")
for index, cache_info in enumerate(cache_info_list):
new_cache_info = {"cache" : index}
new_cache_info.update(cache_info)
cache_info_list[index] = new_cache_info
if self.logger.is_human_readable_format():
cache_info_dict_format = {}
for cache_dict in cach_info_list:
for cache_dict in cache_info_list:
cache_index = "cache_" + str(cache_dict["cache"])
cache_info_dict_format[cache_index] = cache_dict
@@ -567,15 +573,15 @@ class AMDSMICommands():
# take cache_properties out of list -> display as string, removing brackets
cache_info_dict_format[cache_index]["cache_properties"] = ", ".join(cache_info_dict_format[cache_index]["cache_properties"])
cach_info_list = cache_info_dict_format
cache_info_list = cache_info_dict_format
logging.debug(f"After human_readable | cache_info = {cach_info_list}")
logging.debug(f"After human_readable | cache_info = {cache_info_list}")
except amdsmi_exception.AmdSmiLibraryException as e:
cach_info_list = "N/A"
cache_info_list = "N/A"
logging.debug("Failed to get cache info for gpu %s | %s", gpu_id, e.get_error_info())
static_dict['cache_info'] = cach_info_list
static_dict['cache_info'] = cache_info_list
if 'ras' in current_platform_args:
if args.ras:
ras_dict = {"eeprom_version": "N/A",
+7 -7
Просмотреть файл
@@ -541,17 +541,17 @@ typedef struct {
* @brief cache properties
*/
typedef enum {
AMDSMI_CACHE_PROPERTIES_ENABLED = 0x00000001,
AMDSMI_CACHE_PROPERTIES_DATA_CACHE = 0x00000002,
AMDSMI_CACHE_PROPERTIES_INST_CACHE = 0x00000004,
AMDSMI_CACHE_PROPERTIES_CPU_CACHE = 0x00000008,
AMDSMI_CACHE_PROPERTIES_SIMD_CACHE = 0x00000010,
} amdsmi_cache_properties_type_t;
AMDSMI_CACHE_PROPERTY_ENABLED = 0x00000001,
AMDSMI_CACHE_PROPERTY_DATA_CACHE = 0x00000002,
AMDSMI_CACHE_PROPERTY_INST_CACHE = 0x00000004,
AMDSMI_CACHE_PROPERTY_CPU_CACHE = 0x00000008,
AMDSMI_CACHE_PROPERTY_SIMD_CACHE = 0x00000010,
} amdsmi_cache_property_type_t;
typedef struct {
uint32_t num_cache_types;
struct cache_ {
uint32_t cache_properties; // amdsmi_cache_properties_type_t which is a bitmask
uint32_t cache_properties; // amdsmi_cache_property_type_t which is a bitmask
uint32_t cache_size; /* In KB */
uint32_t cache_level;
uint32_t max_num_cu_shared; /* Indicates how many Compute Units share this cache instance */
+4 -8
Просмотреть файл
@@ -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)
```
+9 -8
Просмотреть файл
@@ -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
Просмотреть файл
@@ -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',
+4 -4
Просмотреть файл
@@ -448,13 +448,13 @@ amdsmi_status_t amdsmi_get_gpu_cache_info(
// convert from sysfs type to CRAT type(HSA Cache Affinity type)
info->cache[i].cache_properties = 0;
if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_DATA)
info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTIES_DATA_CACHE;
info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTY_DATA_CACHE;
if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_INSTRUCTION)
info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTIES_INST_CACHE;
info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTY_INST_CACHE;
if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_CPU)
info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTIES_CPU_CACHE;
info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTY_CPU_CACHE;
if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_HSACU)
info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTIES_SIMD_CACHE;
info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTY_SIMD_CACHE;
info->cache[i].cache_size = rsmi_info.cache[i].cache_size_kb;
info->cache[i].cache_level = rsmi_info.cache[i].cache_level;