diff options
author | Brian Paul <[email protected]> | 2005-05-07 16:59:58 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2005-05-07 16:59:58 +0000 |
commit | 42fa81275c67d7d1ad8d255120af0ffeeb46b963 (patch) | |
tree | 1c786fb74f62263d6a1a312178bcef74daeffa5e /src/mesa/math/m_debug_util.h | |
parent | e3f684b753c94d8657a1487655b41fdfc0119dba (diff) |
x86-64 transform optimizations (Mikko T.)
Diffstat (limited to 'src/mesa/math/m_debug_util.h')
-rw-r--r-- | src/mesa/math/m_debug_util.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/mesa/math/m_debug_util.h b/src/mesa/math/m_debug_util.h index c07cdcf7ba7..765f54dfb5a 100644 --- a/src/mesa/math/m_debug_util.h +++ b/src/mesa/math/m_debug_util.h @@ -185,6 +185,44 @@ extern char *mesa_profile; #endif +#elif defined(__amd64__) + +#define rdtscll(val) do { \ + unsigned int a,d; \ + __asm__ volatile("rdtsc" : "=a" (a), "=d" (d)); \ + (val) = ((unsigned long)a) | (((unsigned long)d)<<32); \ +} while(0) + +/* Copied from i386 PIII version */ +#define INIT_COUNTER() \ + do { \ + int cycle_i; \ + counter_overhead = LONG_MAX; \ + for ( cycle_i = 0 ; cycle_i < 16 ; cycle_i++ ) { \ + unsigned long cycle_tmp1, cycle_tmp2; \ + rdtscll(cycle_tmp1); \ + rdtscll(cycle_tmp2); \ + if ( counter_overhead > (cycle_tmp2 - cycle_tmp1) ) { \ + counter_overhead = cycle_tmp2 - cycle_tmp1; \ + } \ + } \ + } while (0) + + +#define BEGIN_RACE(x) \ + x = LONG_MAX; \ + for ( cycle_i = 0 ; cycle_i < 10 ; cycle_i++ ) { \ + unsigned long cycle_tmp1, cycle_tmp2; \ + rdtscll(cycle_tmp1); \ + +#define END_RACE(x) \ + rdtscll(cycle_tmp2); \ + if ( x > (cycle_tmp2 - cycle_tmp1) ) { \ + x = cycle_tmp2 - cycle_tmp1; \ + } \ + } \ + x -= counter_overhead; + #elif defined(__sparc__) #define INIT_COUNTER() \ |