00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _OLDTIMER_H_
00012 #define _OLDTIMER_H_
00013
00014 #ifndef CH_NTIMER
00015
00016 #ifdef CH_AIX
00017 #define FOUR_COUNTERS
00018 #endif
00019
00020 #include <cstdio>
00021 #include "REAL.H"
00022 #include "MayDay.H"
00023 #include "Vector.H"
00024 #include "ClockTicks.H"
00025 #ifdef CH_MPI
00026 #include "mpi.h"
00027 #endif
00028
00029 extern "C"
00030 {
00031
00032 #include <unistd.h>
00033 #include <sys/time.h>
00034
00035
00036
00037
00038 #ifdef PAPI
00039 #include <papi.h>
00040 #endif
00041 }
00042
00043 #ifndef TIMER_COUNTER
00044 #define TIMER_COUNTER 0
00045 #endif
00046
00047 #include <list>
00048 #include <string>
00049 #include "List.H"
00050
00051 #include <string>
00052 #include <iostream>
00053 #include "BaseNamespaceHeader.H"
00054
00055 using namespace std;
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 class OldTimer
00072 {
00073 public:
00074
00075
00076
00077
00078 OldTimer();
00079
00080 OldTimer(const string& a_name, const int a_tableID);
00081 OldTimer(const string& a_name, OldTimer&, const int a_tableID);
00082 OldTimer(const string& a_name, OldTimer&);
00083 OldTimer(const string& a_name, OldTimer&, const int a_tableID, bool);
00084
00085 ~OldTimer();
00086
00087 void setup();
00088 void start();
00089 void stop();
00090 void stop(Real& wc1);
00091 void clear();
00092
00093 inline double getTimeStampWC();
00094 double wc_time()
00095 {
00096 return m_accumulated_WCtime;
00097 }
00098 double mflops();
00099 void writeTotalPct(const string& a_extra = "");
00100
00101 #ifdef PAPI
00102 long long int papi_counter0()
00103 {
00104 return m_accumulated_counter0;
00105 }
00106 long long int papi_counter1()
00107 {
00108 return m_accumulated_counter1;
00109 }
00110 double total_papi_counter0()
00111 {
00112 return m_totalPapiCounter0;
00113 }
00114 double total_papi_counter1()
00115 {
00116 return m_totalPapiCounter1;
00117 }
00118 #ifdef FOUR_COUNTERS
00119 long long int papi_counter2()
00120 {
00121 return m_accumulated_counter2;
00122 }
00123 long long int papi_counter3()
00124 {
00125 return m_accumulated_counter3;
00126 }
00127 double total_papi_counter2()
00128 {
00129 return m_totalPapiCounter2;
00130 }
00131 double total_papi_counter3()
00132 {
00133 return m_totalPapiCounter3;
00134 }
00135 #endif
00136 #endif
00137
00138 string Name()
00139 {
00140 return m_name;
00141 }
00142 long long int Count()
00143 {
00144 return m_count;
00145 }
00146 int tableID()
00147 {
00148 return m_tableID;
00149 }
00150
00151 static list<OldTimer*> *TimerList;
00152
00153 static void TimerSummary(const int bert, const int ernie)
00154 {
00155 TimerSummary();
00156 }
00157
00158 static void TimerInit(const int rank);
00159 static void TimerSummary(void);
00160 static void TimerSummaryWithTITAfiles(void);
00161
00162 private:
00163
00164
00165 static void TimerSummary_(const int itita);
00166 static void writeParentTables(FILE *out, const double TimerCost);
00167 static void writeDiagnosticTables(FILE *out, const double TimerCost);
00168
00169
00170 int m_tableID;
00171
00172 double m_accumulated_WCtime, m_last_WCtime_stamp;
00173
00174
00175 #ifndef CH_MPI
00176 struct timeval tv;
00177 struct timezone tz;
00178 #endif
00179
00180 int m_ID;
00181 string m_name;
00182 bool m_diagnostic;
00183 OldTimer& m_Parent;
00184
00185 bool m_evenCountAcrossRanks;
00186 double m_avgWC, m_minWC, m_maxWC, m_avgCount;
00187
00188 #ifdef PAPI
00189 long long int m_accumulated_counter0;
00190 long long int m_accumulated_counter1;
00191 long long int m_previous_counter0;
00192 long long int m_previous_counter1;
00193 double m_totalPapiCounter0;
00194 double m_totalPapiCounter1;
00195 #ifdef FOUR_COUNTERS
00196 long long int m_values[4];
00197 long long int m_accumulated_counter2;
00198 long long int m_accumulated_counter3;
00199 long long int m_previous_counter2;
00200 long long int m_previous_counter3;
00201 double m_totalPapiCounter2;
00202 double m_totalPapiCounter3;
00203 #else
00204 long long int m_values[2];
00205 #endif
00206 #endif
00207
00208 long long int m_count;
00209 long long int m_totalCount;
00210 };
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354 #include "BaseNamespaceFooter.H"
00355 #endif // CH_NTIMER
00356
00357 #endif // CH_OLDTIMER_H