00001 00002 #include "pose.h" 00003 00005 void adapt3::Step() 00006 { 00007 Event *ev; 00008 POSE_TimeType lastGVT = localPVT->getGVT(), offset; 00009 int iter=0; 00010 double critStart; 00011 00012 rbFlag = 0; 00013 if (!parent->cancels.IsEmpty()) CancelUnexecutedEvents(); 00014 if (eq->RBevent) Rollback(); 00015 if (!parent->cancels.IsEmpty()) CancelEvents(); 00016 parent->Status(); 00017 00018 if (rbFlag) { 00019 if (timeLeash > avgRBoffset) 00020 timeLeash = avgRBoffset; 00021 else timeLeash = avgRBoffset/2; 00022 } 00023 if (specEventCount > (specTol*eventCount + eventCount)) { 00024 timeLeash = avgRBoffset; 00025 } 00026 else if ((specEventCount <= (specTol*eventCount + eventCount)) && 00027 (timeLeash < (POSE_TimeMax/2 -10))) { 00028 timeLeash += avgRBoffset; 00029 } 00030 /* 00031 if (rbFlag) timeLeash = 1; 00032 else if (eq->currentPtr->timestamp > POSE_UnsetTS) 00033 timeLeash = (timeLeash + (eq->largest - lastGVT))/2; 00034 else timeLeash = avgRBoffset; 00035 else if (specEventCount > (specTol*eventCount)) 00036 timeLeash = 1; 00037 else if (specEventCount > (specTol*eventCount)-0.1) 00038 timeLeash = (timeLeash + avgRBoffset)/2; 00039 */ 00040 00041 // Prepare to execute an event 00042 offset = lastGVT + timeLeash; 00043 if (offset < 0) offset = POSE_TimeMax; 00044 // Shorten the leash as we near POSE_endtime 00045 if ((POSE_endtime > POSE_UnsetTS) && ((lastGVT+offset > POSE_endtime) || 00046 (lastGVT+offset <= POSE_UnsetTS))) 00047 offset = POSE_endtime; 00048 00049 ev = eq->currentPtr; 00050 // CkPrintf("offset=%d timeLeash=%d avgRBoffset=%d specEventCount=%d eventCount=%d\n", offset, timeLeash, avgRBoffset, specEventCount, eventCount); 00051 while ((ev->timestamp > POSE_UnsetTS) && (ev->timestamp <= offset)) { 00052 #ifdef MEM_COARSE 00053 // Check to see if we should hold off on forward execution to save on 00054 // memory. 00055 // NOTE: to avoid deadlock, make sure we have executed something 00056 // beyond current GVT before worrying about memory usage 00057 if ((lastGVT < ev->prev->timestamp) && 00058 (eq->mem_usage > pose_config.max_usage)) break; 00059 #endif 00060 iter++; 00061 currentEvent = ev; 00062 ev->done = 2; 00063 specEventCount++; 00064 eventCount++; 00065 #if !CMK_TRACE_DISABLED 00066 if(pose_config.trace) 00067 critStart = CmiWallTimer(); // trace timing 00068 #endif 00069 parent->ResolveFn(ev->fnIdx, ev->msg); // execute it 00070 #if !CMK_TRACE_DISABLED 00071 if(pose_config.trace) 00072 traceUserBracketEvent(10, critStart, CmiWallTimer()); 00073 #endif 00074 ev->done = 1; // flag the event as executed 00075 eq->mem_usage++; 00076 eq->ShiftEvent(); // shift to next event 00077 ev = eq->currentPtr; 00078 } 00079 #if !CMK_TRACE_DISABLED 00080 if(pose_config.stats) 00081 if (iter > 0) localStats->Loop(); 00082 //if (iter > 5) CkPrintf("Executed %d events on this iteration; SE=%d E=%d\n", iter, specEventCount, eventCount); 00083 #endif 00084 } 00085