Shared Persistent Heap Data Environment Manual
1.1.0
|
Functions to access the Time Base register (PPC) or clock_gettime(CLOCK_MONOTONIC) measure time at high resolution. The POWER timebase is safe to use because it is; separate from CPU clock, invariant, and synchronized across cores and sockets. More...
#include <time.h>
Go to the source code of this file.
Macros | |
#define | __C__ |
ignore this macro behind the curtain. | |
#define | __TIME_BASE(__time_v) |
Read the Time Base value. More... | |
Typedefs | |
typedef unsigned long long int | sphtimer_t |
Value from TB/TSC register (64-bits on all platforms). | |
Functions | |
static sphtimer_t | sphgettimer (void) |
Read and return the Timebase value. More... | |
__C__ sphtimer_t | sphgetcpufreq (void) |
Return the Timebase update frequency. More... | |
static sphtimer_t | sphfastcpufreq (void) |
Return the Timebase update frequency (fast version). More... | |
Variables | |
sphtimer_t | sph_cpu_frequency |
Frequency which Timebase is updated by system. More... | |
Functions to access the Time Base register (PPC) or clock_gettime(CLOCK_MONOTONIC) measure time at high resolution. The POWER timebase is safe to use because it is; separate from CPU clock, invariant, and synchronized across cores and sockets.
The Intel (x86/x86_64) Time Stamp Counter is not invariant except on the latest processors. As we want to support earlier processors back to the initial Core2 design, we use clock_gettime (CLOCK_MONOTONIC) by default for Intel. On modern Linux kernels, clock_gettime is implemented as a VDSO function which provides reasonable performance.
Where applications know they will be running on Intel processors with invariant TSC they can enable inlined rdtsc timers by defining __x86_64_INVARIANT_TSC and/or __x86_INVARIANT_TSC and rebuilding libsphde.
The TB/CLOCK_MONOTONIC value can be obtained using the function sphgettimer and the update frequency by using the functions sphgetcpufreq or preferably sphfastcpufreq.
For instance, to measure the time spend in some computation:
#define __TIME_BASE | ( | __time_v | ) |
Read the Time Base value.
|
inlinestatic |
Return the Timebase update frequency (fast version).
Will not read the Timebase frequency if the value was already cached (the function sphgetcpufreq forces an read/update of sph_cpu_frequency).
__C__ sphtimer_t sphgetcpufreq | ( | void | ) |
Return the Timebase update frequency.
Reads the Timebase frequency and updates sph_cpu_frequency.
|
inlinestatic |
Read and return the Timebase value.
sphtimer_t sph_cpu_frequency |
Frequency which Timebase is updated by system.