How to Benchmark Code Execution Times on Intel IA-32 and IA-64 ...
How to Benchmark Code Execution Times on Intel IA-32 and IA-64 ...
How to Benchmark Code Execution Times on Intel IA-32 and IA-64 ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<str<strong>on</strong>g>How</str<strong>on</strong>g> <str<strong>on</strong>g>to</str<strong>on</strong>g> <str<strong>on</strong>g>Benchmark</str<strong>on</strong>g> <str<strong>on</strong>g>Code</str<strong>on</strong>g> <str<strong>on</strong>g>Executi<strong>on</strong></str<strong>on</strong>g> <str<strong>on</strong>g>Times</str<strong>on</strong>g> <strong>on</strong> <strong>Intel</strong> ® <strong>IA</strong>-<strong>32</strong><br />
<strong>and</strong> <strong>IA</strong>-<strong>64</strong> Instructi<strong>on</strong> Set Architectures<br />
5 Appendix<br />
1 #include <br />
2 #include <br />
3 #include <br />
4 #include <br />
5 #include <br />
6 #include <br />
7<br />
8 #define SIZE_OF_STAT 100000<br />
9 #define BOUND_OF_LOOP 1000<br />
10 #define UINT<strong>64</strong>_MAX (18446744073709551615ULL)<br />
11<br />
12 void inline Filltimes(uint<strong>64</strong>_t **times) {<br />
13 unsigned l<strong>on</strong>g flags;<br />
14 int i, j;<br />
15 uint<strong>64</strong>_t start, end;<br />
16 unsigned cycles_low, cycles_high, cycles_low1, cycles_high1;<br />
17 volatile int variable = 0;<br />
18<br />
19 asm volatile ("CPUID\n\t"<br />
20 "RDTSC\n\t"<br />
21 "mov %%edx, %0\n\t"<br />
22 "mov %%eax, %1\n\t": "=r" (cycles_high), "=r" (cycles_low)::<br />
"%rax", "%rbx", "%rcx", "%rdx");<br />
23 asm volatile ("CPUID\n\t"<br />
24 "RDTSC\n\t"<br />
25 "CPUID\n\t"<br />
26 "RDTSC\n\t"<br />
27 "mov %%edx, %0\n\t"<br />
28 "mov %%eax, %1\n\t": "=r" (cycles_high), "=r" (cycles_low)::<br />
"%rax", "%rbx", "%rcx", "%rdx");<br />
29 asm volatile ("CPUID\n\t"<br />
30 "RDTSC\n\t"::: "%rax", "%rbx", "%rcx", "%rdx");<br />
31<br />
<strong>32</strong><br />
33 for (j=0; j