- /* x86_rdtscp_siewior1.c */
- /*
- Results:
- root@EPU-102054501-AugustToepfer:~/x86_rdtscp# ./x86_rdtscp_siewior1
- CPU : 0
- CPUv2: 0 TS 0x1896116ed97bec
- root@EPU-102054501-AugustToepfer:~/x86_rdtscp# ./x86_rdtscp_siewior1
- CPU : 0
- CPUv2: 0 TS 0x189611d176dccc
- root@EPU-102054501-AugustToepfer:~/x86_rdtscp# ./x86_rdtscp_siewior1
- CPU : 0
- CPUv2: 0 TS 0x1896121adfeb94
- root@EPU-102054501-AugustToepfer:~/x86_rdtscp# ./x86_rdtscp_siewior1
- CPU : 1
- CPUv2: 0 TS 0x189612ab407b60
- root@EPU-102054501-AugustToepfer:~/x86_rdtscp# ./x86_rdtscp_siewior1
- CPU : 1
- CPUv2: 0 TS 0x189613730e0678
- root@EPU-102054501-AugustToepfer:~/x86_rdtscp# ./x86_rdtscp_siewior1
- CPU : 0
- CPUv2: 0 TS 0x189613e707ae7c
- */
- #define _GNU_SOURCE 1
- #include <stdio.h>
- #include <sched.h>
- static inline unsigned int rdtscp(unsigned long long *ts)
- {
- unsigned int eax, edx;
- unsigned int cpuid;
- __asm__ __volatile__("rdtscp" : "=a"(eax), "=d"(edx), "=c"(cpuid));
- *ts = ((unsigned long long)edx) << 32 | eax;
- return cpuid;
- }
- int main(void)
- {
- unsigned int cpu;
- unsigned long long tsc;
- unsigned int cpu_v2;
- cpu = sched_getcpu();
- cpu_v2 = rdtscp(&tsc);
- return 0;
- }
x86_rdtscp_siewior1.c, try #001
Posted by Anonymous on Thu 17th Nov 2022 15:48
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.