11.01.2015 Views

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 ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<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 />

asm volatile( "CPUID\n\t"<br />

"RDTSC\n\t"<br />

"mov %%edx, %0\n\t"<br />

"mov %%eax, %1\n\t": "=r" (cycles_high), "=r" (cycles_low)::<br />

"%rax", "%rbx", "%rcx", "%rdx");<br />

asm volatile( "mov %%cr0, %%rax\n\t"<br />

"mov %%rax, %%cr0\n\t"<br />

"RDTSC\n\t"<br />

"mov %%edx, %0\n\t"<br />

"mov %%eax, %1\n\t": "=r" (cycles_high1), "=r" (cycles_low1)::<br />

"%rax", "%rdx");<br />

asm volatile( "CPUID\n\t"<br />

"RDTSC\n\t"<br />

"mov %%edx, %0\n\t"<br />

"mov %%eax, %1\n\t": "=r" (cycles_high), "=r" (cycles_low)::<br />

"%rax", "%rbx", "%rcx", "%rdx");<br />

asm volatile( "mov %%cr0, %%rax\n\t"<br />

"mov %%rax, %%cr0\n\t"<br />

"RDTSC\n\t"<br />

"mov %%edx, %0\n\t"<br />

"mov %%eax, %1\n\t": "=r" (cycles_high1), "=r" (cycles_low1)::<br />

"%rax", "%rdx");<br />

for (j=0; j

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!