From 33133d68286949a46e6d30092ed64dea548988ef Mon Sep 17 00:00:00 2001 From: Guillaume Raffy Date: Thu, 21 Nov 2024 17:04:55 +0100 Subject: [PATCH] v0.0.7 - added blas_library parameter to hibench benchmark, thus allowing the user to choose the blas library to use work related to [https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=3958] --- iprbench/benchmarks/hibench.py | 22 ++++++++++++---------- iprbench/benchmarks/mamul1.py | 16 +++------------- iprbench/cmakeutils.py | 12 ++++++++++++ iprbench/version.py | 2 +- 4 files changed, 28 insertions(+), 24 deletions(-) create mode 100644 iprbench/cmakeutils.py diff --git a/iprbench/benchmarks/hibench.py b/iprbench/benchmarks/hibench.py index 0c1e916..6fd8ff2 100644 --- a/iprbench/benchmarks/hibench.py +++ b/iprbench/benchmarks/hibench.py @@ -3,6 +3,7 @@ from pathlib import Path import subprocess import shutil from ..core import IBenchmark, BenchParam, BenchmarkConfig, BenchmarkMeasurements, ITargetHost +from ..cmakeutils import get_bla_vendor from ..util import get_proxy_env_vars @@ -15,9 +16,7 @@ class HiBench(IBenchmark): bench_params.append(BenchParam('num_cores', BenchParam.Type.PARAM_TYPE_INT, 'the number of cores to use by this benchmark')) bench_params.append(BenchParam('hibridon_version', BenchParam.Type.PARAM_TYPE_STRING, 'the version of hibridon, in the form of a commit id')) bench_params.append(BenchParam('fortran_compiler', BenchParam.Type.PARAM_TYPE_PACKAGE, 'the compiler used in the benchmark')) - # bench_params.append(BenchParam('compiler_version', BenchParam.Type.PARAM_TYPE_STRING, 'the version of the used compiler')) - # bench_params.append(BenchParam('blas_id', BenchParam.Type.PARAM_TYPE_STRING, 'the id of the blas library used in the benchmark')) - # bench_params.append(BenchParam('blas_version', BenchParam.Type.PARAM_TYPE_STRING, 'the version of the blas library used in the benchmark')) + bench_params.append(BenchParam('blas_library', BenchParam.Type.PARAM_TYPE_PACKAGE, 'the blas compatible linear algebra library used in the benchmark')) bench_params.append(BenchParam('test_id', BenchParam.Type.PARAM_TYPE_STRING, 'the name of the test to run (eg arch4_quick (about 2s on a core i5 8th generation) or nh3h2_qma_long (about 10min on a core i5 8th generation))')) bench_params.append(BenchParam('cmake_path', BenchParam.Type.PARAM_TYPE_STRING, 'the location of the cmake executable to use (eg "/opt/cmake/cmake-3.23.0/bin/cmake", or simply "cmake" for the one in the path)')) @@ -44,6 +43,7 @@ class HiBench(IBenchmark): hibridon_version = config['hibridon_version'] test_id = config['test_id'] # eg arch4_quick or nh3h2_qma_long fortran_compiler = config['fortran_compiler'] + blas_library = config['blas_library'] cmake_path = config['cmake_path'] num_cores = config['num_cores'] @@ -62,14 +62,16 @@ class HiBench(IBenchmark): '-DBUILD_TESTING=ON' # enable hibridon tests ] - env_vars_bash_commands = target_host.get_package_activation_command(fortran_compiler.package_id, fortran_compiler.package_version) + package_activation_commands = [] + for param in [fortran_compiler, blas_library]: + env_command = target_host.get_package_activation_command(param.package_id, param.package_version) + if env_command != '': + package_activation_commands.append(env_command) + env_vars_bash_commands = ' && '.join(package_activation_commands) + + bla_vendor = get_bla_vendor(blas_library.package_id) cmake_options.append(f'-DCMAKE_Fortran_COMPILER={fortran_compiler.package_id}') - if fortran_compiler.package_id == 'ifort': - cmake_options.append('-DBLA_VENDOR=Intel10_64lp') # use 64 bits intel mkl with multithreading - elif fortran_compiler.package_id == 'gfortran': - pass - else: - assert f'unhandled compiler_id : {fortran_compiler.package_id}' + cmake_options.append(f'-DBLA_VENDOR={bla_vendor}') output_measurements_file_path = output_dir / "measurements.tsv" diff --git a/iprbench/benchmarks/mamul1.py b/iprbench/benchmarks/mamul1.py index 3056f15..818dcaf 100644 --- a/iprbench/benchmarks/mamul1.py +++ b/iprbench/benchmarks/mamul1.py @@ -1,20 +1,10 @@ -from ..core import IBenchmark, BenchParam, BenchmarkConfig, BenchmarkMeasurements, ITargetHost, PackageId from pathlib import Path import pandas as pd import subprocess -from iprbench.util import extract_resource_dir import logging - - -def get_bla_vendor(package_id: PackageId) -> str: - """returns the bla vendor used by cmake's FindBLAS module - see https://cmake.org/cmake/help/latest/module/FindBLAS.html - """ - bla_vendor = { - 'libopenblas-pthread': 'OpenBLAS', - 'intelmkl': 'Intel10_64lp', # use 64 bits intel mkl with multithreading - }[package_id] - return bla_vendor +from ..core import IBenchmark, BenchParam, BenchmarkConfig, BenchmarkMeasurements, ITargetHost +from ..cmakeutils import get_bla_vendor +from iprbench.util import extract_resource_dir class MaMul1(IBenchmark): diff --git a/iprbench/cmakeutils.py b/iprbench/cmakeutils.py new file mode 100644 index 0000000..cb3c839 --- /dev/null +++ b/iprbench/cmakeutils.py @@ -0,0 +1,12 @@ +from .core import PackageId + + +def get_bla_vendor(package_id: PackageId) -> str: + """returns the bla vendor used by cmake's FindBLAS module + see https://cmake.org/cmake/help/latest/module/FindBLAS.html + """ + bla_vendor = { + 'libopenblas-pthread': 'OpenBLAS', + 'intelmkl': 'Intel10_64lp', # use 64 bits intel mkl with multithreading + }[package_id] + return bla_vendor diff --git a/iprbench/version.py b/iprbench/version.py index fa9c4ec..2792152 100644 --- a/iprbench/version.py +++ b/iprbench/version.py @@ -1 +1 @@ -__version__ = '0.0.6' +__version__ = '0.0.7'