Chombo + EB + MF  3.2
CH_Counters.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 _CH_COUNTERS_H_
12 #define _CH_COUNTERS_H_
13 
14 #include <sys/time.h>
15 #include <iostream>
16 
17 #ifdef CH_PAPI
18 #include <papi.h>
19 #endif
20 
21 #include "FortranNameMacro.H"
22 
23 // These objects are outside all namespaces. ch_timer is a COMMON BLOCK with the Fortran code
24 // and is defined in CH_CounterF.f. In the longer run I will need to make ch_flops
25 // atomic, or threadprivate, and do the same for the m_flop data member in CH_Timer
26 #include "BaseNamespaceHeader.H"
27 
28 extern "C"{
29  extern struct{
30  long long int ch_flops;
31  } FORTRAN_BASENAME(CH_TIMER,ch_timer);
32 }
33 
34 
35 inline double TimerGetTimeStampWC()
36 {
37  struct timeval tv; // Values from call to gettimeofday
38  struct timezone tz;
39  gettimeofday(&tv, &tz);
40  return((double)tv.tv_sec + 0.000001 * (double)tv.tv_usec);
41 }
42 
43 
44 #define NCOUNTERS 3
45 extern long long int ch_counters[NCOUNTERS];
46 extern int ch_eventset;
47 
48 inline long long int& ch_flops(){ return FORTRAN_BASENAME(CH_TIMER,ch_timer).ch_flops;}
49 
50 
51 void CountersInit();
52 
53 inline void readCounters()
54 {
55 #ifdef CH_PAPI
56  PAPI_read(ch_eventset, ch_counters);
57 #endif
58 }
59 
60 void streamDump(std::ostream& os);
61 
62 #include "BaseNamespaceFooter.H"
63 #endif
void readCounters()
Definition: CH_Counters.H:53
long long int ch_counters[NCOUNTERS]
double TimerGetTimeStampWC()
Definition: CH_Counters.H:35
void CountersInit()
struct @1 FORTRAN_BASENAME(CH_TIMER, ch_timer)
int ch_eventset
#define CH_TIMER(name, tpointer)
Definition: CH_Timer.H:63
#define NCOUNTERS
Definition: CH_Counters.H:44
void streamDump(std::ostream &os)
long long int ch_flops
Definition: CH_Counters.H:30