diff --git a/iprbench/autoparams.py b/iprbench/autoparams.py index f4cafc7..03ea196 100644 --- a/iprbench/autoparams.py +++ b/iprbench/autoparams.py @@ -1,6 +1,6 @@ from datetime import datetime from .core import IAutoParam, BenchParam, BenchParamType -from .main import __version__ as iprbench_version +from .version import __version__ as iprbench_version import socket import subprocess import re @@ -76,13 +76,36 @@ class CpuModel(IAutoParam): cpu_model_name: the name of a cpu as seen in /proc/cpuinfo (eg 'Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz') return: a compact identifier of the cpu model without spaces (eg 'intel_core_i5_8350u' (the frequency is implicit, as this model only operates at 1.7 Ghz)) """ - cpu_model_id = None match = re.match(r'Intel\(R\) Core\(TM\) i(?P[357])-(?P[0-9]+[U]) CPU @ [0-9]+\.[0-9]+GHz', cpu_model_name) if match: - cpu_model_id = f'intel_core_i{match["major_id"]}_{match["minor_id"].lower()}' - else: - assert False, f'unhandled cpu model name: "{cpu_model_name}"' - return cpu_model_id + return f'intel_core_i{match["major_id"]}_{match["minor_id"].lower()}' + + # eg "Intel(R) Xeon(R) Gold 6248R CPU @ 3.00GHz" + match = re.match(r'Intel\(R\) Xeon\(R\) Gold +(?P[^ ]+) +CPU +@ [0-9]+\.[0-9]+GHz', cpu_model_name) + if match: + return f'intel_xeon_gold_{match["xeon_id"].lower()}' + + # eg "Intel(R) Xeon(R) CPU X5650 @ 2.67GHz" + # eg 'Intel(R) Xeon(R) CPU E5-2660 0 @ 2.20GHz': 'intel_xeon_e5-2660', + # eg 'Intel(R) Xeon(R) CPU E5-2660 v2 @ 2.20GHz': 'intel_xeon_e5-2660v2' + # eg'Intel(R) Xeon(R) CPU E5-2660 v4 @ 2.00GHz': 'intel_xeon_e5-2660v4' + match = re.match(r'Intel\(R\) Xeon\(R\) CPU +(?P[^ ]+) +(?P(?:[^@ ]+ +|))@ [0-9]+\.[0-9]+GHz', cpu_model_name) + if match: + cpu_id = f'intel_xeon_{match["xeon_id"].lower()}' + version = match['version'] + m2 = re.match(r'^v(?P[0-9]+) ', version) + if m2: + cpu_id += f'v{m2["version_number"]}' + return cpu_id + + # eg "AMD EPYC 7282 16-Core Processor" + match = re.match(r'AMD EPYC (?P[0-9a-z]+) (?P[0-9]+)-Core Processor', cpu_model_name) + if match: + return f'amd_epyc_{match["epyc_model_id"].lower()}' + + assert False, f'unhandled cpu model name: "{cpu_model_name}"' + + return None def get_value(self) -> BenchParamType: # completed_process = subprocess.run('grep "^model name +:" /proc/cpuinfo | head -1 | sed "s/model name *: //"', shell=True, check=True, capture_output=True) diff --git a/iprbench/main.py b/iprbench/main.py index 39e7a5c..4b92066 100644 --- a/iprbench/main.py +++ b/iprbench/main.py @@ -1,5 +1,3 @@ -__version__ = '0.0.2' - from .core import BenchmarkId, IBenchmark, ResultsDbFactory from .benchmarks.hibench import HiBench from .benchmarks.mamul1 import MaMul1 diff --git a/iprbench/version.py b/iprbench/version.py new file mode 100644 index 0000000..ffcc925 --- /dev/null +++ b/iprbench/version.py @@ -0,0 +1 @@ +__version__ = '0.0.3' diff --git a/pyproject.toml b/pyproject.toml index 1c9e71b..5c47d4e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ Repository = "https://github.com/g-raffy/starbench" packages = ["iprbench", "iprbench.benchmarks", "iprbench.resultsdb"] [tool.setuptools.dynamic] -version = {attr = "iprbench.main.__version__"} +version = {attr = "iprbench.version.__version__"} [tool.setuptools.package-data] iprbench = ["resources/**/*"] diff --git a/test/test_cpu.py b/test/test_cpu.py new file mode 100644 index 0000000..4f21269 --- /dev/null +++ b/test/test_cpu.py @@ -0,0 +1,45 @@ +"""test all benchmarks +""" +import unittest +import logging +from pathlib import Path +from iprbench.autoparams import CpuModel + + +class CpuTestCase(unittest.TestCase): + + results_root_dir: Path + + def setUp(self) -> None: # pylint: disable=useless-parent-delegation + return super().setUp() + + def test_cpu(self): + # amd_epyc_7282 + # amd_epyc_7282 + # intel_xeon_x5550 + # intel_xeon_x5650 + # intel_xeon_e5-2660 + # intel_xeon_e5-2660v2 + # intel_xeon_e5-2660v4 + # intel_xeon_gold_5220 + # intel_xeon_gold_6140 + # intel_xeon_gold_6154 + # intel_xeon_gold_6226r + # intel_xeon_gold_6248r + ipr_cpus_id = { + r'Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz': 'intel_core_i5_8350u', + r'Intel(R) Xeon(R) CPU X5650 @ 2.67GHz': 'intel_xeon_x5650', + r'Intel(R) Xeon(R) CPU E5-2660 0 @ 2.20GHz': 'intel_xeon_e5-2660', + r'Intel(R) Xeon(R) CPU E5-2660 v2 @ 2.20GHz': 'intel_xeon_e5-2660v2', + r'Intel(R) Xeon(R) CPU E5-2660 v4 @ 2.00GHz': 'intel_xeon_e5-2660v4', + r'Intel(R) Xeon(R) Gold 6248R CPU @ 3.00GHz': 'intel_xeon_gold_6248r', + r'AMD EPYC 7282 16-Core Processor': 'amd_epyc_7282', + r'AMD EPYC 7452 32-Core Processor': 'amd_epyc_7452', + } + for cpuinfo_id, short_id in ipr_cpus_id.items(): + self.assertEqual(CpuModel.model_name_to_cpu_model_id(cpuinfo_id), short_id) + + +if __name__ == '__main__': + logging.basicConfig(level=logging.DEBUG) + unittest.main()