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 // (dfm 4/29/08)note that NamespaceHeader.H gets included 3x, once for
15 // each "if"...
16 
17 #if defined(__INTEL_COMPILER) && defined(__ia64__)
18 #include <ia64intrin.h>
19 #include <ia64regs.h>
20 #include "BaseNamespaceHeader.H"
21 
22 inline unsigned long long int ch_ticks()
23 {
24  volatile unsigned long long int rtn = __getReg(_IA64_REG_AR_ITC);
25  return rtn;
26 }
27 #define CH_TICKS
28 
29 #elif defined(__x86_64__) || defined(__i386__) || defined(__i686__)
30 #include "BaseNamespaceHeader.H"
31 
32 union clockunion
33 {
34  unsigned int i[2];
35  unsigned long long int l;
36 };
37 
38 inline unsigned long long int ch_ticks()
39 {
40  volatile clockunion ret;
41  __asm__ __volatile__ ("rdtsc" : "=a"(ret.i[0]), "=d"(ret.i[1]));
42  return ret.l;
43 
44  // for some reason this form executes on 64, bit acts funny.
45  // unsigned long long int rtn;
46  // __asm__ __volatile__("rdtsc" : "=A"(rtn));
47  // return rtn;
48 }
49 #define CH_TICKS
50 
51 #elif defined(_POWER) || defined(_POWERPC) || defined(__powerpc__)
52 #include "BaseNamespaceHeader.H"
53 
54 inline unsigned long long int ch_ticks()
55 {
56  volatile unsigned long long int tbr;
57  __asm__ __volatile__("mftb %[tbr]" : [tbr] "=r" (tbr):);
58  return tbr;
59 }
60 #define CH_TICKS
61 #else
62 // if we fall all the way through to here, we don't really do anything,
63 // but we still need the NamespaceHeader to balance
64 // the namespacefooter. (DFM 4/28/09)
65 #include "BaseNamespaceHeader.H"
66 #endif
67 
68 #include "BaseNamespaceFooter.H"
69 #endif