2016-09-19 18:03:58 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
# Copyright 2016 Google Inc.
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
from __future__ import print_function
|
2016-09-22 12:10:02 +00:00
|
|
|
from _adb import Adb
|
2016-09-19 18:03:58 +00:00
|
|
|
from _benchresult import BenchResult
|
2016-09-22 12:10:02 +00:00
|
|
|
from _hardware import HardwareException, Hardware
|
2016-09-19 18:03:58 +00:00
|
|
|
from argparse import ArgumentParser
|
2016-09-22 19:37:21 +00:00
|
|
|
from multiprocessing import Queue
|
2016-09-22 12:10:02 +00:00
|
|
|
from threading import Thread, Timer
|
2016-09-19 18:03:58 +00:00
|
|
|
import collections
|
|
|
|
import glob
|
|
|
|
import math
|
|
|
|
import re
|
|
|
|
import subprocess
|
|
|
|
import sys
|
2016-09-22 12:10:02 +00:00
|
|
|
import time
|
2016-09-19 18:03:58 +00:00
|
|
|
|
2016-09-23 18:36:11 +00:00
|
|
|
__argparse = ArgumentParser(description="""
|
2016-09-19 18:03:58 +00:00
|
|
|
|
|
|
|
Executes the skpbench binary with various configs and skps.
|
|
|
|
|
|
|
|
Also monitors the output in order to filter out and re-run results that have an
|
|
|
|
unacceptable stddev.
|
|
|
|
|
2016-09-23 18:36:11 +00:00
|
|
|
""")
|
2016-09-19 18:03:58 +00:00
|
|
|
|
2016-11-09 21:34:53 +00:00
|
|
|
__argparse.add_argument('skpbench',
|
2016-11-10 19:19:00 +00:00
|
|
|
help="path to the skpbench binary")
|
2016-09-19 19:04:56 +00:00
|
|
|
__argparse.add_argument('--adb',
|
2016-11-10 19:19:00 +00:00
|
|
|
action='store_true', help="execute skpbench over adb")
|
2017-10-19 20:11:58 +00:00
|
|
|
__argparse.add_argument('--adb_binary', default='adb',
|
|
|
|
help="The name of the adb binary to use.")
|
2016-09-19 19:04:56 +00:00
|
|
|
__argparse.add_argument('-s', '--device-serial',
|
2016-11-10 19:19:00 +00:00
|
|
|
help="if using adb, ID of the specific device to target "
|
|
|
|
"(only required if more than 1 device is attached)")
|
2016-09-19 18:03:58 +00:00
|
|
|
__argparse.add_argument('-m', '--max-stddev',
|
2016-11-10 19:19:00 +00:00
|
|
|
type=float, default=4,
|
|
|
|
help="initial max allowable relative standard deviation")
|
2016-09-19 18:03:58 +00:00
|
|
|
__argparse.add_argument('-x', '--suffix',
|
2016-11-10 19:19:00 +00:00
|
|
|
help="suffix to append on config (e.g. '_before', '_after')")
|
2016-09-19 18:03:58 +00:00
|
|
|
__argparse.add_argument('-w','--write-path',
|
2016-11-10 19:19:00 +00:00
|
|
|
help="directory to save .png proofs to disk.")
|
2016-09-19 18:03:58 +00:00
|
|
|
__argparse.add_argument('-v','--verbosity',
|
2016-11-10 19:19:00 +00:00
|
|
|
type=int, default=1, help="level of verbosity (0=none to 5=debug)")
|
2016-09-28 20:56:01 +00:00
|
|
|
__argparse.add_argument('-d', '--duration',
|
2016-11-10 19:19:00 +00:00
|
|
|
type=int, help="number of milliseconds to run each benchmark")
|
2016-09-28 20:56:01 +00:00
|
|
|
__argparse.add_argument('-l', '--sample-ms',
|
2016-11-10 19:19:00 +00:00
|
|
|
type=int, help="duration of a sample (minimum)")
|
2016-10-05 15:42:03 +00:00
|
|
|
__argparse.add_argument('--gpu',
|
2016-11-10 19:19:00 +00:00
|
|
|
action='store_true',
|
|
|
|
help="perform timing on the gpu clock instead of cpu (gpu work only)")
|
2016-09-19 18:03:58 +00:00
|
|
|
__argparse.add_argument('--fps',
|
2016-11-10 19:19:00 +00:00
|
|
|
action='store_true', help="use fps instead of ms")
|
2017-10-19 20:11:58 +00:00
|
|
|
__argparse.add_argument('--pr',
|
|
|
|
help="comma- or space-separated list of GPU path renderers, including: "
|
2021-03-23 17:18:36 +00:00
|
|
|
"[[~]all [~]default [~]dashline [~]msaa [~]aaconvex "
|
2017-10-19 20:11:58 +00:00
|
|
|
"[~]aalinearizing [~]small [~]tess]")
|
2019-03-30 06:31:23 +00:00
|
|
|
__argparse.add_argument('--cc',
|
|
|
|
action='store_true', help="allow coverage counting shortcuts to render paths")
|
2017-10-19 20:11:58 +00:00
|
|
|
__argparse.add_argument('--nocache',
|
|
|
|
action='store_true', help="disable caching of path mask textures")
|
2020-09-24 17:42:47 +00:00
|
|
|
__argparse.add_argument('--allPathsVolatile',
|
|
|
|
action='store_true',
|
|
|
|
help="Causes all GPU paths to be processed as if 'setIsVolatile' had been called.")
|
2016-09-19 18:03:58 +00:00
|
|
|
__argparse.add_argument('-c', '--config',
|
2017-03-17 18:32:05 +00:00
|
|
|
default='gl', help="comma- or space-separated list of GPU configs")
|
2016-11-10 15:36:28 +00:00
|
|
|
__argparse.add_argument('-a', '--resultsfile',
|
2016-11-10 19:19:00 +00:00
|
|
|
help="optional file to append results into")
|
2018-05-31 12:12:33 +00:00
|
|
|
__argparse.add_argument('--ddl',
|
|
|
|
action='store_true', help="record the skp into DDLs before rendering")
|
2021-02-09 13:58:00 +00:00
|
|
|
__argparse.add_argument('--lock-clocks',
|
|
|
|
action='store_true', help="Put device in benchmarking mode (locked clocks, no other processes)")
|
|
|
|
__argparse.add_argument('--clock-speed',
|
|
|
|
type=float, default=66.0, help="A number between 0 and 100 indicating how fast to lock the CPU and GPU clock."
|
|
|
|
"Valid speeds are chosen from their respective available frequencies list.")
|
2020-05-18 14:21:53 +00:00
|
|
|
__argparse.add_argument('--ddlNumRecordingThreads',
|
2018-05-31 12:12:33 +00:00
|
|
|
type=int, default=0,
|
2020-05-18 14:21:53 +00:00
|
|
|
help="number of DDL recording threads (0=num_cores)")
|
2018-05-31 12:12:33 +00:00
|
|
|
__argparse.add_argument('--ddlTilingWidthHeight',
|
|
|
|
type=int, default=0, help="number of tiles along one edge when in DDL mode")
|
2021-04-22 15:08:12 +00:00
|
|
|
__argparse.add_argument('--dontReduceOpsTaskSplitting',
|
|
|
|
action='store_true', help="don't reorder GPU tasks to reduce render target swaps")
|
2018-06-26 12:49:38 +00:00
|
|
|
__argparse.add_argument('--gpuThreads',
|
|
|
|
type=int, default=-1,
|
|
|
|
help="Create this many extra threads to assist with GPU work, including"
|
|
|
|
" software path rendering. Defaults to two.")
|
2020-09-24 17:42:47 +00:00
|
|
|
__argparse.add_argument('--internalSamples',
|
|
|
|
type=int, default=-1,
|
|
|
|
help="Number of samples for internal draws that use MSAA or mixed samples.")
|
2018-06-26 16:13:06 +00:00
|
|
|
__argparse.add_argument('srcs',
|
2016-11-10 19:19:00 +00:00
|
|
|
nargs='+',
|
2018-06-26 16:13:06 +00:00
|
|
|
help=".skp files or directories to expand for .skp files, and/or .svg files")
|
2021-04-19 15:04:21 +00:00
|
|
|
__argparse.add_argument('--gpuResourceCacheLimit',
|
|
|
|
type=int, default=-1,
|
|
|
|
help="Maximum number of bytes to use for budgeted GPU resources.")
|
2016-09-19 18:03:58 +00:00
|
|
|
|
|
|
|
FLAGS = __argparse.parse_args()
|
2016-09-19 19:04:56 +00:00
|
|
|
if FLAGS.adb:
|
|
|
|
import _adb_path as _path
|
2017-10-13 12:15:09 +00:00
|
|
|
_path.init(FLAGS.device_serial, FLAGS.adb_binary)
|
2016-09-19 19:04:56 +00:00
|
|
|
else:
|
|
|
|
import _os_path as _path
|
2016-09-19 18:03:58 +00:00
|
|
|
|
2016-10-12 01:28:54 +00:00
|
|
|
def dump_commandline_if_verbose(commandline):
|
2016-11-09 16:41:23 +00:00
|
|
|
if FLAGS.verbosity >= 5:
|
2016-10-12 01:28:54 +00:00
|
|
|
quoted = ['\'%s\'' % re.sub(r'([\\\'])', r'\\\1', x) for x in commandline]
|
|
|
|
print(' '.join(quoted), file=sys.stderr)
|
|
|
|
|
2016-09-19 18:03:58 +00:00
|
|
|
|
|
|
|
class StddevException(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class Message:
|
|
|
|
READLINE = 0,
|
2016-09-22 12:10:02 +00:00
|
|
|
POLL_HARDWARE = 1,
|
|
|
|
EXIT = 2
|
2016-09-19 18:03:58 +00:00
|
|
|
def __init__(self, message, value=None):
|
|
|
|
self.message = message
|
|
|
|
self.value = value
|
|
|
|
|
2016-09-22 12:10:02 +00:00
|
|
|
class SubprocessMonitor(Thread):
|
|
|
|
def __init__(self, queue, proc):
|
|
|
|
self._queue = queue
|
|
|
|
self._proc = proc
|
|
|
|
Thread.__init__(self)
|
|
|
|
|
|
|
|
def run(self):
|
2016-09-23 18:36:11 +00:00
|
|
|
"""Runs on the background thread."""
|
2016-09-22 12:10:02 +00:00
|
|
|
for line in iter(self._proc.stdout.readline, b''):
|
|
|
|
self._queue.put(Message(Message.READLINE, line.decode('utf-8').rstrip()))
|
|
|
|
self._queue.put(Message(Message.EXIT))
|
|
|
|
|
|
|
|
class SKPBench:
|
2016-11-09 21:34:53 +00:00
|
|
|
ARGV = [FLAGS.skpbench, '--verbosity', str(FLAGS.verbosity)]
|
2016-09-28 20:56:01 +00:00
|
|
|
if FLAGS.duration:
|
|
|
|
ARGV.extend(['--duration', str(FLAGS.duration)])
|
2016-09-19 18:03:58 +00:00
|
|
|
if FLAGS.sample_ms:
|
|
|
|
ARGV.extend(['--sampleMs', str(FLAGS.sample_ms)])
|
2016-10-05 15:42:03 +00:00
|
|
|
if FLAGS.gpu:
|
|
|
|
ARGV.extend(['--gpuClock', 'true'])
|
2016-09-19 18:03:58 +00:00
|
|
|
if FLAGS.fps:
|
|
|
|
ARGV.extend(['--fps', 'true'])
|
2017-10-19 20:11:58 +00:00
|
|
|
if FLAGS.pr:
|
|
|
|
ARGV.extend(['--pr'] + re.split(r'[ ,]', FLAGS.pr))
|
2019-03-30 06:31:23 +00:00
|
|
|
if FLAGS.cc:
|
|
|
|
ARGV.extend(['--cc', 'true'])
|
2017-10-19 20:11:58 +00:00
|
|
|
if FLAGS.nocache:
|
|
|
|
ARGV.extend(['--cachePathMasks', 'false'])
|
2020-09-24 17:42:47 +00:00
|
|
|
if FLAGS.allPathsVolatile:
|
|
|
|
ARGV.extend(['--allPathsVolatile', 'true'])
|
2018-06-26 12:49:38 +00:00
|
|
|
if FLAGS.gpuThreads != -1:
|
|
|
|
ARGV.extend(['--gpuThreads', str(FLAGS.gpuThreads)])
|
2020-09-24 17:42:47 +00:00
|
|
|
if FLAGS.internalSamples != -1:
|
|
|
|
ARGV.extend(['--internalSamples', str(FLAGS.internalSamples)])
|
2018-05-31 12:12:33 +00:00
|
|
|
|
|
|
|
# DDL parameters
|
|
|
|
if FLAGS.ddl:
|
|
|
|
ARGV.extend(['--ddl', 'true'])
|
2020-05-18 14:21:53 +00:00
|
|
|
if FLAGS.ddlNumRecordingThreads:
|
|
|
|
ARGV.extend(['--ddlNumRecordingThreads',
|
|
|
|
str(FLAGS.ddlNumRecordingThreads)])
|
2018-05-31 12:12:33 +00:00
|
|
|
if FLAGS.ddlTilingWidthHeight:
|
|
|
|
ARGV.extend(['--ddlTilingWidthHeight', str(FLAGS.ddlTilingWidthHeight)])
|
|
|
|
|
2021-04-22 15:08:12 +00:00
|
|
|
if FLAGS.dontReduceOpsTaskSplitting:
|
|
|
|
ARGV.extend(['--dontReduceOpsTaskSplitting'])
|
2021-02-12 17:17:20 +00:00
|
|
|
|
2021-04-19 15:04:21 +00:00
|
|
|
if FLAGS.gpuResourceCacheLimit:
|
|
|
|
ARGV.extend(['--gpuResourceCacheLimit', str(FLAGS.gpuResourceCacheLimit)])
|
|
|
|
|
2016-09-19 19:04:56 +00:00
|
|
|
if FLAGS.adb:
|
|
|
|
if FLAGS.device_serial is None:
|
2017-10-13 12:15:09 +00:00
|
|
|
ARGV[:0] = [FLAGS.adb_binary, 'shell']
|
2016-09-19 19:04:56 +00:00
|
|
|
else:
|
2017-10-13 12:15:09 +00:00
|
|
|
ARGV[:0] = [FLAGS.adb_binary, '-s', FLAGS.device_serial, 'shell']
|
2016-09-19 18:03:58 +00:00
|
|
|
|
|
|
|
@classmethod
|
2016-11-10 15:36:28 +00:00
|
|
|
def get_header(cls, outfile=sys.stdout):
|
2016-10-12 01:28:54 +00:00
|
|
|
commandline = cls.ARGV + ['--duration', '0']
|
|
|
|
dump_commandline_if_verbose(commandline)
|
2016-11-10 15:36:28 +00:00
|
|
|
out = subprocess.check_output(commandline, stderr=subprocess.STDOUT)
|
|
|
|
return out.rstrip()
|
2016-10-12 01:28:54 +00:00
|
|
|
|
|
|
|
@classmethod
|
2017-03-17 18:32:05 +00:00
|
|
|
def run_warmup(cls, warmup_time, config):
|
2016-10-12 01:28:54 +00:00
|
|
|
if not warmup_time:
|
|
|
|
return
|
2016-10-18 16:19:50 +00:00
|
|
|
print('running %i second warmup...' % warmup_time, file=sys.stderr)
|
2016-10-12 01:28:54 +00:00
|
|
|
commandline = cls.ARGV + ['--duration', str(warmup_time * 1000),
|
2017-03-17 18:32:05 +00:00
|
|
|
'--config', config,
|
2018-06-26 16:13:06 +00:00
|
|
|
'--src', 'warmup']
|
2016-10-12 01:28:54 +00:00
|
|
|
dump_commandline_if_verbose(commandline)
|
2016-11-09 21:25:23 +00:00
|
|
|
output = subprocess.check_output(commandline, stderr=subprocess.STDOUT)
|
|
|
|
|
2016-10-12 01:28:54 +00:00
|
|
|
# validate the warmup run output.
|
2016-11-09 21:25:23 +00:00
|
|
|
for line in output.decode('utf-8').split('\n'):
|
2016-10-12 01:28:54 +00:00
|
|
|
match = BenchResult.match(line.rstrip())
|
|
|
|
if match and match.bench == 'warmup':
|
|
|
|
return
|
|
|
|
raise Exception('Invalid warmup output:\n%s' % output)
|
2016-09-19 18:03:58 +00:00
|
|
|
|
2018-06-26 16:13:06 +00:00
|
|
|
def __init__(self, src, config, max_stddev, best_result=None):
|
|
|
|
self.src = src
|
2016-09-19 18:03:58 +00:00
|
|
|
self.config = config
|
|
|
|
self.max_stddev = max_stddev
|
|
|
|
self.best_result = best_result
|
|
|
|
self._queue = Queue()
|
2016-09-22 12:10:02 +00:00
|
|
|
self._proc = None
|
|
|
|
self._monitor = None
|
|
|
|
self._hw_poll_timer = None
|
|
|
|
|
|
|
|
def __enter__(self):
|
|
|
|
return self
|
|
|
|
|
|
|
|
def __exit__(self, exception_type, exception_value, traceback):
|
|
|
|
if self._proc:
|
|
|
|
self.terminate()
|
|
|
|
if self._hw_poll_timer:
|
|
|
|
self._hw_poll_timer.cancel()
|
|
|
|
|
|
|
|
def execute(self, hardware):
|
|
|
|
hardware.sanity_check()
|
|
|
|
self._schedule_hardware_poll()
|
|
|
|
|
|
|
|
commandline = self.ARGV + ['--config', self.config,
|
2018-06-26 16:13:06 +00:00
|
|
|
'--src', self.src,
|
2016-09-22 12:10:02 +00:00
|
|
|
'--suppressHeader', 'true']
|
|
|
|
if FLAGS.write_path:
|
|
|
|
pngfile = _path.join(FLAGS.write_path, self.config,
|
2018-06-26 16:13:06 +00:00
|
|
|
_path.basename(self.src) + '.png')
|
2016-09-22 12:10:02 +00:00
|
|
|
commandline.extend(['--png', pngfile])
|
2016-10-12 01:28:54 +00:00
|
|
|
dump_commandline_if_verbose(commandline)
|
2016-11-09 21:25:23 +00:00
|
|
|
self._proc = subprocess.Popen(commandline, stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.STDOUT)
|
2016-09-22 12:10:02 +00:00
|
|
|
self._monitor = SubprocessMonitor(self._queue, self._proc)
|
|
|
|
self._monitor.start()
|
2016-09-19 18:03:58 +00:00
|
|
|
|
|
|
|
while True:
|
|
|
|
message = self._queue.get()
|
|
|
|
if message.message == Message.READLINE:
|
|
|
|
result = BenchResult.match(message.value)
|
|
|
|
if result:
|
2016-09-22 12:10:02 +00:00
|
|
|
hardware.sanity_check()
|
|
|
|
self._process_result(result)
|
2016-11-09 21:25:23 +00:00
|
|
|
elif hardware.filter_line(message.value):
|
2016-10-18 16:19:50 +00:00
|
|
|
print(message.value, file=sys.stderr)
|
2016-09-19 18:03:58 +00:00
|
|
|
continue
|
2016-09-22 12:10:02 +00:00
|
|
|
if message.message == Message.POLL_HARDWARE:
|
|
|
|
hardware.sanity_check()
|
|
|
|
self._schedule_hardware_poll()
|
|
|
|
continue
|
2016-09-19 18:03:58 +00:00
|
|
|
if message.message == Message.EXIT:
|
2016-09-22 12:10:02 +00:00
|
|
|
self._monitor.join()
|
|
|
|
self._proc.wait()
|
|
|
|
if self._proc.returncode != 0:
|
|
|
|
raise Exception("skpbench exited with nonzero exit code %i" %
|
|
|
|
self._proc.returncode)
|
|
|
|
self._proc = None
|
2016-09-19 18:03:58 +00:00
|
|
|
break
|
|
|
|
|
2016-09-22 12:10:02 +00:00
|
|
|
def _schedule_hardware_poll(self):
|
|
|
|
if self._hw_poll_timer:
|
|
|
|
self._hw_poll_timer.cancel()
|
|
|
|
self._hw_poll_timer = \
|
|
|
|
Timer(1, lambda: self._queue.put(Message(Message.POLL_HARDWARE)))
|
|
|
|
self._hw_poll_timer.start()
|
|
|
|
|
|
|
|
def _process_result(self, result):
|
2016-09-19 18:03:58 +00:00
|
|
|
if not self.best_result or result.stddev <= self.best_result.stddev:
|
|
|
|
self.best_result = result
|
2016-09-22 12:10:02 +00:00
|
|
|
elif FLAGS.verbosity >= 2:
|
|
|
|
print("reusing previous result for %s/%s with lower stddev "
|
|
|
|
"(%s%% instead of %s%%)." %
|
2016-09-19 18:03:58 +00:00
|
|
|
(result.config, result.bench, self.best_result.stddev,
|
|
|
|
result.stddev), file=sys.stderr)
|
|
|
|
if self.max_stddev and self.best_result.stddev > self.max_stddev:
|
|
|
|
raise StddevException()
|
|
|
|
|
2016-09-22 12:10:02 +00:00
|
|
|
def terminate(self):
|
|
|
|
if self._proc:
|
2016-10-05 15:42:03 +00:00
|
|
|
self._proc.terminate()
|
2016-09-22 12:10:02 +00:00
|
|
|
self._monitor.join()
|
|
|
|
self._proc.wait()
|
|
|
|
self._proc = None
|
2016-09-19 18:03:58 +00:00
|
|
|
|
2016-11-10 15:36:28 +00:00
|
|
|
def emit_result(line, resultsfile=None):
|
|
|
|
print(line)
|
|
|
|
sys.stdout.flush()
|
|
|
|
if resultsfile:
|
|
|
|
print(line, file=resultsfile)
|
|
|
|
resultsfile.flush()
|
2016-09-19 18:03:58 +00:00
|
|
|
|
2018-06-26 16:13:06 +00:00
|
|
|
def run_benchmarks(configs, srcs, hardware, resultsfile=None):
|
2017-10-20 15:58:32 +00:00
|
|
|
hasheader = False
|
2018-06-26 16:13:06 +00:00
|
|
|
benches = collections.deque([(src, config, FLAGS.max_stddev)
|
|
|
|
for src in srcs
|
2016-09-19 18:03:58 +00:00
|
|
|
for config in configs])
|
|
|
|
while benches:
|
2017-10-20 15:58:32 +00:00
|
|
|
try:
|
|
|
|
with hardware:
|
2017-03-17 18:32:05 +00:00
|
|
|
SKPBench.run_warmup(hardware.warmup_time, configs[0])
|
2017-10-20 15:58:32 +00:00
|
|
|
if not hasheader:
|
|
|
|
emit_result(SKPBench.get_header(), resultsfile)
|
|
|
|
hasheader = True
|
|
|
|
while benches:
|
|
|
|
benchargs = benches.popleft()
|
|
|
|
with SKPBench(*benchargs) as skpbench:
|
|
|
|
try:
|
|
|
|
skpbench.execute(hardware)
|
|
|
|
if skpbench.best_result:
|
|
|
|
emit_result(skpbench.best_result.format(FLAGS.suffix),
|
|
|
|
resultsfile)
|
|
|
|
else:
|
|
|
|
print("WARNING: no result for %s with config %s" %
|
2018-06-26 16:13:06 +00:00
|
|
|
(skpbench.src, skpbench.config), file=sys.stderr)
|
2017-10-20 15:58:32 +00:00
|
|
|
|
|
|
|
except StddevException:
|
|
|
|
retry_max_stddev = skpbench.max_stddev * math.sqrt(2)
|
|
|
|
if FLAGS.verbosity >= 1:
|
|
|
|
print("stddev is too high for %s/%s (%s%%, max=%.2f%%), "
|
|
|
|
"re-queuing with max=%.2f%%." %
|
|
|
|
(skpbench.best_result.config, skpbench.best_result.bench,
|
|
|
|
skpbench.best_result.stddev, skpbench.max_stddev,
|
|
|
|
retry_max_stddev),
|
|
|
|
file=sys.stderr)
|
2018-06-26 16:13:06 +00:00
|
|
|
benches.append((skpbench.src, skpbench.config, retry_max_stddev,
|
2017-10-20 15:58:32 +00:00
|
|
|
skpbench.best_result))
|
|
|
|
|
|
|
|
except HardwareException as exception:
|
|
|
|
skpbench.terminate()
|
|
|
|
if FLAGS.verbosity >= 4:
|
|
|
|
hardware.print_debug_diagnostics()
|
|
|
|
if FLAGS.verbosity >= 1:
|
2017-10-23 23:19:37 +00:00
|
|
|
print("%s; rebooting and taking a %i second nap..." %
|
2017-10-20 15:58:32 +00:00
|
|
|
(exception.message, exception.sleeptime), file=sys.stderr)
|
|
|
|
benches.appendleft(benchargs) # retry the same bench next time.
|
|
|
|
raise # wake hw up from benchmarking mode before the nap.
|
|
|
|
|
|
|
|
except HardwareException as exception:
|
|
|
|
time.sleep(exception.sleeptime)
|
2016-09-22 12:10:02 +00:00
|
|
|
|
|
|
|
def main():
|
|
|
|
# Delimiter is ',' or ' ', skip if nested inside parens (e.g. gpu(a=b,c=d)).
|
|
|
|
DELIMITER = r'[, ](?!(?:[^(]*\([^)]*\))*[^()]*\))'
|
|
|
|
configs = re.split(DELIMITER, FLAGS.config)
|
2018-06-26 16:13:06 +00:00
|
|
|
srcs = _path.find_skps(FLAGS.srcs)
|
2019-09-11 18:00:20 +00:00
|
|
|
assert srcs
|
2016-09-22 12:10:02 +00:00
|
|
|
|
2021-02-09 13:58:00 +00:00
|
|
|
|
2016-09-22 12:10:02 +00:00
|
|
|
if FLAGS.adb:
|
2017-10-13 12:15:09 +00:00
|
|
|
adb = Adb(FLAGS.device_serial, FLAGS.adb_binary,
|
|
|
|
echo=(FLAGS.verbosity >= 5))
|
2021-02-09 13:58:00 +00:00
|
|
|
from _hardware_android import HardwareAndroid
|
|
|
|
|
2016-11-09 16:41:23 +00:00
|
|
|
model = adb.check('getprop ro.product.model').strip()
|
2016-09-23 18:36:11 +00:00
|
|
|
if model == 'Pixel C':
|
|
|
|
from _hardware_pixel_c import HardwarePixelC
|
|
|
|
hardware = HardwarePixelC(adb)
|
2020-10-05 15:20:43 +00:00
|
|
|
elif model == 'Pixel' or model == "Pixel XL":
|
2017-10-20 15:58:32 +00:00
|
|
|
from _hardware_pixel import HardwarePixel
|
|
|
|
hardware = HardwarePixel(adb)
|
2018-04-27 23:10:39 +00:00
|
|
|
elif model == 'Pixel 2':
|
|
|
|
from _hardware_pixel2 import HardwarePixel2
|
|
|
|
hardware = HardwarePixel2(adb)
|
2016-10-18 16:19:50 +00:00
|
|
|
elif model == 'Nexus 6P':
|
|
|
|
from _hardware_nexus_6p import HardwareNexus6P
|
|
|
|
hardware = HardwareNexus6P(adb)
|
2020-09-24 17:42:47 +00:00
|
|
|
else:
|
2016-09-22 12:10:02 +00:00
|
|
|
print("WARNING: %s: don't know how to monitor this hardware; results "
|
|
|
|
"may be unreliable." % model, file=sys.stderr)
|
|
|
|
hardware = HardwareAndroid(adb)
|
2021-02-09 13:58:00 +00:00
|
|
|
|
|
|
|
if FLAGS.lock_clocks:
|
|
|
|
hardware.__enter__()
|
|
|
|
print("Entered benchmarking mode, not running benchmarks. Reboot to restore.");
|
|
|
|
return;
|
|
|
|
|
|
|
|
if FLAGS.clock_speed:
|
|
|
|
hardware.setDesiredClock(FLAGS.clock_speed)
|
2016-09-22 12:10:02 +00:00
|
|
|
else:
|
|
|
|
hardware = Hardware()
|
|
|
|
|
2017-10-20 15:58:32 +00:00
|
|
|
if FLAGS.resultsfile:
|
|
|
|
with open(FLAGS.resultsfile, mode='a+') as resultsfile:
|
2018-06-26 16:13:06 +00:00
|
|
|
run_benchmarks(configs, srcs, hardware, resultsfile=resultsfile)
|
2017-10-20 15:58:32 +00:00
|
|
|
else:
|
2018-06-26 16:13:06 +00:00
|
|
|
run_benchmarks(configs, srcs, hardware)
|
2016-09-19 18:03:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|