00001 00002 00005 #ifndef REP_H 00006 #define REP_H 00007 #include "sim.decl.h" 00008 00009 extern CProxy_sim POSE_Objects_RO; 00010 00011 // our configuration bundle 00012 extern POSE_Config pose_config; 00013 00015 class rep 00016 { 00017 public: 00019 strat *myStrat; 00021 sim *parent; 00023 00024 int myHandle; 00026 POSE_TimeType ovt; 00028 double ort; 00030 unsigned int prand_seed; 00032 unsigned short int prand48_seed[3]; 00034 int anti_methods; 00036 00037 POSE_TimeType simulationStartGVT; 00038 #ifdef MEM_TEMPORAL 00039 TimePool *localTimePool; 00040 #endif 00042 rep() { 00043 ovt = 0; ort = 0.0; parent = NULL; myStrat = NULL; 00044 anti_methods = 0; 00045 simulationStartGVT = (POSE_TimeType)-1; 00046 #ifdef MEM_TEMPORAL 00047 localTimePool = (TimePool *)CkLocalBranch(TempMemID); 00048 #endif 00049 } 00051 rep(POSE_TimeType init_ovt) { 00052 ovt = init_ovt; ort = 0.0; anti_methods = 0; 00053 simulationStartGVT = (POSE_TimeType)-1; 00054 } 00056 virtual ~rep() { 00057 } 00059 void init(eventMsg *m); 00061 inline POSE_TimeType OVT() { return ovt; } 00063 inline void SetOVT(POSE_TimeType t) { ovt = t; } 00065 inline void useAntimethods() { anti_methods = 1; } 00067 inline void turnOffAntimethods() { anti_methods = 0; } 00069 inline int usesAntimethods() { return anti_methods; } 00071 inline void elapse(POSE_TimeType dt) { ovt += dt; } 00073 00075 void update(POSE_TimeType t, double rt); 00077 virtual void terminus() { 00078 //CkPrintf("Object %d terminus at time %d\n", myHandle, ovt); 00079 } 00081 virtual void registerTimestamp(int idx, eventMsg *m, POSE_TimeType offset); 00083 void setSimulationStartGVT(POSE_TimeType startGVT) { 00084 CkAssert(startGVT >= 0); 00085 simulationStartGVT = startGVT; 00086 } 00088 00089 inline virtual rep& operator=(const rep& obj) { 00090 ovt = obj.ovt; 00091 ort = obj.ort; 00092 myHandle = obj.myHandle; 00093 anti_methods = obj.anti_methods; 00094 prand_seed = obj.prand_seed; 00095 prand48_seed[0]=obj.prand48_seed[0]; 00096 prand48_seed[1]=obj.prand48_seed[1]; 00097 prand48_seed[2]=obj.prand48_seed[2]; 00098 simulationStartGVT = obj.simulationStartGVT; 00099 return *this; 00100 } 00102 #if USE_LONG_TIMESTAMPS 00103 virtual void dump() { CkPrintf("[REP: ovt=%lld]\n", ovt); } 00104 #else 00105 virtual void dump() { CkPrintf("[REP: ovt=%d]\n", ovt); } 00106 #endif 00108 00109 virtual void pup(PUP::er &p) { 00110 p(ovt); p(ort); p(myHandle); p(anti_methods); p(prand_seed); p(prand48_seed,3); p(simulationStartGVT); 00111 } 00112 #ifdef SEQUENTIAL_POSE 00113 inline void checkpoint(rep *) { } 00114 inline void restore(rep *) { } 00115 #endif 00116 inline void POSE_srand(unsigned int pseed) { prand_seed = pseed; } 00117 inline int POSE_rand() { 00118 int rnum; 00119 srand(prand_seed); 00120 rnum = rand(); 00121 prand_seed = rnum+INT_MAX; 00122 return rnum; 00123 } 00124 inline unsigned int POSE_urand() { 00125 int rnum; 00126 srand(prand_seed); 00127 rnum = rand(); 00128 prand_seed = rnum+INT_MAX; 00129 return prand_seed; 00130 } 00131 #if !defined(_WIN32) 00132 inline long int POSE_Linear_rand() { return nrand48(prand48_seed); } 00133 inline double POSE_Uniform_rand() { return erand48(prand48_seed); } 00134 #else 00135 inline long int POSE_Linear_rand() { return CrnRand(); } 00136 inline double POSE_Uniform_rand() { return 1.0*CrnRand()/MAXINT; } 00137 #endif 00138 00139 }; 00140 00141 #endif