added the following automatic parameters (parameters common to all benchmarks):

- host_id (host serial number)
- num_cpus
- iprbench_version

(took inspiration from [https://git.ipr.univ-rennes.fr/cellinfo/maco/src/branch/main/Libs/Benchmark.bash])

work related to [https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=3958]
This commit is contained in:
Guillaume Raffy 2024-11-13 17:42:01 +01:00
parent 59a5109ed9
commit 3d8a0ff4ad
2 changed files with 45 additions and 3 deletions

View File

@ -1,5 +1,6 @@
from datetime import datetime from datetime import datetime
from .core import IAutoParam, BenchParam, BenchParamType from .core import IAutoParam, BenchParam, BenchParamType
from .main import __version__ as iprbench_version
import socket import socket
import subprocess import subprocess
import re import re
@ -15,6 +16,30 @@ class MeasurementTime(IAutoParam):
return datetime.now() return datetime.now()
class IprBenchVersion(IAutoParam):
def __init__(self):
bench_param = BenchParam('ipr_bench_version', BenchParam.Type.PARAM_TYPE_STRING, 'the version of iprbench used for this measurement')
super().__init__(bench_param)
def get_value(self) -> BenchParamType:
return iprbench_version
class HostId(IAutoParam):
def __init__(self):
bench_param = BenchParam('host_id', BenchParam.Type.PARAM_TYPE_STRING, 'the serial number of the host running the benchmark')
super().__init__(bench_param)
def get_value(self) -> BenchParamType:
serial_number = '<unknown>'
completed_process = subprocess.run(r"dmidecode | grep -A4 '^System Information' | grep 'Serial Number' | sed 's/^\s*Serial Number: //'; exit $PIPESTATUS[0]", check=False, shell=True, capture_output=True)
if completed_process.returncode == 0:
serial_number = completed_process.stdout.decode(encoding='utf-8').split('\n')[0]
return serial_number
class HostFqdn(IAutoParam): class HostFqdn(IAutoParam):
def __init__(self): def __init__(self):
@ -25,6 +50,20 @@ class HostFqdn(IAutoParam):
return socket.getfqdn() return socket.getfqdn()
class NumCpus(IAutoParam):
def __init__(self):
bench_param = BenchParam('num_cpus', BenchParam.Type.PARAM_TYPE_INT, 'the number of cpus on the benchmarked system')
super().__init__(bench_param)
def get_value(self) -> BenchParamType:
num_cpus = 0
completed_process = subprocess.run(r"cat /proc/cpuinfo | awk 'BEGIN { maxid=0; } /^physical id/ {if ($4 > maxid) { maxid = $4 };} END {print maxid+1;}'", check=False, shell=True, capture_output=True)
if completed_process.returncode == 0:
num_cpus = int(completed_process.stdout.decode(encoding='utf-8').split('\n')[0])
return num_cpus
class CpuModel(IAutoParam): class CpuModel(IAutoParam):
def __init__(self): def __init__(self):

View File

@ -1,3 +1,5 @@
__version__ = '0.0.1'
from .core import BenchmarkId, IBenchmark, ResultsDbFactory from .core import BenchmarkId, IBenchmark, ResultsDbFactory
from .benchmarks.hibench import HiBench from .benchmarks.hibench import HiBench
from .benchmarks.mamul1 import MaMul1 from .benchmarks.mamul1 import MaMul1
@ -5,14 +7,12 @@ from .resultsdb.tsvresultsdb import TsvResultsDbCreator
from .resultsdb.sqlresultsdb import SqliteResultsDbCreator, SqlServerResultsDbCreator from .resultsdb.sqlresultsdb import SqliteResultsDbCreator, SqlServerResultsDbCreator
from .util import Singleton from .util import Singleton
from .autoparams import MeasurementTime, HostFqdn, CpuModel from .autoparams import MeasurementTime, HostFqdn, NumCpus, CpuModel, IprBenchVersion, HostId
import logging import logging
import argparse import argparse
from pathlib import Path from pathlib import Path
import json import json
__version__ = '0.0.1'
class BenchmarkFactory(metaclass=Singleton): class BenchmarkFactory(metaclass=Singleton):
@ -60,7 +60,10 @@ def main():
results_db = ResultsDbFactory().create_resultsdb(resultsdb_params['type'], resultsdb_params) results_db = ResultsDbFactory().create_resultsdb(resultsdb_params['type'], resultsdb_params)
results_db.add_auto_param(MeasurementTime()) results_db.add_auto_param(MeasurementTime())
results_db.add_auto_param(IprBenchVersion())
results_db.add_auto_param(HostId())
results_db.add_auto_param(HostFqdn()) results_db.add_auto_param(HostFqdn())
results_db.add_auto_param(NumCpus())
results_db.add_auto_param(CpuModel()) results_db.add_auto_param(CpuModel())
results_table = results_db.get_table(benchmark) results_table = results_db.get_table(benchmark)