aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernard Ogden <benie.ogden@linaro.org>2014-07-03 07:46:34 +0100
committerBernard Ogden <benie.ogden@linaro.org>2014-07-03 07:46:34 +0100
commit5e812bf5c5cf323f119d57f0529bdbe398233927 (patch)
tree7a197089c4fe50985440f3f2815ecb567ab165d4
parent52f8e9927a40b66d4682e0cfcb04d84c52db2b68 (diff)
parent097c1530048bf3c285cea1341a45a5cab7978cf1 (diff)
Merge branch 'scripts'
Conflicts: scripts/bench.py
-rw-r--r--scripts/bench.py64
1 files changed, 38 insertions, 26 deletions
diff --git a/scripts/bench.py b/scripts/bench.py
index 41a9abf..39fe8ee 100644
--- a/scripts/bench.py
+++ b/scripts/bench.py
@@ -15,45 +15,49 @@ import subprocess
import math
import sys
-ALL = 'memchr memcmp memcpy memset strchr strcmp strcpy strlen'
+SINGLE_BUFFER_FUNCTIONS = ['strchr', 'memset', 'strlen', 'memchr']
+DUAL_BUFFER_FUNCTIONS = ['memcmp', 'memcpy', 'strcmp', 'strcpy']
+
+FUNCTIONS = list(SINGLE_BUFFER_FUNCTIONS)
+FUNCTIONS.extend(DUAL_BUFFER_FUNCTIONS)
HAS = {
'this': 'bounce memchr memcpy memset strchr strcpy strlen',
'bionic-a9': 'memcmp memcpy memset strcmp strcpy strlen',
'bionic-a15': 'memcmp memcpy memset strcmp strcpy strlen',
- 'bionic-c': ALL,
+ 'bionic-c': FUNCTIONS,
'csl': 'memcpy memset',
'glibc': 'memcpy memset strchr strlen',
- 'glibc-c': ALL,
+ 'glibc-c': FUNCTIONS,
'newlib': 'memcpy strcmp strcpy strlen',
- 'newlib-c': ALL,
+ 'newlib-c': FUNCTIONS,
'newlib-xscale': 'memchr memcpy memset strchr strcmp strcpy strlen',
'plain': 'memset memcpy strcmp strcpy',
}
-BOUNCE_ALIGNMENTS = ['1']
-SINGLE_BUFFER_ALIGNMENTS = ['1', '2', '4', '8', '16', '32']
-DUAL_BUFFER_ALIGNMENTS = ['1:32', '2:32', '4:32', '8:32', '16:32', '32:32']
-
ALIGNMENTS = {
- 'bounce': BOUNCE_ALIGNMENTS,
- 'memchr': SINGLE_BUFFER_ALIGNMENTS,
- 'memset': SINGLE_BUFFER_ALIGNMENTS,
- 'strchr': SINGLE_BUFFER_ALIGNMENTS,
- 'strlen': SINGLE_BUFFER_ALIGNMENTS,
- 'memcmp': DUAL_BUFFER_ALIGNMENTS,
- 'memcpy': DUAL_BUFFER_ALIGNMENTS,
- 'strcmp': DUAL_BUFFER_ALIGNMENTS,
- 'strcpy': DUAL_BUFFER_ALIGNMENTS,
+ 'bounce': ['1'],
}
VARIANTS = sorted(HAS.keys())
-FUNCTIONS = sorted(ALIGNMENTS.keys())
NUM_RUNS = 5
DRY_RUN = False
+#CLI helpers
+def parse_alignments(alignment):
+ e = Exception("Alignments must be expressed as colon-separated digits e.g. 8:32 16:16")
+ alignments = alignment.split(':')
+ if len(alignments) != 2:
+ raise e
+ try:
+ [int(x) for x in alignments]
+ except:
+ raise e
+ return alignment
+
+
def run(cache, variant, function, bytes, loops, alignment, run_id, quiet=False):
"""Perform a single run, exercising the cache as appropriate."""
key = ':'.join('%s' % x for x in (variant, function, bytes, loops, alignment, run_id))
@@ -138,28 +142,36 @@ def run_top(cache):
parser.add_argument("-f", "--functions", nargs="+", help="function to run (run all if not specified)", default = FUNCTIONS, choices = FUNCTIONS)
parser.add_argument("-u", "--upper", type=int, help="upper limit to test to (in bytes)", default = 512*1024)
parser.add_argument("-l", "--lower", type=int, help="lowest block size to test (bytes)", default = 0)
- parser.add_argument("-s", "--steps", type=float, nargs="+", help="steps to test powers of", default = [1.4, 2.0])
+ parser.add_argument("-s", "--steps", nargs="+", help="steps to test powers of", default = ['1.4', '2.0'])
parser.add_argument("-p", "--prefix", help="path to executables, relative to CWD", default=".")
parser.add_argument("-d", "--dry-run", help="Dry run: just print the invocations that we would use", default=False, action="store_true")
+ parser.add_argument("-a", "--alignments", nargs="+", type=parse_alignments, help="Alignments, e.g. 2:32 for 2-byte-aligned source to 4-byte-aligned dest. Functions with just a dest use the number before the colon.", default=['1:32', '2:32', '4:32', '8:32', '16:32', '32:32'])
+ parser.add_argument("-r", "--runs", type=int, help="Number of runs of each test", default=5)
args = parser.parse_args()
if(args.lower >= args.upper):
raise Exception("Range starts after it ends!")
- global build, DRY_RUN
+ global build, DRY_RUN, ALIGNMENTS, NUM_RUNS
+ NUM_RUNS = args.runs
build = args.prefix
DRY_RUN = args.dry_run
+ for function in SINGLE_BUFFER_FUNCTIONS:
+ ALIGNMENTS[function] = [x.split(':')[0] for x in args.alignments]
+ for function in DUAL_BUFFER_FUNCTIONS:
+ ALIGNMENTS[function] = args.alignments
bytes = []
#Test powers of steps
for step in args.steps:
- print step
- print args.upper
- print args.lower
- # Figure out how many steps get us up to the top (not sure if it's exactly right, but it seems to be close enough)
- steps = int(round(math.log(args.upper - args.lower) / math.log(step)))
- bytes.extend([args.lower -1 + int(step**x) for x in range(0, steps+1)])
+ if step[0] == '+':
+ step = int(step[1:])
+ bytes.extend(range(args.lower, args.upper + step, step))
+ else:
+ step = float(step)
+ steps = int(round(math.log(args.upper - args.lower, step)))
+ bytes.extend([args.lower - 1 + int(step**x) for x in range(steps+1)])
run_many(cache, args.variants, bytes, args.functions)