import unittest import logging import subprocess import json from pathlib import Path # import importlib.resources class IprBenchTestCase(unittest.TestCase): logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') def setUp(self) -> None: # pylint: disable=useless-parent-delegation return super().setUp() def test_iprbench_run(self): logging.info('test_iprbench_run') # with importlib.resources.path('iprbench.resources', 'mamul1') as src_dir: # with open(src_dir / 'mamul1.F90', encoding='utf8') as f: # print(f.readlines()) # with open(src_dir / 'CMakeLists.txt', encoding='utf8') as f: # print(f.readlines()) # subprocess.run(f'cat {src_dir / "CMakeLists.txt"}', check=True) results_dir = Path('/tmp/mamul1_out') config = { 'compiler_id': 'gfortran', 'matrix_size': 1024, 'num_loops': 10, 'num_cores': 2 } resultsdb_params = { 'type': 'tsv-files', 'tsv_results_dir': f'{results_dir / "results"}' } command = f'iprbench-run --benchmark-id \'mamul1\' --config \'{json.dumps(config)}\' --results-dir {results_dir} --resultsdb-params \'{json.dumps(resultsdb_params)}\'' subprocess.run(command, shell=True, check=True, executable='/bin/bash') def test_iprbench_hibench(self): logging.info('test_iprbench_hibench') results_dir = Path('/tmp/hibench_out') config = { 'compiler_id': 'gfortran', 'test_id': 'arch4_quick', 'hibridon_version': 'a3bed1c3ccfbca572003020d3e3d3b1ff3934fad', 'cmake_path': 'cmake', 'num_cores': 2, } resultsdb_params = { 'type': 'tsv-files', 'tsv_results_dir': f'{results_dir / "results"}' } command = f'iprbench-run --benchmark-id \'hibench\' --config \'{json.dumps(config)}\' --results-dir {results_dir} --resultsdb-params \'{json.dumps(resultsdb_params)}\'' subprocess.run(command, shell=True, check=True, executable='/bin/bash') if __name__ == '__main__': unittest.main()