This source file includes following definitions.
- pmix_sys_timer_get_cycles
- pmix_sys_timer_is_monotonic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #ifndef PMIX_SYS_ARCH_TIMER_H
24 #define PMIX_SYS_ARCH_TIMER_H 1
25
26
27 typedef uint64_t pmix_timer_t;
28
29
30 #undef PMIX_TIMER_MONOTONIC
31 #define PMIX_TIMER_MONOTONIC 0
32
33 #if PMIX_GCC_INLINE_ASSEMBLY
34
35
36 static inline pmix_timer_t
37 pmix_sys_timer_get_cycles(void)
38 {
39 uint32_t l, h;
40 __asm__ __volatile__ ("lfence\n\t"
41 "rdtsc\n\t"
42 : "=a" (l), "=d" (h));
43 return ((pmix_timer_t)l) | (((pmix_timer_t)h) << 32);
44 }
45
46 static inline bool pmix_sys_timer_is_monotonic (void)
47 {
48 int64_t tmp;
49 int32_t cpuid1, cpuid2;
50 const int32_t level = 0x80000007;
51
52
53
54 __asm__ volatile ("xchg %%rbx, %2\n"
55 "cpuid\n"
56 "xchg %%rbx, %2\n":
57 "=a" (cpuid1), "=d" (cpuid2), "=r" (tmp) :
58 "a" (level) :
59 "ecx", "ebx");
60
61 return !!(cpuid2 & (1 << 8));
62 }
63
64 #define PMIX_HAVE_SYS_TIMER_GET_CYCLES 1
65 #define PMIX_HAVE_SYS_TIMER_IS_MONOTONIC 1
66
67 #else
68
69 pmix_timer_t pmix_sys_timer_get_cycles(void);
70
71 #define PMIX_HAVE_SYS_TIMER_GET_CYCLES 1
72
73 #endif
74
75 #endif