1 |
|
|
/*************************************** |
2 |
|
|
Auteur : Pierre Aubert |
3 |
|
|
Mail : pierre.aubert@lapp.in2p3.fr |
4 |
|
|
Licence : CeCILL-C |
5 |
|
|
****************************************/ |
6 |
|
|
|
7 |
|
|
|
8 |
|
|
#include "phoenix_timer.h" |
9 |
|
|
|
10 |
|
|
#ifdef __i386 |
11 |
|
|
///Get the number of cycles since the begining of the program |
12 |
|
|
/** @return number of cycles since the begining of the program |
13 |
|
|
*/ |
14 |
|
|
extern long unsigned int phoenix_rdtsc(void) { |
15 |
|
|
long unsigned int x; |
16 |
|
|
__asm__ volatile ("rdtsc" : "=A" (x)); |
17 |
|
|
return x; |
18 |
|
|
} |
19 |
|
|
#elif defined __amd64 |
20 |
|
|
///Get the number of cycles since the begining of the program |
21 |
|
|
/** @return number of cycles since the begining of the program |
22 |
|
|
*/ |
23 |
|
24000 |
extern long unsigned int phoenix_rdtsc(void) { |
24 |
|
|
long unsigned int a, d; |
25 |
|
24000 |
__asm__ volatile ("rdtsc" : "=a" (a), "=d" (d)); |
26 |
|
24000 |
return (d<<32) | a; |
27 |
|
|
} |
28 |
|
|
#endif |
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|