53 lines
1.7 KiB
Diff
53 lines
1.7 KiB
Diff
From c5d4306792bb14eacf2192fe372dcb1b37f862f1 Mon Sep 17 00:00:00 2001
|
|
From: Muhammad Asif Manzoor <muhammad.asif.manzoor1@huawei.com>
|
|
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
|
|
|