]>
Commit | Line | Data |
---|---|---|
23e3fea5 | 1 | #ifndef TIMING_H |
2 | #define TIMING_H | |
3 | ||
4 | #define NUM_TIMINGS 10000 | |
5 | #define ITERATIONS 1000 | |
6 | ||
7 | int compareDouble(const void *x, const void *y) | |
8 | { | |
9 | double xx = *(double*)x, yy = *(double*)y; | |
10 | if (xx < yy) return -1; | |
11 | if (xx > yy) return 1; | |
12 | return 0; | |
13 | } | |
14 | ||
15 | unsigned long long int startTimer(void) | |
16 | { | |
17 | unsigned a, d; | |
18 | ||
19 | __asm__ volatile("CPUID\n\t" | |
20 | "RDTSC\n\t" | |
21 | "mov %%edx, %0\n\t" | |
22 | "mov %%eax, %1\n\t": "=r" (d), | |
23 | "=r" (a):: "%rax", "%rbx", "%rcx", "%rdx"); | |
24 | ||
25 | return ((unsigned long long)a) | (((unsigned long long)d) << 32);; | |
26 | } | |
27 | ||
28 | unsigned long long int endTimer(void) | |
29 | { | |
30 | unsigned a, d; | |
31 | ||
32 | __asm__ volatile("RDTSCP\n\t" | |
33 | "mov %%edx, %0\n\t" | |
34 | "mov %%eax,%1\n\t" | |
35 | "CPUID\n\t": "=r" (d), "=r" (a):: | |
36 | "%rax", "%rbx", "%rcx", "%rdx"); | |
37 | ||
38 | return ((unsigned long long)a) | (((unsigned long long)d) << 32);; | |
39 | } | |
40 | ||
41 | #endif |