~linaro-toolchain-dev/cortex-strings/trunk

« back to all changes in this revision

Viewing changes to scripts/bench.py

  • Committer: Will Newton
  • Date: 2013-06-21 14:42:10 UTC
  • Revision ID: will.newton@linaro.org-20130621144210-za4jb0kw9d4mcnml
Allow aligning source and destination buffers separately.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    'plain': 'memset memcpy strcmp strcpy',
34
34
}
35
35
 
36
 
def run(cache, variant, function, bytes, loops, alignment=8, quiet=False):
 
36
BOUNCE_ALIGNMENTS = ['1']
 
37
SINGLE_BUFFER_ALIGNMENTS = ['1', '2', '4', '8', '16', '32']
 
38
DUAL_BUFFER_ALIGNMENTS = ['1:32', '2:32', '4:32', '8:32', '16:32', '32:32']
 
39
 
 
40
ALIGNMENTS = {
 
41
    'bounce': BOUNCE_ALIGNMENTS,
 
42
    'memchr': SINGLE_BUFFER_ALIGNMENTS,
 
43
    'memset': SINGLE_BUFFER_ALIGNMENTS,
 
44
    'strchr': SINGLE_BUFFER_ALIGNMENTS,
 
45
    'strlen': SINGLE_BUFFER_ALIGNMENTS,
 
46
    'memcmp': DUAL_BUFFER_ALIGNMENTS,
 
47
    'memcpy': DUAL_BUFFER_ALIGNMENTS,
 
48
    'strcmp': DUAL_BUFFER_ALIGNMENTS,
 
49
    'strcpy': DUAL_BUFFER_ALIGNMENTS,
 
50
}
 
51
 
 
52
def run(cache, variant, function, bytes, loops, alignment, quiet=False):
37
53
    """Perform a single run, exercising the cache as appropriate."""
38
54
    key = ':'.join('%s' % x for x in (variant, function, bytes, loops, alignment))
39
55
 
49
65
            assert False, 'Error %s while running %s' % (ex, cmd)
50
66
 
51
67
    parts = got.split(':')
52
 
    took = float(parts[5])
 
68
    took = float(parts[6])
53
69
 
54
70
    cache[key] = got
55
71
 
59
75
 
60
76
    return took
61
77
 
62
 
def run_many(cache, variants, bytes, alignments, all_functions):
 
78
def run_many(cache, variants, bytes, all_functions):
63
79
    # We want the data to come out in a useful order.  So fix an
64
80
    # alignment and function, and do all sizes for a variant first
65
81
    bytes = sorted(bytes)
66
 
    mid = bytes[len(bytes)/2]
 
82
    mid = bytes[int(len(bytes)/1.5)]
67
83
 
68
84
    if not all_functions:
69
85
        # Use the ordering in 'this' as the default
75
91
                if function not in all_functions:
76
92
                    all_functions.append(function)
77
93
 
78
 
    for alignment in alignments:
79
 
        for function in all_functions:
 
94
    for function in all_functions:
 
95
        for alignment in ALIGNMENTS[function]:
80
96
            for variant in variants:
81
97
                if function not in HAS[variant].split():
82
98
                    continue
122
138
            steps = int(round(math.log(top) / math.log(step)))
123
139
            bytes.extend([int(step**x) for x in range(0, steps+1)])
124
140
 
125
 
    alignments = [8, 16, 4, 1, 2, 32]
126
 
 
127
 
    run_many(cache, variants, bytes, alignments, functions)
 
141
    run_many(cache, variants, bytes, functions)
128
142
 
129
143
def main():
130
144
    cachename = 'cache.txt'