Skip to content

Commit

Permalink
Merge pull request #5894 from AYUSHJAIN951/amd_cpu_changes
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Richter <jarichte@redhat.com>
  • Loading branch information
richtja committed Apr 3, 2024
2 parents 76199b2 + 241c9cd commit af38b8e
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion avocado/utils/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,13 @@ def get_family():
arch = get_arch()
if arch == "x86_64" or arch == "i386":
if get_vendor() == "amd":
raise NotImplementedError
cpu_info = _get_info()
pattern = r"cpu family\s*:"
for line in cpu_info:
line = line.decode("utf-8")
if re.search(pattern, line):
family = int(line.split(":")[1])
return family
try:
# refer below links for microarchitectures names
# https://en.wikipedia.org/wiki/List_of_Intel_CPU_microarchitectures
Expand Down Expand Up @@ -276,6 +282,54 @@ def get_family():
return family


def get_model():
"""
Get model of cpu
"""
arch = get_arch()
if arch == "x86_64":
cpu_info = _get_info()
pattern = r"model\s*:"
for line in cpu_info:
line = line.decode("utf-8")
if re.search(pattern, line):
model = int(line.split(":")[1])
return model
else:
raise NotImplementedError


def get_x86_amd_zen(family=None, model=None):
"""
:param family: AMD family
:type family: int
:param model: AMD model
:type model: int
:return: AMD Zen
:rtype: int
"""

x86_amd_zen = {
0x17: {
1: [(0x00, 0x2F), (0x50, 0x5F)],
2: [(0x30, 0x4F), (0x60, 0x7F), (0x90, 0x91), (0xA0, 0xAF)],
},
0x19: {3: [(0x00, 0x0F), (0x20, 0x5F)], 4: [(0x10, 0x1F), (0x60, 0xAF)]},
0x1A: {5: [(0x00, 0x0F), (0x20, 0x2F), (0x40, 0x4F), (0x70, 0x7F)]},
}
if not family:
family = get_family()
if not model:
model = get_model()

for _family, _zen_model in x86_amd_zen.items():
if _family == family:
for _zen, _model in _zen_model.items():
if any(lower <= model <= upper for (lower, upper) in _model):
return _zen


def online_list():
"""Reports a list of indexes of the online cpus."""
cpus = []
Expand Down

0 comments on commit af38b8e

Please sign in to comment.