00001
00002
00003 #ifndef OPT_H
00004 #define OPT_H
00005
00006 class opt : public strat {
00007 protected:
00009 int idle;
00011 virtual void Rollback();
00013
00020 virtual void RecoverState(Event *recoveryPoint);
00022
00026 virtual void CancelEvents();
00027 virtual void CancelUnexecutedEvents();
00029 virtual void UndoEvent(Event *e);
00030 public:
00032
00033 int cpRate;
00034
00035 unsigned int specEventCount, eventCount, stepCount, avgEventsPerStep;
00036 unsigned int rbCount, jumpCount;
00037 POSE_TimeType avgRBoffset, avgTimeLeash, avgJump;
00038 unsigned short int rbFlag;
00040 opt() : specEventCount(0),
00041 eventCount(0), stepCount(0), avgEventsPerStep(0), rbCount(0), jumpCount(0),
00042 rbFlag(0), idle(0), avgTimeLeash(0), avgJump(0)
00043 {
00044 STRAT_T=OPT_T;
00045 cpRate=pose_config.store_rate;
00046 avgRBoffset = POSE_TimeMax/2;
00047 }
00049 inline void initSync() { parent->sync = OPTIMISTIC; }
00051
00053 virtual void Step();
00055
00058 POSE_TimeType SafeTime() {
00059 POSE_TimeType ovt=userObj->OVT(), theTime=POSE_UnsetTS,
00060 ec=parent->cancels.getEarliest(), gvt=localPVT->getGVT(),
00061 worktime = eq->currentPtr->timestamp;
00062
00063 if ((ec == POSE_UnsetTS) && (worktime == POSE_UnsetTS)) {
00064 return POSE_UnsetTS;
00065 }
00066 if (ec > POSE_UnsetTS) {
00067 theTime = ec;
00068 if ((worktime > POSE_UnsetTS) && (worktime < ec) && (ovt < worktime))
00069 theTime = worktime;
00070 else if ((worktime > POSE_UnsetTS) && (worktime < ec) && (ovt < ec))
00071 theTime = ovt;
00072 else if ((worktime > POSE_UnsetTS) && (worktime < ec))
00073 theTime = ec;
00074 else if ((worktime == POSE_UnsetTS) && (ovt < ec))
00075 theTime = ec;
00076 }
00077 else if (worktime > POSE_UnsetTS) {
00078 theTime = worktime;
00079 if (ovt > worktime)
00080 theTime = ovt;
00081 }
00082
00083
00084
00085 CkAssert((theTime == POSE_UnsetTS) || (theTime >= gvt) ||
00086 (theTime == (gvt-1)));
00087 return theTime;
00088 }
00090 inline void AddSpawnedEvent(int AnObjIdx, eventID evID, POSE_TimeType ts) {
00091 eq->AddSpawnToCurrent(AnObjIdx, evID, ts);
00092 }
00094 void CancelSpawn(Event *e) {
00095 #if !CMK_TRACE_DISABLED
00096 double critStart;
00097 if(pose_config.trace)
00098 critStart= CmiWallTimer();
00099 #endif
00100 cancelMsg *m;
00101 SpawnedEvent *ev = e->spawnedList;
00102 while (ev) {
00103 e->spawnedList = ev->next;
00104 ev->next = NULL;
00105 m = new cancelMsg();
00106 m->evID = ev->evID;
00107 m->timestamp = ev->timestamp;
00108 m->setPriority((m->timestamp-1) - POSE_TimeMax);
00109 localPVT->objUpdate(ev->timestamp, SEND);
00110
00111
00112 POSE_Objects[ev->objIdx].Cancel(m);
00113 delete ev;
00114 ev = e->spawnedList;
00115 }
00116 #if !CMK_TRACE_DISABLED
00117 if(pose_config.trace)
00118 traceUserBracketEvent(30, critStart, CmiWallTimer());
00119 #endif
00120 }
00121 };
00122
00123 #endif