| 20 | |
| 21 | |
| 22 | class BenchmarkRunner(BenchMarkRunnerBase): |
| 23 | remote_config = None |
| 24 | remote_config_file = "{}/benchmark/config/cofnig.yaml".format(megcc_path) |
| 25 | |
| 26 | def __init__(self, benchmark_build_dir="", benchmark_arch="x86"): |
| 27 | super().__init__(benchmark_build_dir, benchmark_arch) |
| 28 | |
| 29 | def run_ssh_device(self, ssh_name, ssh_host, ssh_workdir): |
| 30 | if not os.path.exists(self.output_dir.local_path) or os.path.isfile( |
| 31 | self.output_dir.local_path): |
| 32 | os.makedirs(self.output_dir.local_path) |
| 33 | logfile = open( |
| 34 | "{}/{}-{}-{}-{}-log-{}.txt".format( |
| 35 | self.output_dir.local_path, |
| 36 | self.benchmark_framework, |
| 37 | self.benchmark_arch, |
| 38 | self.model.name, |
| 39 | self.log_level, |
| 40 | ssh_name, |
| 41 | ), |
| 42 | "w", |
| 43 | ) |
| 44 | run_options = "" |
| 45 | if self.log_level == 0: |
| 46 | run_options += " --profile" |
| 47 | config_name = "benchmark-{}-{}-{}".format(self.benchmark_framework, |
| 48 | self.benchmark_arch, |
| 49 | self.model.name) |
| 50 | for file_ in [self.benchmark_exec_func, self.model.path]: |
| 51 | cmd = "rsync -aP -zz {} {}:{}/".format(file_, ssh_host, |
| 52 | ssh_workdir) |
| 53 | subprocess.check_call(cmd, shell=True) |
| 54 | cmd = ' ssh -t {} "unset LD_PRELOAD && cd {} && LD_LIBRARY_PATH=./ && chmod +x ./benchmarker && ./benchmarker {}.{} {}" '.format( |
| 55 | ssh_host, ssh_workdir, self.model.name, self.model.extension, |
| 56 | run_options) |
| 57 | subprocess.check_call(cmd, |
| 58 | shell=True, |
| 59 | stdout=logfile, |
| 60 | stderr=subprocess.STDOUT) |
| 61 | |
| 62 | |
| 63 | # build benchmarker |