Created
July 7, 2014 14:24
-
-
Save jonathan-beard/ed2f3bba8ae5f2f33280 to your computer and use it in GitHub Desktop.
This file contains 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
std::uint64_t cycles( 0 ); | |
/** begin assembly section to init previous **/ | |
#ifdef __x86_64 | |
__asm__ volatile( | |
#if RDTSCP | |
"\ | |
rdtscp \n\ | |
shl $32, %%rdx \n\ | |
orq %%rax, %%rdx \n\ | |
movq %%rdx, %[cyc]" | |
#elif defined INTEL | |
"\ | |
lfence \n\ | |
rdtsc \n\ | |
shl $32, %%rdx \n\ | |
orq %%rax, %%rdx \n\ | |
movq %%rdx, %[cyc]" | |
#elif defined AMD | |
"\ | |
mfence \n\ | |
rdtsc \n\ | |
shl $32, %%rdx \n\ | |
orq %%rax, %%rdx \n\ | |
movq %%rdx, %[cyc]" | |
#elif NOSERIAL | |
"\ | |
rdtsc \n\ | |
shl $32, %%rdx \n\ | |
orq %%rax, %%rdx \n\ | |
movq %%rdx, %[cyc]" | |
#endif | |
: | |
/*outputs here*/ | |
[cyc] "=r" (cycles) | |
: | |
/*inputs here*/ | |
: | |
/*clobbered registers*/ | |
"rax","eax","rcx","ecx","rdx" | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment