From dac00f571da1311a012fa3e1c8c38f25cf4012fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Thu, 23 Oct 2014 08:33:30 +0200 Subject: [PATCH] Use unsigned long arrays for memxor benchmark. --- ChangeLog | 5 +++++ examples/nettle-benchmark.c | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 561476e9..f611ea2f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-10-23 Niels Möller <nisse@lysator.liu.se> + + * examples/nettle-benchmark.c (time_memxor): Allocate buffers as + arrays of unsigned long, for more reliable alignment. + 2014-10-22 Niels Möller <nisse@lysator.liu.se> * configure.ac: Check for getline function. diff --git a/examples/nettle-benchmark.c b/examples/nettle-benchmark.c index d60aad76..c00486cc 100644 --- a/examples/nettle-benchmark.c +++ b/examples/nettle-benchmark.c @@ -157,9 +157,9 @@ bench_nothing(void *arg UNUSED) struct bench_memxor_info { - uint8_t *dst; - const uint8_t *src; - const uint8_t *other; + void *dst; + const void *src; + const void *other; }; static void @@ -345,16 +345,16 @@ static void time_memxor(void) { struct bench_memxor_info info; - uint8_t src[BENCH_BLOCK + sizeof(long)]; - uint8_t other[BENCH_BLOCK + sizeof(long)]; - uint8_t dst[BENCH_BLOCK]; + unsigned long src[BENCH_BLOCK / sizeof(long) + 2]; + unsigned long other[BENCH_BLOCK / sizeof(long) + 2]; + unsigned long dst[BENCH_BLOCK / sizeof(long) + 1]; info.src = src; info.dst = dst; display ("memxor", "aligned", sizeof(unsigned long), time_function(bench_memxor, &info)); - info.src = src + 1; + info.src = (const char *) src + 1; display ("memxor", "unaligned", sizeof(unsigned long), time_function(bench_memxor, &info)); @@ -363,13 +363,13 @@ time_memxor(void) display ("memxor3", "aligned", sizeof(unsigned long), time_function(bench_memxor3, &info)); - info.other = other + 1; + info.other = (const char *) other + 1; display ("memxor3", "unaligned01", sizeof(unsigned long), time_function(bench_memxor3, &info)); - info.src = src + 1; + info.src = (const char *) src + 1; display ("memxor3", "unaligned11", sizeof(unsigned long), time_function(bench_memxor3, &info)); - info.other = other + 2; + info.other = (const char *) other + 2; display ("memxor3", "unaligned12", sizeof(unsigned long), time_function(bench_memxor3, &info)); } -- GitLab