00001
00002
00005 #ifndef PVTOBJ_H
00006 #define PVTOBJ_H
00007
00009
00011 class pvtObjectNode {
00013 POSE_TimeType ovt, ovt2;
00015 int index;
00017
00019 bool present;
00021 short int sync;
00023 double qdo;
00024 public:
00026 sim *localObjPtr;
00028 pvtObjectNode() : ovt(POSE_UnsetTS), ovt2(POSE_UnsetTS), index(-1), present(false), sync(0), qdo(0.0) { }
00030 inline void set(POSE_TimeType ts, int idx, bool on, short int s, sim *p) {
00031 ovt = ts; index = idx; present = on; sync = s; localObjPtr = p; qdo = 0.0;
00032 ovt2 = POSE_UnsetTS;
00033 }
00035 inline void setIdle() { ovt = ovt2 = POSE_UnsetTS; }
00037 inline bool isPresent() { return present; }
00039 inline int isOptimistic() { return (sync == OPTIMISTIC); }
00041 inline int isConservative() { return (sync == CONSERVATIVE); }
00043 inline POSE_TimeType getOVT() { return ovt; }
00045 inline POSE_TimeType getOVT2() { return ovt2; }
00047 inline void setOVT(POSE_TimeType st) { ovt = st; }
00049 inline void setOVT2(POSE_TimeType st) { ovt2 = st; }
00051 inline void addQdoTime(double t) { qdo += t; }
00053 inline double getQdo() { return qdo; }
00055 inline void resetQdo() { qdo = 0.0; }
00057 void dump() {
00058 if (localObjPtr == NULL)
00059 CkPrintf("ovt=%d index=%d present=%s sync=%s ptr=NULL",
00060 ovt, index, present?"true":"false", (sync==0)?"OPT":"CON");
00061 else
00062 CkPrintf("ovt=%d index=%d present=%s sync=%s ptr!=NULL",
00063 ovt, index, present?"true":"false", (sync==0)?"OPT":"CON");
00064 }
00066 void sanitize();
00067 };
00068
00070 class pvtObjects {
00072 int numObjs;
00074 int numSpaces;
00076 int size;
00078 int firstEmpty;
00080 int stratIterCount;
00081 public:
00083 pvtObjectNode *objs;
00085 pvtObjects();
00087 inline int getNumObjs() { return numObjs; }
00089 inline int getNumSpaces() { return numSpaces; }
00091 inline void SetIdle() {
00092 int i;
00093 for (i=0; i<numSpaces; i++) objs[i].setIdle();
00094 }
00096 void Wake();
00097 void callAtSync();
00099 void Commit();
00101 void CheckpointCommit();
00103 void StratCalcs();
00105
00107 int Insert(int index, POSE_TimeType ovt, int sync, sim *myPtr);
00109 inline void Delete(int idx) {
00110 objs[idx].set(POSE_UnsetTS, POSE_UnsetTS, false, 0, NULL);
00111 numObjs--;
00112 if (idx < firstEmpty) firstEmpty = idx;
00113 }
00115 void dump();
00117 void sanitize();
00118 };
00119
00120 #endif