SWDEV-436533 [CLI/Python API] Align Cache Info BM UI to Host

- [CLI] Refactored cache info to display
cache flags as "cache_properties" names.
Names are displayed as a list of comma-separated
cache type strings. Previously, values
were shown one by one as ENABLED.

ex.
CACHE_PROPERTIES = <a,b,c>

- [JSON] mirrors CLI fields.
No longer display "cache_flags", renamed
field as "cache_properties" dictionary. This
allows users to better understand the
list of names provided.

- [Python API] Updated amdsmi_get_gpu_cache_info
to mirror Host return.

README.md - updated to reflect all changes.

Change-Id: Ife2ef5adcef30058937d1376efb01749e45c02fb
Signed-off-by: Charis Poag <Charis.Poag@amd.com>


[ROCm/amdsmi commit: fe86afed8c]
Cette révision appartient à :
Charis Poag
2024-01-17 16:28:39 -06:00
révisé par Maisam Arif
Parent 6dc774c275
révision f2587543e8
4 fichiers modifiés avec 87 ajouts et 73 suppressions
+4 -5
Voir le fichier
@@ -475,13 +475,12 @@ Output: Dictionary of Dictionaries containing cache information
Field | Description
---|---
`cache #` | upt 10 caches will be available
`cache_index` | cache index - up to 10 caches will be available
`cache_flags` | 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
`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
`max_num_cu_shared` | max number of compute units shared
`num_cache_instance` | number of cache instances
Exceptions that can be thrown by `amdsmi_get_gpu_cache_info` function:
+24 -8
Voir le fichier
@@ -22,7 +22,7 @@
import ctypes
import re
from typing import Union, Any, Dict, List, Tuple
from enum import IntEnum
from enum import IntEnum, Enum
from collections.abc import Iterable
from . import amdsmi_wrapper
@@ -357,6 +357,11 @@ class AmdSmiProcessorType(IntEnum):
NON_AMD_GPU = amdsmi_wrapper.NON_AMD_GPU
NON_AMD_CPU = amdsmi_wrapper.NON_AMD_CPU
class AmdSmiCacheTypeNames(Enum):
DATA_CACHE = 2
INST_CACHE = 4
CPU_CACHE = 8
SIMD_CACHE = 16
class AmdSmiEventReader:
def __init__(
@@ -1626,15 +1631,26 @@ def amdsmi_get_gpu_cache_info(
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_flag_list = []
if (data_cache):
cache_flag_list.append(
AmdSmiCacheTypeNames(amdsmi_wrapper.CACHE_FLAGS_DATA_CACHE).name)
if (inst_cache):
cache_flag_list.append(
AmdSmiCacheTypeNames(amdsmi_wrapper.CACHE_FLAGS_INST_CACHE).name)
if (cpu_cache):
cache_flag_list.append(
AmdSmiCacheTypeNames(amdsmi_wrapper.CACHE_FLAGS_CPU_CACHE).name)
if (simd_cache):
cache_flag_list.append(
AmdSmiCacheTypeNames(amdsmi_wrapper.CACHE_FLAGS_SIMD_CACHE).name)
cache_info_dict[f"cache {cache_index}"] = {
"cache_flags": cache_flag_list,
"cache_size": cache_size,
"cache_level": cache_level,
"max_num_cu_shared": max_num_cu_shared,
"num_cache_instance": num_cache_instance}
if (data_cache): cache_info_dict[f"cache {cache_index}"]["data_cache"] = data_cache
if (inst_cache): cache_info_dict[f"cache {cache_index}"]["inst_cache"] = inst_cache
if (cpu_cache): cache_info_dict[f"cache {cache_index}"]["cpu_cache"] = cpu_cache
if (simd_cache): cache_info_dict[f"cache {cache_index}"]["simd_cache"] = simd_cache
"num_cache_instance": num_cache_instance
}
if cache_info_dict == {}:
raise AmdSmiLibraryException(amdsmi_wrapper.AMDSMI_STATUS_NO_DATA)