00001 00002 #ifndef EVQ_H 00003 #define EVQ_H 00004 00005 //#define EQ_SANITIZE 1 00006 00008 00010 class eventQueue { 00012 void CommitStatsHelper(sim *obj, Event *commitPtr); 00013 public: 00015 Event *frontPtr, *backPtr; 00017 Event *currentPtr; 00019 Event *RBevent; 00021 EqHeap *eqh; 00023 POSE_TimeType largest; 00025 unsigned int eventCount; 00027 POSE_TimeType tsOfLastInserted; 00029 unsigned int mem_usage; 00031 POSE_TimeType lastLoggedVT; 00033 int recentAvgEventSparsity; 00035 POSE_TimeType sparsityStartTime; 00037 int sparsityCalcCount; 00039 int tsDiffCount; 00041 POSE_TimeType lastCommittedTS; 00043 POSE_TimeType tsCommitDiffs[DIFFS_TO_STORE]; 00044 #ifdef MEM_TEMPORAL 00045 TimePool *localTimePool; 00046 #endif 00048 00050 eventQueue(); 00052 ~eventQueue(); 00054 00056 void InsertEvent(Event *e); 00058 00060 void InsertEventDeterministic(Event *e); 00062 inline Event *front() { return frontPtr; } 00064 inline Event *back() { return backPtr; } 00066 00067 void ShiftEvent() { 00068 Event *e; 00069 #ifdef EQ_SANITIZE 00070 sanitize(); 00071 #endif 00072 CmiAssert(currentPtr->next != NULL); 00073 currentPtr = currentPtr->next; // set currentPtr to next event 00074 if ((currentPtr == backPtr) && (eqh->top)) { // currentPtr on back sentinel 00075 e = eqh->GetAndRemoveTopEvent(); // get next event from heap 00076 // insert event in list 00077 e->prev = currentPtr->prev; 00078 e->next = currentPtr; 00079 currentPtr->prev = e; 00080 e->prev->next = e; 00081 currentPtr = e; 00082 } 00083 if (currentPtr == backPtr) largest = POSE_UnsetTS; 00084 else FindLargest(); 00085 eventCount--; 00086 #ifdef EQ_SANITIZE 00087 sanitize(); 00088 #endif 00089 } 00091 void CommitEvents(sim *obj, POSE_TimeType ts); 00093 void CommitAll(sim *obj); 00095 void CommitDoneEvents(sim *obj); 00097 00098 void SetCurrentPtr(Event *e); 00100 void DeleteEvent(Event *ev); 00102 inline const eventID& CurrentEventID() { return currentPtr->evID; } 00104 00105 inline void AddSpawnToCurrent(int id, eventID e, POSE_TimeType ts) { 00106 SpawnedEvent *newnode = 00107 new SpawnedEvent(id, e, ts, currentPtr->spawnedList); 00108 CmiAssert(currentPtr->done == 2); 00109 currentPtr->spawnedList = newnode; 00110 } 00112 inline SpawnedEvent *GetNextCurrentSpawn() { 00113 SpawnedEvent *tmp = currentPtr->spawnedList; 00114 if (tmp) currentPtr->spawnedList = tmp->next; 00115 return tmp; 00116 } 00118 inline void FindLargest() { 00119 POSE_TimeType hs = eqh->FindMax(); 00120 if (backPtr->prev->done == 0) largest = backPtr->prev->timestamp; 00121 else largest = POSE_UnsetTS; 00122 if (largest < hs) largest = hs; 00123 } 00125 void SetRBevent(Event *e) { 00126 if (!RBevent) RBevent = e; 00127 else if ((pose_config.deterministic && RBevent->timestamp > e->timestamp) || 00128 (RBevent->timestamp == e->timestamp && e->evID < RBevent->evID)) { 00129 CmiAssert(RBevent->prev->next == RBevent); 00130 CmiAssert(RBevent->next->prev == RBevent); 00131 RBevent = e; 00132 } 00133 else if ((RBevent->timestamp > e->timestamp) || 00134 (RBevent->timestamp == e->timestamp && RBevent->evID > e->evID) 00135 ) { 00136 CmiAssert(RBevent->prev->next == RBevent); 00137 CmiAssert(RBevent->next->prev == RBevent); 00138 RBevent = e; 00139 } 00140 } 00142 void dump(); 00144 char *dumpString(); 00146 void pup(PUP::er &p); 00148 void sanitize(); 00149 }; 00150 00151 #endif