AMPI: drop comm argument from AMPI_Comm_set_migratable and rename to AMPI_Set_migratable
[charm.git] / src / ck-ldb / LBObj.h
blob7a0a6a4dbe1e262440307cb38c6b1cf15f28c720
1 /**
2 * \addtogroup CkLdb
3 */
4 /*@{*/
6 #ifndef LBOBJ_H
7 #define LBOBJ_H
9 #include "lbdb.h"
11 class LBDB;
13 class LBObj
15 friend class LBDB;
17 public:
18 LBObj(const LDObjHandle &_h, void *usr_ptr = NULL, bool _migratable=true, bool _asyncArrival = false) {
19 data.handle = _h;
20 data.migratable = _migratable;
21 data.asyncArrival = _asyncArrival;
22 Clear();
23 // data.cpuTime = 0.;
24 // data.wallTime = 0.;
25 // data.minWall = 1e6;
26 // data.maxWall = 0.;
27 localUserData = usr_ptr;
28 // migratable = _migratable;
29 // registered = true;
30 startWTime = -1.0;
31 lastWallTime = .0;
32 #if CMK_LB_CPUTIMER
33 startCTime = -1.0;
34 lastCpuTime = .0;
35 #endif
38 ~LBObj() { };
40 void Clear(void);
42 void IncrementTime(LBRealType walltime, LBRealType cputime);
43 inline void StartTimer(void) {
44 startWTime = CkWallTimer();
45 #if CMK_LB_CPUTIMER
46 startCTime = CkCpuTimer();
47 #endif
49 inline void StopTimer(LBRealType* walltime, LBRealType* cputime) {
50 if (startWTime >= 0.0) { // in case startOn in middle of entry
51 const double endWTime = CkWallTimer();
52 *walltime = endWTime - startWTime;
53 #if CMK_LB_CPUTIMER
54 const double endCTime = CkCpuTimer();
55 *cputime = endCTime - startCTime;
56 #else
57 *cputime = *walltime;
58 #endif
60 else {
61 *walltime = *cputime = 0.0;
65 inline void getTime(LBRealType *w, LBRealType *c) {
66 *w = data.wallTime;
67 #if CMK_LB_CPUTIMER
68 *c = data.cpuTime;
69 #else
70 *c = *w;
71 #endif
74 inline void setTiming(LBRealType cputime)
76 data.wallTime = cputime;
77 #if CMK_LB_CPUTIMER
78 data.cpuTime = cputime;
79 #endif
82 inline LDOMHandle &parentOM() { return data.handle.omhandle; }
83 inline const LDObjHandle &GetLDObjHandle() const { return data.handle; }
84 inline void SetMigratable(bool mig) { data.migratable = mig; }
85 inline void setPupSize(size_t obj_pup_size) {
86 data.pupSize = pup_encodeSize(obj_pup_size);
88 inline void UseAsyncMigrate(bool async) { data.asyncArrival = async; }
89 inline LDObjData &ObjData() { return data; };
90 inline void lastKnownLoad(LBRealType *w, LBRealType *c) {
91 *w = lastWallTime;
92 #if CMK_LB_CPUTIMER
93 *c = lastCpuTime;
94 #else
95 *c = *w;
96 #endif
98 inline void *getLocalUserData() { return localUserData; }
99 #if CMK_LB_USER_DATA
100 inline void *getDBUserData(int idx) { return data.getUserData(idx); }
101 #endif
102 private:
104 void *localUserData; // local user data, not in database
105 // LDOMHandle parentOM;
106 // LDObjHandle myhandle;
107 LDObjData data;
108 // bool registered;
109 double startWTime; // needs double precision
110 LBRealType lastWallTime;
111 #if CMK_LB_CPUTIMER
112 double startCTime;
113 LBRealType lastCpuTime;
114 #endif
115 // bool migratable; // temp
118 #endif
120 /*@}*/