00001 00005 00006 #ifndef LBOBJ_H 00007 #define LBOBJ_H 00008 00009 #include "lbdb.h" 00010 00011 class LBDB; 00012 00013 class LBObj 00014 { 00015 friend class LBDB; 00016 00017 public: 00018 LBObj(const LDObjHandle &_h, void *usr_ptr = NULL, bool _migratable=true, bool _asyncArrival = false) { 00019 data.handle = _h; 00020 data.migratable = _migratable; 00021 data.asyncArrival = _asyncArrival; 00022 Clear(); 00023 // data.cpuTime = 0.; 00024 // data.wallTime = 0.; 00025 // data.minWall = 1e6; 00026 // data.maxWall = 0.; 00027 localUserData = usr_ptr; 00028 // migratable = _migratable; 00029 // registered = true; 00030 startWTime = -1.0; 00031 lastWallTime = .0; 00032 #if CMK_LB_CPUTIMER 00033 startCTime = -1.0; 00034 lastCpuTime = .0; 00035 #endif 00036 } 00037 00038 ~LBObj() { }; 00039 00040 void Clear(void); 00041 00042 void IncrementTime(LBRealType walltime, LBRealType cputime); 00043 inline void StartTimer(void) { 00044 startWTime = CkWallTimer(); 00045 #if CMK_LB_CPUTIMER 00046 startCTime = CkCpuTimer(); 00047 #endif 00048 } 00049 inline void StopTimer(LBRealType* walltime, LBRealType* cputime) { 00050 if (startWTime >= 0.0) { // in case startOn in middle of entry 00051 const double endWTime = CkWallTimer(); 00052 *walltime = endWTime - startWTime; 00053 #if CMK_LB_CPUTIMER 00054 const double endCTime = CkCpuTimer(); 00055 *cputime = endCTime - startCTime; 00056 #else 00057 *cputime = *walltime; 00058 #endif 00059 } 00060 else { 00061 *walltime = *cputime = 0.0; 00062 } 00063 } 00064 00065 inline void getTime(LBRealType *w, LBRealType *c) { 00066 *w = data.wallTime; 00067 #if CMK_LB_CPUTIMER 00068 *c = data.cpuTime; 00069 #else 00070 *c = *w; 00071 #endif 00072 } 00073 00074 inline void setTiming(LBRealType cputime) 00075 { 00076 data.wallTime = cputime; 00077 #if CMK_LB_CPUTIMER 00078 data.cpuTime = cputime; 00079 #endif 00080 } 00081 00082 inline LDOMHandle &parentOM() { return data.handle.omhandle; } 00083 inline const LDObjHandle &GetLDObjHandle() const { return data.handle; } 00084 inline void SetMigratable(bool mig) { data.migratable = mig; } 00085 inline void setPupSize(size_t obj_pup_size) { 00086 data.pupSize = pup_encodeSize(obj_pup_size); 00087 } 00088 inline void UseAsyncMigrate(bool async) { data.asyncArrival = async; } 00089 inline LDObjData &ObjData() { return data; }; 00090 inline void lastKnownLoad(LBRealType *w, LBRealType *c) { 00091 *w = lastWallTime; 00092 #if CMK_LB_CPUTIMER 00093 *c = lastCpuTime; 00094 #else 00095 *c = *w; 00096 #endif 00097 } 00098 inline void *getLocalUserData() { return localUserData; } 00099 #if CMK_LB_USER_DATA 00100 inline void *getDBUserData(int idx) { return data.getUserData(idx); } 00101 #endif 00102 private: 00103 00104 void *localUserData; // local user data, not in database 00105 // LDOMHandle parentOM; 00106 // LDObjHandle myhandle; 00107 LDObjData data; 00108 // bool registered; 00109 double startWTime; // needs double precision 00110 LBRealType lastWallTime; 00111 #if CMK_LB_CPUTIMER 00112 double startCTime; 00113 LBRealType lastCpuTime; 00114 #endif 00115 // bool migratable; // temp 00116 }; 00117 00118 #endif 00119