00001 #ifdef CH_LANG_CC 00002 /* 00003 * _______ __ 00004 * / ___/ / ___ __ _ / / ___ 00005 * / /__/ _ \/ _ \/ V \/ _ \/ _ \ 00006 * \___/_//_/\___/_/_/_/_.__/\___/ 00007 * Please refer to Copyright.txt, in Chombo's root directory. 00008 */ 00009 #endif 00010 00011 #ifndef _CH_COUNTERS_H_ 00012 #define _CH_COUNTERS_H_ 00013 00014 #include <sys/time.h> 00015 #include <iostream> 00016 00017 #ifdef CH_PAPI 00018 #include <papi.h> 00019 #endif 00020 00021 #include "FortranNameMacro.H" 00022 00023 // These objects are outside all namespaces. ch_timer is a COMMON BLOCK with the Fortran code 00024 // and is defined in CH_CounterF.f. In the longer run I will need to make ch_flops 00025 // atomic, or threadprivate, and do the same for the m_flop data member in CH_Timer 00026 #include "BaseNamespaceHeader.H" 00027 00028 extern "C"{ 00029 extern struct{ 00030 long long int ch_flops; 00031 } FORTRAN_BASENAME(CH_TIMER,ch_timer); 00032 } 00033 00034 00035 inline double TimerGetTimeStampWC() 00036 { 00037 struct timeval tv; // Values from call to gettimeofday 00038 struct timezone tz; 00039 gettimeofday(&tv, &tz); 00040 return((double)tv.tv_sec + 0.000001 * (double)tv.tv_usec); 00041 } 00042 00043 00044 #define NCOUNTERS 3 00045 extern long long int ch_counters[NCOUNTERS]; 00046 extern int ch_eventset; 00047 00048 inline long long int& ch_flops(){ return FORTRAN_BASENAME(CH_TIMER,ch_timer).ch_flops;} 00049 00050 00051 void CountersInit(); 00052 00053 inline void readCounters() 00054 { 00055 #ifdef CH_PAPI 00056 PAPI_read(ch_eventset, ch_counters); 00057 #endif 00058 } 00059 00060 void streamDump(std::ostream& os); 00061 00062 #include "BaseNamespaceFooter.H" 00063 #endif