00001
00002
00007 #ifndef GVT_H
00008 #define GVT_H
00009 #include "gvt.decl.h"
00010
00012 #define OPTIMISTIC 0
00013 #define CONSERVATIVE 1
00014
00016 extern CkGroupID ThePVT;
00017 extern CkGroupID TheGVT;
00018
00019 class SRtable;
00020 class SRentry;
00021
00022 void POSE_sumGVTIterations(void *param, void *msg);
00023
00025
00027 class UpdateMsg : public CMessage_UpdateMsg {
00028 public:
00030
00031 POSE_TimeType optPVT;
00033 POSE_TimeType conPVT;
00035 POSE_TimeType maxSR;
00037 SRentry *SRs;
00039 int numEntries;
00041 int inactive;
00043 POSE_TimeType inactiveTime;
00045 int nextLB;
00047 int runGVTflag;
00048 };
00049
00051 class GVTMsg : public CMessage_GVTMsg {
00052 public:
00054 POSE_TimeType estGVT;
00056 int done;
00057 };
00058
00060 class prioBcMsg : public CMessage_prioBcMsg {
00061 public:
00062 int bc;
00063 };
00064
00066
00069 class PVT : public Group {
00070 private:
00071 #if !CMK_TRACE_DISABLED
00072 localStat *localStats;
00073 #endif
00075 POSE_TimeType optPVT;
00077 POSE_TimeType conPVT;
00079 POSE_TimeType estGVT;
00081 POSE_TimeType repPVT;
00083 int simdone;
00085 POSE_TimeType iterMin;
00087
00088 int waitForFirst;
00090 SRtable *SendsAndRecvs;
00092 pvtObjects objs;
00094 int reportTo, reportsExpected, reportReduceTo, reportEnd;
00096 int gvtTurn;
00097 int specEventCount, eventCount;
00099 int startPhaseActive;
00101 double parStartTime;
00103 int parCheckpointInProgress;
00105 POSE_TimeType parLastCheckpointGVT;
00107 int parLBInProgress;
00109 POSE_TimeType parLastLBGVT;
00111 double parLastCheckpointTime;
00112
00114 POSE_TimeType optGVT, conGVT;
00115 int rdone;
00117 SRentry *SRs;
00118 #ifdef MEM_TEMPORAL
00119 TimePool *localTimePool;
00120 #endif
00122 // int debugBufferLoc, debugBufferWrapped, debugBufferDumped;
00123
00124
00125 public:
00127 PVT(void);
00129 PVT(CkMigrateMessage *msg) : Group(msg) { };
00131 void pup(PUP::er &p);
00133 ~PVT() { }
00135 void startPhase(prioBcMsg *m);
00137 void startPhaseExp(prioBcMsg *m);
00139
00141 void setGVT(GVTMsg *m);
00143 void beginCheckpoint(eventMsg *m);
00145 void resumeAfterCheckpoint(eventMsg *m);
00147 void beginLoadbalancing(eventMsg *m);
00149 void resumeAfterLB(eventMsg *m);
00151 void callAtSync();
00152 void doneLB();
00153
00155 inline POSE_TimeType getGVT() { return estGVT; }
00156
00157 inline int getSpecEventCount() { return specEventCount; }
00158 inline int getEventCount() { return eventCount; }
00159 inline void incSpecEventCount() { specEventCount++; }
00160 inline void incEventCount() { eventCount++; }
00161 inline void decEventCount() { eventCount--; }
00163 inline int done() { return simdone; }
00165 int objRegister(int arrIdx, POSE_TimeType safeTime, int sync, sim *myPtr);
00167 void objRemove(int pvtIdx);
00169 void objUpdate(POSE_TimeType timestamp, int sr);
00171 void objUpdateOVT(int pvtIdx, POSE_TimeType safeTime, POSE_TimeType ovt);
00173 void reportReduce(UpdateMsg *);
00175 void addSR(SRentry **SRs, SRentry *e, POSE_TimeType og, int ne);
00176 inline int getNumObjs() { return objs.getNumObjs(); }
00177
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217 };
00218
00220
00222 class GVT : public Group {
00223 private:
00224 #if !CMK_TRACE_DISABLED
00225 localStat *localStats;
00226 #endif
00228 POSE_TimeType estGVT;
00230 int inactive;
00232 POSE_TimeType inactiveTime;
00234 int nextLBstart;
00236 POSE_TimeType lastEarliest;
00238 int lastSends;
00240 int lastRecvs;
00242 int reportsExpected;
00243
00245 POSE_TimeType optGVT, conGVT;
00246 int done;
00248 SRentry *SRs;
00249 int startOffset;
00250 public:
00252
00253
00254
00255 int gvtIterationCount;
00256
00258 GVT(void);
00260 GVT(CkMigrateMessage *msg) : Group(msg) { };
00262 void pup(PUP::er &p);
00264 inline int getGVTIterationCount() { return gvtIterationCount; }
00265
00266
00268 inline void sumGVTIterationCounts() {
00269 contribute(sizeof(int), &gvtIterationCount, CkReduction::sum_int, CkCallback(POSE_sumGVTIterations, NULL));
00270 }
00272
00274 void runGVT(UpdateMsg *);
00276 void computeGVT(UpdateMsg *);
00278 void addSR(SRentry **SRs, SRentry *e, POSE_TimeType og, int ne);
00279 };
00280
00281 #endif