|
6 | 6 | import os |
7 | 7 | import shutil |
8 | 8 | from pathlib import Path |
9 | | -import subprocess # nosec B404 |
10 | 9 | from .result import Result |
11 | 10 | from .options import options |
12 | 11 | from utils.utils import run |
|
16 | 15 | class Benchmark: |
17 | 16 | def __init__(self, directory): |
18 | 17 | self.directory = directory |
| 18 | + |
| 19 | + @staticmethod |
| 20 | + def get_adapter_full_path(): |
19 | 21 | for libs_dir_name in ['lib', 'lib64']: |
20 | | - self.adapter_path = os.path.join( |
| 22 | + adapter_path = os.path.join( |
21 | 23 | options.ur_dir, libs_dir_name, f"libur_adapter_{options.ur_adapter_name}.so") |
22 | | - if os.path.isfile(self.adapter_path): |
23 | | - print(f"using adapter {self.adapter_path}") |
24 | | - return |
25 | | - assert os.path.isfile(self.adapter_path), \ |
26 | | - f"could not find adapter file {self.adapter_path} (and in similar lib paths)" |
| 24 | + if os.path.isfile(adapter_path): |
| 25 | + return adapter_path |
| 26 | + assert False, \ |
| 27 | + f"could not find adapter file {adapter_path} (and in similar lib paths)" |
27 | 28 |
|
28 | 29 | def run_bench(self, command, env_vars): |
29 | 30 | env_vars_with_forced_adapter = env_vars.copy() |
30 | | - env_vars_with_forced_adapter.update({'UR_ADAPTERS_FORCE_LOAD': self.adapter_path}) |
| 31 | + env_vars_with_forced_adapter.update( |
| 32 | + {'UR_ADAPTERS_FORCE_LOAD': Benchmark.get_adapter_full_path()}) |
31 | 33 | return run( |
32 | 34 | command=command, |
33 | 35 | env_vars=env_vars_with_forced_adapter, |
|
0 commit comments