00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef IPPL_STATS_H
00012 #define IPPL_STATS_H
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include "Utility/IpplInfo.h"
00040 #include "Utility/Timer.h"
00041 #include "Utility/Inform.h"
00042 #include "Utility/Pstring.h"
00043
00044 #ifdef IPPL_STDSTL
00045 #include <vector>
00046 using std::vector;
00047 #else
00048 #include <vector.h>
00049 #endif
00050
00051
00052 class IpplStats {
00053
00054 public:
00055
00056 IpplStats();
00057
00058
00059 ~IpplStats();
00060
00061
00062 void print(Inform &);
00063
00064
00065
00066
00067 int addStat(const char *description, long initval = 0) {
00068 StatList.push_back(new StatData(description, initval, true));
00069 return (StatList.size() - 1);
00070 }
00071
00072
00073
00074 long incStat(int statindx, long val = 1) {
00075 StatList[statindx]->Value += val;
00076 return StatList[statindx]->Value;
00077 }
00078 long decStat(int statindx, long val = 1) {
00079 StatList[statindx]->Value -= val;
00080 return StatList[statindx]->Value;
00081 }
00082
00083
00084
00085
00086
00087
00088 Timer &getTime() { return Time; }
00089
00090
00091
00092
00093
00094 void incMessageSent() { ++MessagesSent.Value; }
00095 void incMessageSentToOthers() { ++MessagesSentToOthers.Value; }
00096 void incMessageSentToSelf() { ++MessagesSentToSelf.Value; }
00097 void incMessageReceived() { ++MessagesReceived.Value; }
00098 void incMessageReceivedFromNetwork() { ++MessagesReceivedFromNetwork.Value;}
00099 void incMessageReceivedFromQueue() { ++MessagesReceivedFromQueue.Value; }
00100 void incMessageReceiveChecks() { ++MessageReceiveChecks.Value; }
00101 void incMessageReceiveChecksFailed() { ++MessageReceiveChecksFailed.Value; }
00102 void incMessageBytesSent(long bytes) { BytesSent.Value += bytes; }
00103 void incMessageBytesReceived(long bytes) { BytesReceived.Value += bytes; }
00104 void incBarriers() { ++Barriers.Value; }
00105 void incReductions() { ++Reductions.Value; }
00106 void incScatters() { ++Scatters.Value; }
00107
00108
00109
00110
00111
00112 void incBareFields() { ++BareFields.Value; }
00113 void incLFields() { ++LFields.Value; }
00114 void incLFieldBytes(long bytes) { LFieldBytes.Value += bytes; }
00115 void incFieldLayouts() { ++FieldLayouts.Value; }
00116 void incRepartitions() { ++Repartitions.Value; }
00117 void incExpressions() { ++Expressions.Value; }
00118 void incBFEqualsExpression() { ++BFEqualsExpression.Value; }
00119 void incIBFEqualsExpression() { ++IBFEqualsExpression.Value; }
00120 void incParensEqualsExpression() { ++ParensEqualsExpression.Value; }
00121 void incBFEqualsBF() { ++BFEqualsBF.Value; }
00122 void incIBFEqualsIBF() { ++IBFEqualsIBF.Value; }
00123 void incSubEqualsExpression() { ++SubEqualsExpression.Value; }
00124 void incFFTs() { ++FFTs.Value; }
00125 void incGuardCellFills() { ++GuardCellFills.Value; }
00126 void incBoundaryConditions() { ++BoundaryConditions.Value; }
00127 void incCompresses() { ++Compresses.Value; }
00128 void incDecompresses() { ++Decompresses.Value; }
00129 void incCompressionCompares(long c) { CompressionCompares.Value += c; }
00130 void incCompressionCompareMax(long c) { CompressionCompareMax.Value += c; }
00131 void incBareFieldIterators() { ++BareFieldIterators.Value; }
00132 void incDefaultBareFieldIterators() { ++DefaultBareFieldIterators.Value; }
00133 void incBeginScalarCodes() { ++BeginScalarCodes.Value; }
00134 void incEndScalarCodes() { ++EndScalarCodes.Value; }
00135
00136
00137
00138
00139 void incParticleAttribs() { ++ParticleAttribs.Value; }
00140 void incParticleBases() { ++ParticleBases.Value; }
00141 void incParticleUpdates() { ++ParticleUpdates.Value; }
00142 void incParticleExpressions() { ++ParticleExpressions.Value; }
00143 void incParticleGathers() { ++ParticleGathers.Value; }
00144 void incParticleScatters() { ++ParticleScatters.Value; }
00145 void incParticlesCreated(long num) { ParticlesCreated.Value += num; }
00146 void incParticlesDestroyed(long num) { ParticlesDestroyed.Value += num; }
00147 void incParticlesSwapped(long num) { ParticlesSwapped.Value += num; }
00148
00149
00150
00151
00152
00153 void incDiscReads() { ++DiscReads.Value; }
00154 void incDiscWrites() { ++DiscWrites.Value; }
00155 void incDiscFilesetReads(long f) { DiscFilesetReads.Value += f; }
00156 void incDiscFilesetWrites(long f) { DiscFilesetWrites.Value += f; }
00157 void incDiscBytesRead(long b) { DiscBytesRead.Value += b; }
00158 void incDiscBytesWritten(long b) { DiscBytesWritten.Value += b; }
00159
00160 private:
00161
00162 struct StatData {
00163
00164 StatData(vector<StatData *> &datalist, const char *nm, long initval = 0,
00165 bool needDelete = false)
00166 : Value(initval), Name(nm), NeedDelete(needDelete) {
00167
00168 datalist.push_back(this);
00169 }
00170
00171
00172 StatData(const char *nm, long initval = 0, bool needDelete = false)
00173 : Value(initval), Name(nm), NeedDelete(needDelete) { }
00174
00175
00176 StatData() : Value(0), Name("") { }
00177
00178
00179 ~StatData() { }
00180
00181
00182 long Value;
00183 string Name;
00184
00185
00186 bool NeedDelete;
00187 };
00188
00189
00190
00191
00192
00193 vector<StatData *> StatList;
00194
00195
00196
00197 Timer Time;
00198
00199
00200 StatData MessagesSent;
00201 StatData MessagesSentToOthers;
00202 StatData MessagesSentToSelf;
00203 StatData MessagesReceived;
00204 StatData MessagesReceivedFromNetwork;
00205 StatData MessagesReceivedFromQueue;
00206 StatData MessageReceiveChecks;
00207 StatData MessageReceiveChecksFailed;
00208 StatData BytesSent;
00209 StatData BytesReceived;
00210 StatData Barriers;
00211 StatData Reductions;
00212 StatData Scatters;
00213
00214 StatData BareFields;
00215 StatData LFields;
00216 StatData LFieldBytes;
00217 StatData FieldLayouts;
00218 StatData Repartitions;
00219 StatData Expressions;
00220 StatData BFEqualsExpression;
00221 StatData IBFEqualsExpression;
00222 StatData ParensEqualsExpression;
00223 StatData BFEqualsBF;
00224 StatData IBFEqualsIBF;
00225 StatData SubEqualsExpression;
00226 StatData FFTs;
00227 StatData GuardCellFills;
00228 StatData BoundaryConditions;
00229 StatData Compresses;
00230 StatData Decompresses;
00231 StatData CompressionCompares;
00232 StatData CompressionCompareMax;
00233 StatData BareFieldIterators;
00234 StatData DefaultBareFieldIterators;
00235 StatData BeginScalarCodes;
00236 StatData EndScalarCodes;
00237
00238 StatData ParticleAttribs;
00239 StatData ParticleBases;
00240 StatData ParticleUpdates;
00241 StatData ParticleExpressions;
00242 StatData ParticleGathers;
00243 StatData ParticleScatters;
00244 StatData ParticlesCreated;
00245 StatData ParticlesDestroyed;
00246 StatData ParticlesSwapped;
00247
00248 StatData DiscReads;
00249 StatData DiscWrites;
00250 StatData DiscFilesetReads;
00251 StatData DiscFilesetWrites;
00252 StatData DiscBytesRead;
00253 StatData DiscBytesWritten;
00254 };
00255
00256
00257
00258 #ifndef IPPL_NO_STATS
00259 # define INCIPPLSTAT(stat) Ippl::Stats->stat()
00260 # define ADDIPPLSTAT(stat,amount) Ippl::Stats->stat(amount)
00261 #else
00262 # define INCIPPLSTAT(stat)
00263 # define ADDIPPLSTAT(stat,amount)
00264 #endif
00265
00266 #endif
00267
00268
00269
00270
00271
00272
00273