Commit 71502947 authored by Niels Möller's avatar Niels Möller

(GET_CYCLE_COUNTER): Define also for x86_64.

(time_memxor): Improved display.

Rev: nettle/examples/nettle-benchmark.c:1.11
parent e376c4eb
...@@ -61,7 +61,7 @@ static double frequency = 0.0; ...@@ -61,7 +61,7 @@ static double frequency = 0.0;
/* FIXME: Proper configure test for rdtsc? */ /* FIXME: Proper configure test for rdtsc? */
#ifndef WITH_CYCLE_COUNTER #ifndef WITH_CYCLE_COUNTER
# if defined(__GNUC__) && defined(__i386__) # if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
# define WITH_CYCLE_COUNTER 1 # define WITH_CYCLE_COUNTER 1
# else # else
# define WITH_CYCLE_COUNTER 0 # define WITH_CYCLE_COUNTER 0
...@@ -69,6 +69,7 @@ static double frequency = 0.0; ...@@ -69,6 +69,7 @@ static double frequency = 0.0;
#endif #endif
#if WITH_CYCLE_COUNTER #if WITH_CYCLE_COUNTER
# if defined(__i386__)
#define GET_CYCLE_COUNTER(hi, lo) \ #define GET_CYCLE_COUNTER(hi, lo) \
__asm__("xorl %%eax,%%eax\n" \ __asm__("xorl %%eax,%%eax\n" \
"movl %%ebx, %%edi\n" \ "movl %%ebx, %%edi\n" \
...@@ -78,6 +79,17 @@ static double frequency = 0.0; ...@@ -78,6 +79,17 @@ static double frequency = 0.0;
: "=a" (lo), "=d" (hi) \ : "=a" (lo), "=d" (hi) \
: /* No inputs. */ \ : /* No inputs. */ \
: "%edi", "%ecx", "cc") : "%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 #define BENCH_ITERATIONS 10
#endif #endif
...@@ -272,9 +284,9 @@ time_memxor(void) ...@@ -272,9 +284,9 @@ time_memxor(void)
info.src = src; info.src = src;
info.dst = dst; info.dst = dst;
display ("xor", "aligned", 1, time_function(bench_memxor, &info)); display ("memxor", "aligned", 0, time_function(bench_memxor, &info));
info.src++; info.src++;
display ("xor", "unaligned", 1, time_function(bench_memxor, &info)); display ("memxor", "unaligned", 0, time_function(bench_memxor, &info));
} }
static void static void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment