00001 
00002 
00005 #ifndef POSE_H
00006 #define POSE_H
00007 
00008 
00009 #include "pose.decl.h"
00010 #include "pose_config.h"
00011 
00012 #include <stdio.h>
00013 #include <string.h>
00014 #include <stdlib.h>
00015 #include <limits.h>
00016 #include "charm++.h"
00017 #include "eventID.h"
00018 #include "mempool.h"
00019 #include "memory_temporal.h"
00020 #include "srtable.h"
00021 #include "stats.h"
00022 #include "cancel.h"
00023 
00024 class eventMsg; 
00025 class rep; 
00026 #include "event.h"
00027 #include "eqheap.h"
00028 
00029 class sim; 
00030 #include "pvtobj.h"
00031 #include "lbObject.h"
00032 #include "ldbal.h"
00033 #include "gvt.h"
00034 #include "evq.h"
00035 
00036 class strat; 
00037 #include "rep.h"
00038 #include "strat.h"
00039 #include "sim.h"
00040 #include "sim.decl.h"
00041 #include "opt.h"
00042 #include "opt2.h"
00043 #include "opt3.h"
00044 #include "spec.h"
00045 #include "adapt.h"
00046 #include "adapt2.h"
00047 #include "adapt3.h"
00048 #include "adapt4.h"
00049 #include "adapt5.h"
00050 #include "cons.h"
00051 #include "seq.h"
00052 #include "chpt.h"
00053 
00055 void POSE_init(); 
00056 void POSE_init(int ET); 
00057 void POSE_init(int IDflag, int ET); 
00059 void POSE_startTimer(); 
00061 void POSE_useID();
00062 
00064 
00065 void POSE_useET(POSE_TimeType et); 
00067 void POSE_registerCallBack(CkCallback cb);
00069 
00071 void POSE_stop();
00072 
00073 void POSE_prepExit(void *param, void *msg);
00075 void POSE_exit();
00077 void setPoseIndexOfStopEvent(int index);
00078 
00080 extern int _POSE_SEQUENTIAL;
00081 
00083 #define _POSE_external_invoke(_POSE_proxy, _POSE_handle, _POSE_objectType, _POSE_atTime, _POSE_method, _POSE_msg) \
00084    { \
00085        CkAssert(_POSE_atTime >= 0); \
00086        _POSE_msg->Timestamp(_POSE_atTime); \
00087        if (! _POSE_SEQUENTIAL) { \
00088          PVT *pvt = (PVT *)CkLocalBranch(ThePVT); \
00089          pvt->objUpdate(_POSE_atTime, SEND); \
00090        } \
00091        (*(CProxy_ ## _POSE_objectType*)&_POSE_proxy)[_POSE_handle]._POSE_method(_POSE_msg); \
00092    }
00093 
00095 extern int totalNumPosers;
00096 
00098 #define POSE_insert_poser(_POSE_poser_type, _POSE_array_index, _POSE_message, _POSE_physical_pe) { \
00099   (*(CProxy_ ## _POSE_poser_type*)&POSE_Objects)[_POSE_array_index].insert(_POSE_message, _POSE_physical_pe); \
00100   totalNumPosers++; \
00101 }
00102 
00104 extern double busyWait;
00105 
00107 extern double sim_timer;
00108 
00110 extern POSE_TimeType POSE_endtime;
00111 
00113 extern int POSE_inactDetect;
00114 
00116 extern POSE_TimeType POSE_GlobalClock;
00117 extern POSE_TimeType POSE_GlobalTS;
00118 
00120 class Skipped_Event {
00121  public:
00122   int simIndex;
00123   POSE_TimeType timestamp;
00124 
00125   Skipped_Event() {}
00126   Skipped_Event(int sIndex, POSE_TimeType ts) : simIndex(sIndex), timestamp(ts) {}
00127   inline void pup(PUP::er &p) {
00128     p|simIndex; p|timestamp;
00129   }
00130   inline Skipped_Event& operator=(const Skipped_Event &obj) {
00131     simIndex = obj.simIndex;
00132     timestamp = obj.timestamp;
00133     return *this;
00134   }
00135 };
00136 
00138 extern int seqCheckpointInProgress;
00139 extern POSE_TimeType seqLastCheckpointGVT;
00140 extern double seqLastCheckpointTime;
00141 extern double seqStartTime;
00142 
00143 
00144 
00145 extern CkQ<Skipped_Event> POSE_Skipped_Events;
00146 
00148 
00149 
00150 
00151 
00152 
00153 
00154 
00155 
00156 extern int poseIndexOfStopEvent;
00157 
00158 extern POSE_Config pose_config;
00159 
00161 void POSE_set_busy_wait(double n);
00163 void POSE_busy_wait();
00165 void POSE_busy_wait(double n);
00166 
00168 
00169 CpvExtern(int, stateRecovery);
00170 
00172 class callBack : public CMessage_callBack
00173 {
00174  public:
00175   CkCallback callback;
00176 };
00177 
00179 class pose : public Chare {
00180  private:
00182 
00184   CkCallback cb;
00186   int callBackSet;
00187  public:
00189   pose(void) : callBackSet(0) { 
00190 #ifdef VERBOSE_DEBUG
00191   CkPrintf("[%d] constructing pose\n",CkMyPe());
00192 #endif
00193 
00194  }
00196   pose(CkMigrateMessage *) { }
00198   void pup(PUP::er &p) {
00199     p|cb;
00200     p|callBackSet;
00201   }
00203   void registerCallBack(callBack *);
00205 
00206   void stop();
00208 
00210 
00211   void prepExit();
00212 
00213   void exit();
00214 };
00215 
00216 #endif