
00001 00005 00006 #ifndef NBORBASELB_H 00007 #define NBORBASELB_H 00008 00009 #include "BaseLB.h" 00010 #include "NborBaseLB.decl.h" 00011 00012 #include "topology.h" 00013 00014 void CreateNborBaseLB(); 00015 00017 typedef LBMigrateMsg NLBMigrateMsg; 00018 00019 class NLBStatsMsg; 00020 00021 class NborBaseLB : public BaseLB 00022 { 00023 private: 00024 CProxy_NborBaseLB thisProxy; 00025 LBTopology *topo; 00026 public: 00027 NborBaseLB(const CkLBOptions &); 00028 NborBaseLB(CkMigrateMessage *m):BaseLB(m) {} 00029 ~NborBaseLB(); 00030 00031 static void staticAtSync(void*); 00032 void AtSync(void); // Everything is at the PE barrier 00033 00034 void ReceiveStats(CkMarshalledNLBStatsMessage &m); // Receive stats on PE 0 00035 void ResumeClients(CkReductionMsg *msg); 00036 void ResumeClients(int balancing); 00037 void ReceiveMigration(LBMigrateMsg *); // Receive migration data 00038 00039 // Migrated-element callback 00040 static void staticMigrated(void* me, LDObjHandle h, int waitBarrier); 00041 void Migrated(LDObjHandle h, int waitBarrier); 00042 00043 void MigrationDone(int balancing); // Call when migration is complete 00044 00045 struct LDStats { // Passed to Strategy 00046 int from_pe; 00047 LBRealType total_walltime; 00048 LBRealType idletime; 00049 LBRealType bg_walltime; 00050 LBRealType obj_walltime; 00051 #if CMK_LB_CPUTIMER 00052 LBRealType total_cputime; 00053 LBRealType bg_cputime; 00054 LBRealType obj_cputime; 00055 #endif 00056 int pe_speed; 00057 CmiBool available; 00058 CmiBool move; 00059 00060 int n_objs; 00061 LDObjData* objData; 00062 int n_comm; 00063 LDCommData* commData; 00064 00065 inline void clearBgLoad() { 00066 bg_walltime = idletime = 0.0; 00067 #if CMK_LB_CPUTIMER 00068 bg_cputime = 0.0; 00069 #endif 00070 } 00071 }; 00072 00073 protected: 00074 virtual CmiBool QueryBalanceNow(int) { return CmiTrue; }; 00075 virtual CmiBool QueryMigrateStep(int) { return CmiTrue; }; 00076 virtual LBMigrateMsg* Strategy(LDStats* stats, int n_nbrs); 00077 00078 int NeighborIndex(int pe); // return the neighbor array index 00079 00080 LDStats myStats; 00081 00082 private: 00083 void FindNeighbors(); 00084 NLBStatsMsg* AssembleStats(); 00085 00086 int stats_msg_count; 00087 NLBStatsMsg** statsMsgsList; 00088 LDStats* statsDataList; 00089 int migrates_completed; 00090 int migrates_expected; 00091 LBMigrateMsg** mig_msgs; 00092 int mig_msgs_received; 00093 int mig_msgs_expected; 00094 int* neighbor_pes; 00095 int receive_stats_ready; 00096 double start_lb_time; 00097 }; 00098 00099 class NLBStatsMsg { 00100 public: 00101 int from_pe; 00102 int serial; 00103 int pe_speed; 00104 double total_walltime; 00105 double idletime; 00106 double bg_walltime; 00107 double obj_walltime; // may not needed 00108 #if CMK_LB_CPUTIMER 00109 double total_cputime; 00110 double bg_cputime; 00111 double obj_cputime; // may not needed 00112 #endif 00113 int n_objs; 00114 LDObjData *objData; 00115 int n_comm; 00116 LDCommData *commData; 00117 public: 00118 NLBStatsMsg(int osz, int csz); 00119 NLBStatsMsg(NLBStatsMsg *s); 00120 NLBStatsMsg() {} 00121 ~NLBStatsMsg(); 00122 void pup(PUP::er &p); 00123 }; 00124 00125 #endif /* NBORBASELB_H */ 00126
1.5.5