From 071b0b22f23f643cbf68996308561b1c29f69535 Mon Sep 17 00:00:00 2001 From: "huanghe (AH)" Date: Wed, 4 Dec 2024 20:22:22 +0800 Subject: [PATCH] Improve extraction of CPU type information --- BiSheng-opetuner.spec | 9 +++- ...prove-extraction-of-CPU-type-informa.patch | 52 +++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 Driver-Improve-extraction-of-CPU-type-informa.patch diff --git a/BiSheng-opetuner.spec b/BiSheng-opetuner.spec index c6ebe34..77d33e7 100644 --- a/BiSheng-opetuner.spec +++ b/BiSheng-opetuner.spec @@ -1,11 +1,13 @@ Name: BiSheng-opentuner Version: 0.8.8 -Release: 1 +Release: 2 Summary: An Extensible Framework for Program Autotuning License: MIT URL: https://github.com/Huawei-CPLLab/bisheng-opentuner Source0: https://github.com/Huawei-CPLLab/bisheng-opentuner/archive/bisheng-opentuner.zip +Patch0001: Driver-Improve-extraction-of-CPU-type-informa.patch + BuildArch: noarch BuildRequires: python3-devel @@ -26,7 +28,7 @@ simultaneously, techniques which perform well will receive larger testing budget and techniques which perform poorly will be disabled. %prep -%autosetup -n %{name}-%{version} +%autosetup -p1 -n %{name}-%{version} sed -i 's/numpy>=1.12.1, <=1.23.5/numpy>=1.12.1/' requirements.txt sed -i 's/SQLAlchemy==1.4.49/SQLAlchemy/' requirements.txt sed -i 's/argparse>=1.2.1//' requirements.txt @@ -44,5 +46,8 @@ sed -i 's/argparse>=1.2.1//' requirements.txt %{python3_sitelib}/opentuner %changelog +* Wed Dec 04 2024 huanghe - 0.8.8-2 +- Patch0001 Improve extraction of CPU type information + * Wed Apr 24 2024 liyunfei - 0.8.8-1 - Package init \ No newline at end of file diff --git a/Driver-Improve-extraction-of-CPU-type-informa.patch b/Driver-Improve-extraction-of-CPU-type-informa.patch new file mode 100644 index 0000000..9328b37 --- /dev/null +++ b/Driver-Improve-extraction-of-CPU-type-informa.patch @@ -0,0 +1,52 @@ +From c5d4306792bb14eacf2192fe372dcb1b37f862f1 Mon Sep 17 00:00:00 2001 +From: Muhammad Asif Manzoor +Date: Mon, 29 Apr 2024 13:32:15 -0400 +Subject: [PATCH] [Driver] Improve extraction of CPU type information + +Use lscpu command to extract 'model name' for Linux OS if 'model name' is not +available in /proc/cpuinfo file; return 'unknown' otherwise. +--- + opentuner/measurement/driver.py | 27 ++++++++++++++++++++++----- + 1 file changed, 22 insertions(+), 5 deletions(-) + +diff --git a/opentuner/measurement/driver.py b/opentuner/measurement/driver.py +index 707b4ec..512bcb5 100644 +--- a/opentuner/measurement/driver.py ++++ b/opentuner/measurement/driver.py +@@ -221,11 +221,28 @@ class MeasurementDriver(DriverBase): + + + def _cputype(): +- try: +- return re.search(r"model name\s*:\s*([^\n]*)", +- open("/proc/cpuinfo").read()).group(1) +- except: +- pass ++ if os.name is "posix": ++ try: ++ return re.search( ++ r"model name\s*:\s*([^\n]*)", open("/proc/cpuinfo").read() ++ ).group(1) ++ except: ++ pass ++ try: ++ # AArch64 machines may not have 'model name' attribute in ++ # /proc/cpuinfo file. Using lscpu command to extract 'model name'. ++ import subprocess ++ ++ return re.search( ++ r"Model name\s*:\s*([^\n]*)", ++ subprocess.Popen(["lscpu"], stdout=subprocess.PIPE) ++ .communicate()[0] ++ .decode(), ++ ).group(1) ++ except: ++ log.warning("failed to get cpu type") ++ return "unknown" ++ + try: + # for OS X + import subprocess +-- +2.45.1.windows.1 + -- Gitee