From 7150294706b307946186f792931430d2d5236da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Wed, 22 Sep 2010 16:37:23 +0200 Subject: [PATCH] (GET_CYCLE_COUNTER): Define also for x86_64. (time_memxor): Improved display. Rev: nettle/examples/nettle-benchmark.c:1.11 --- examples/nettle-benchmark.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/examples/nettle-benchmark.c b/examples/nettle-benchmark.c index c5264f26..0a4a0d91 100644 --- a/examples/nettle-benchmark.c +++ b/examples/nettle-benchmark.c @@ -61,7 +61,7 @@ static double frequency = 0.0; /* FIXME: Proper configure test for rdtsc? */ #ifndef WITH_CYCLE_COUNTER -# if defined(__GNUC__) && defined(__i386__) +# if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) # define WITH_CYCLE_COUNTER 1 # else # define WITH_CYCLE_COUNTER 0 @@ -69,6 +69,7 @@ static double frequency = 0.0; #endif #if WITH_CYCLE_COUNTER +# if defined(__i386__) #define GET_CYCLE_COUNTER(hi, lo) \ __asm__("xorl %%eax,%%eax\n" \ "movl %%ebx, %%edi\n" \ @@ -78,6 +79,17 @@ static double frequency = 0.0; : "=a" (lo), "=d" (hi) \ : /* No inputs. */ \ : "%edi", "%ecx", "cc") +# elif defined(__x86_64__) +#define GET_CYCLE_COUNTER(hi, lo) \ + __asm__("xorl %%eax,%%eax\n" \ + "mov %%rbx, %%r10\n" \ + "cpuid\n" \ + "rdtsc\n" \ + "mov %%r10, %%rbx\n" \ + : "=a" (lo), "=d" (hi) \ + : /* No inputs. */ \ + : "%r10", "%rcx", "cc") +# endif #define BENCH_ITERATIONS 10 #endif @@ -272,9 +284,9 @@ time_memxor(void) info.src = src; info.dst = dst; - display ("xor", "aligned", 1, time_function(bench_memxor, &info)); + display ("memxor", "aligned", 0, time_function(bench_memxor, &info)); info.src++; - display ("xor", "unaligned", 1, time_function(bench_memxor, &info)); + display ("memxor", "unaligned", 0, time_function(bench_memxor, &info)); } static void -- GitLab