Created
January 7, 2018 02:52
-
-
Save richinseattle/39a6e2bc92e4869260f761f42d69db8c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ulong time_page_fetch (ulong addr) | |
| { | |
| volatile ulong v=0; | |
| asm volatile ( | |
| " movq %0, %%rsi \n" | |
| :: "m"(addr) | |
| ); | |
| asm volatile ( | |
| " xor %eax, %eax \n" | |
| " rdtsc \n" | |
| " shl $32, %rdx \n" | |
| " orq %rax, %rdx \n" | |
| " movl $1000000, %edi \n" | |
| "pf: prefetcht0 (%rsi) \n" | |
| " decl %edi \n" | |
| " jne pf \n" | |
| " movq %rdx, %rdi \n" | |
| " xor %eax, %eax \n" | |
| " rdtsc \n" | |
| " shl $32, %rdx \n" | |
| " orq %rax, %rdx \n" | |
| " subq %rdi, %rdx \n" | |
| ); | |
| asm volatile ( | |
| " movq %%rdx, %0 \n" | |
| :: "m"(v) | |
| ); | |
| return v; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment