00001 00006 #ifndef _DISTBASELB_H 00007 #define _DISTBASELB_H 00008 00009 #include "BaseLB.h" 00010 #include "DistBaseLB.decl.h" 00011 00012 00013 void CreateDistBaseLB(); 00014 00016 typedef LBMigrateMsg NLBMigrateMsg; 00017 00018 00019 class DistBaseLB : public CBase_DistBaseLB { 00020 public: 00021 DistBaseLB(const CkLBOptions &); 00022 DistBaseLB(CkMigrateMessage *m) : CBase_DistBaseLB(m) {} 00023 ~DistBaseLB(); 00024 00025 static void staticAtSync(void*); 00026 void AtSync(void); // Everything is at the PE barrier 00027 00028 void barrierDone(); 00029 static void staticStartLB(void*); 00030 void ProcessAtSync(); 00031 void LoadBalance(); 00032 void ResumeClients(); 00033 void ResumeClients(int balancing); 00034 // Migrated-element callback 00035 static void staticMigrated(void* me, LDObjHandle h, int waitBarrier); 00036 void Migrated(LDObjHandle h, int waitBarrier); 00037 00038 struct LDStats { // Passed to Strategy 00039 int from_pe; 00040 LBRealType total_walltime; 00041 LBRealType idletime; 00042 LBRealType bg_walltime; 00043 LBRealType obj_walltime; 00044 #if CMK_LB_CPUTIMER 00045 LBRealType total_cputime; 00046 LBRealType bg_cputime; 00047 LBRealType obj_cputime; 00048 #endif 00049 int pe_speed; 00050 bool available; 00051 bool move; 00052 00053 int n_objs; 00054 LDObjData* objData; 00055 int n_comm; 00056 LDCommData* commData; 00057 00058 inline void clearBgLoad() { 00059 bg_walltime = idletime = 0.0; 00060 #if CMK_LB_CPUTIMER 00061 bg_cputime = 0.0; 00062 #endif 00063 } 00064 }; 00065 00066 protected: 00067 virtual void Strategy(const LDStats* const myStats); 00068 void ProcessMigrationDecision(LBMigrateMsg* migrateMsg); 00069 00070 LDStats myStats; 00071 int migrates_expected; 00072 00073 private: 00074 bool lb_started; 00075 double start_lb_time; 00076 double strat_start_time; 00077 double strat_end_time; 00078 00079 int migrates_completed; 00080 LBMigrateMsg** mig_msgs; 00081 00082 void AssembleStats(); 00083 void MigrationDone(int balancing); // Call when migration is complete 00084 }; 00085 00086 #endif /* _DISTBASELB_H */