Chombo + EB + MF  3.2
ClockTicks.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _CLOCKTICKS_H_
12 #define _CLOCKTICKS_H_
13 
14 #include <chrono>
15 
16 // (dfm 4/29/08)note that NamespaceHeader.H gets included 3x, once for
17 // each "if"...
18 
19 #if defined(__INTEL_COMPILER) && defined(__ia64__)
20 #include <ia64intrin.h>
21 #include <ia64regs.h>
22 #include "BaseNamespaceHeader.H"
23 
24 inline unsigned long long int ch_ticks()
25 {
26  volatile unsigned long long int rtn = __getReg(_IA64_REG_AR_ITC);
27  return rtn;
28 }
29 #define CH_TICKS
30 
31 #elif defined(__x86_64__) || defined(__i386__) || defined(__i686__)
32 #include "BaseNamespaceHeader.H"
33 
34 union clockunion
35 {
36  unsigned int i[2];
37  unsigned long long int l;
38 };
39 
40 inline unsigned long long int ch_ticks()
41 {
42  volatile clockunion ret;
43  __asm__ __volatile__ ("rdtsc" : "=a"(ret.i[0]), "=d"(ret.i[1]));
44  return ret.l;
45 
46  // for some reason this form executes on 64, bit acts funny.
47  // unsigned long long int rtn;
48  // __asm__ __volatile__("rdtsc" : "=A"(rtn));
49  // return rtn;
50 }
51 #define CH_TICKS
52 
53 #elif defined(_POWER) || defined(_POWERPC) || defined(__powerpc__)
54 #include "BaseNamespaceHeader.H"
55 
56 inline unsigned long long int ch_ticks()
57 {
58  volatile unsigned long long int tbr;
59  __asm__ __volatile__("mftb %[tbr]" : [tbr] "=r" (tbr):);
60  return tbr;
61 }
62 #define CH_TICKS
63 #else
64 inline unsigned long long int ch_ticks()
65 {
66  return std::chrono::high_resolution_clock::now().time_since_epoch().count();
67 }
68 #define CH_TICKS
69 #include "BaseNamespaceHeader.H"
70 #endif
71 
72 #include "BaseNamespaceFooter.H"
73 #endif
unsigned long long int ch_ticks()
Definition: ClockTicks.H:64
Fail now
Definition: BaseNamespaceFooter.H:15