summaryrefslogtreecommitdiff
path: root/tune
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2001-03-05 22:54:19 +0100
committerKevin Ryde <user42@zip.com.au>2001-03-05 22:54:19 +0100
commit909fe1d48d17f1ce0f122f9eb66c87c11de4081e (patch)
tree496b646d76e5395a6d04fc56cc508d16c49a7ae0 /tune
parent6776ed975ddc66882d5d02b33bcf4ec155d65f8f (diff)
downloadgmp-909fe1d48d17f1ce0f122f9eb66c87c11de4081e.tar.gz
* tune/speed.h (speed_cyclecounter): Inline asm version for i386.
This might help accuracy by reducing overheads a tiny bit, it's also how the program started out, quite some time ago.
Diffstat (limited to 'tune')
-rw-r--r--tune/speed.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/tune/speed.h b/tune/speed.h
index ad099ad4d..60855104b 100644
--- a/tune/speed.h
+++ b/tune/speed.h
@@ -81,6 +81,7 @@ void speed_cycletime_need_seconds _PROTO ((void));
void speed_starttime _PROTO ((void));
double speed_endtime _PROTO ((void));
+
struct speed_params {
unsigned reps; /* how many times to run the routine */
mp_ptr xp; /* first argument */
@@ -248,6 +249,19 @@ double speed_umul_ppmm _PROTO ((struct speed_params *s));
/* low 32-bits in p[0], high 32-bits in p[1] */
void speed_cyclecounter _PROTO ((unsigned p[2]));
+
+#if defined(__GNUC__) && ! defined (NO_ASM) \
+ && (defined (__i386__) || defined (__i486__))
+#define speed_cyclecounter(p) \
+ do { \
+ __asm__ __volatile__ ("cpuid\n" \
+ "rdtsc" \
+ : "=a" ((p)[0]), "=d" ((p)[1]) \
+ : \
+ : "ebx", "ecx"); \
+ } while (0)
+#endif
+
double speed_cyclecounter_diff _PROTO ((const unsigned end[2],
const unsigned start[2]));
int gettimeofday_microseconds_p _PROTO ((void));