diff options
author | Jason Gross <jgross@mit.edu> | 2017-09-15 20:57:07 -0400 |
---|---|---|
committer | Jason Gross <jgross@mit.edu> | 2017-09-15 20:57:43 -0400 |
commit | cb293cf0cb1a0d008022ef55cad29aa8a3827508 (patch) | |
tree | 8a7bf1129bce64c4646dfcdc18027b51d26417ee /measure.c | |
parent | dcf7685e7e55e28d6e087244bd6040ba43a761c0 (diff) |
Allow bp in inline asm by tweaking measure
Diffstat (limited to 'measure.c')
-rw-r--r-- | measure.c | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -1,6 +1,6 @@ /* * Benchmarking utilities extracted from SUPERCOP by Andres Erbsen - * based on measure-anything.c version 20120328 and measure.c + * based on measure-anything.c version 20120328 and measure.c * by D. J. Bernstein * Public domain. */ @@ -85,15 +85,24 @@ void limits() void UUT(unsigned char*); -void measure(int n) +// place the call to UUT in a separate function, because gcc prohibits +// use of bp in inline assembly if you have a variable-length array or +// alloca in the code; see +// https://stackoverflow.com/questions/46248430/how-can-i-determine-preferably-at-compile-time-whether-gcc-is-using-rbp-based?noredirect=1#comment79462384_46248430 +void measure_helper(int n, unsigned char *buf, long long* cycles) { - unsigned char *buf = aligned_alloc(64, 1024); - long long* cycles = calloc(n + 1, sizeof(long long)); - for (int i = 0;i <= n;++i) { cycles[i] = cpucycles(); UUT(buf); } +} + +void measure(int n) +{ + unsigned char *buf = aligned_alloc(64, 1024); + long long* cycles = calloc(n + 1, sizeof(long long)); + + measure_helper(n, buf, cycles); for (int i = 0;i < n;++i) cycles[i] = cycles[i + 1] - cycles[i]; for (int i = 0;i < n;++i) printf("%lld\n", cycles[i]); |