38#ifndef MADNESS_WORLD_TIMERS_H__INCLUDED
39#define MADNESS_WORLD_TIMERS_H__INCLUDED
50#include <catamount/dclock.h>
54# define BG_CYCLES_PER_MICROSECOND 850
55# define BG_SECONDS_PER_CYCLE 1.176470588235294033e-09
56# include </bgsys/drivers/ppcfloor/arch/include/bpcore/ppc450_inlines.h>
60# define BG_CYCLES_PER_MICROSECOND 1600
61# define BG_SECONDS_PER_CYCLE 6.25e-10
62# include <hwi/include/bqc/A2_inlines.h>
84#if defined(HAVE_IBMBGP)
85 unsigned int rx, ry, rz;
88 asm volatile (
"mftbu %0" :
"=r"(rx) );
89 asm volatile (
"mftb %0" :
"=r"(ry) );
90 asm volatile (
"mftbu %0" :
"=r"(rz) );
95#elif defined(HAVE_IBMBGQ)
99 __asm__
volatile(
".byte 0x0f, 0x31" :
"=A"(x));
102 __asm__
volatile(
"rdtsc" :
"=a"(
a),
"=d"(
d));
103 x = ((uint64_t)
a) | (((uint64_t)
d)<<32);
129#if defined(X86_32) || defined(X86_64) || defined(HAVE_IBMBGP)
134#elif defined(HAVE_IBMBGP)
135 return BG_SECONDS_PER_CYCLE * _bgp_GetTimeBase();
136#elif defined(HAVE_IBMBGQ)
137 return BG_SECONDS_PER_CYCLE * GetTimeBase();
139 const auto now = std::chrono::steady_clock::now();
140 const auto nanoseconds_since_epoch = std::chrono::duration_cast<std::chrono::nanoseconds>(now.time_since_epoch()).count();
141 return nanoseconds_since_epoch / 1e9;
153#if defined(CLOCK_PROCESS_CPUTIME_ID)
155 if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) == 0) {
156 return static_cast<double>(ts.tv_sec) + 1.0e-9 *
static_cast<double>(ts.tv_nsec);
159 return static_cast<double>(std::clock()) /
static_cast<double>(CLOCKS_PER_SEC);
167#if defined(X86_32) || defined(X86_64)
168 asm volatile(
"rep;nop" : : :
"memory");
169#elif defined(__aarch64__) || defined(__arm__)
172 asm volatile(
"yield" : : :
"memory");
173#elif defined(HAVE_IBMBGP) || defined(HAVE_IBMBGQ)
174 asm volatile (
"nop\n");
178 asm volatile (
"nop\n");
187#if defined(HAVE_CRAYXT)
188 double secs = us*1
e-6;
193#elif defined(HAVE_IBMBGP) || defined(HAVE_IBMBGQ)
194 int count = BG_CYCLES_PER_MICROSECOND*us;
195 for (
int i=0; i<count; i++) {
196 asm volatile (
"nop\n");
Macros and tools pertaining to the configuration of MADNESS.
Namespace for all elements and tools of MADNESS.
Definition DFConvergence.h:9
static double process_cpu_time()
Returns the CPU time consumed by this process, in seconds.
Definition timers.h:152
static double cpu_time()
Returns the cpu time in seconds relative to an arbitrary origin.
Definition timers.h:128
static void myusleep(unsigned int us)
Sleep or spin for specified number of microseconds.
Definition timers.h:186
double cpu_frequency()
Estimate the processor frequency, in Hz.
Definition timers.cc:79
double wall_time()
Returns the wall time in seconds relative to an arbitrary origin.
Definition timers.cc:48
void cpu_relax()
Do nothing and especially do not touch memory.
Definition timers.h:166
static uint64_t cycle_count()
On some machines we have access to a cycle count.
Definition timers.h:82
static const double d
Definition nonlinschro.cc:121
static const double a
Definition nonlinschro.cc:118
void e()
Definition test_sig.cc:75