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