00001
00017 #ifndef _DISTLB_H_
00018 #define _DISTLB_H_
00019
00020 #include "DistBaseLB.h"
00021 #include "DistributedLB.decl.h"
00022
00023 #include "ckheap.h"
00024
00025 #include <vector>
00026
00027 void CreateDistributedLB();
00028
00029 class DistributedLB : public CBase_DistributedLB {
00030 public:
00031 DistributedLB(const CkLBOptions &);
00032 DistributedLB(CkMigrateMessage *m);
00033 static void initnodeFn(void);
00034
00035 void GossipLoadInfo(int, int, int[], double[]);
00036 void LoadReduction(CkReductionMsg* msg);
00037 void AfterLBReduction(CkReductionMsg* msg);
00038 void DoneGossip();
00039 void InformMigration(int obj_id, int from_pe, double obj_load, bool force);
00040 void RecvAck(int obj_id, int assigned_pe, bool can_accept);
00041 void turnOn();
00042 void turnOff();
00043
00044 private:
00045
00046 int underloaded_pe_count;
00047 std::vector<int> pe_no;
00048 std::vector<double> loads;
00049 std::vector<double> distribution;
00050
00051 minHeap* objs;
00052
00053 int total_migrates_ack;
00054 int total_migrates;
00055 std::vector<MigrateInfo*> migrateInfo;
00056
00057
00058 bool kUseAck;
00059 int kPartialInfoCount;
00060 int kMaxTrials;
00061 int kMaxGossipMsgCount;
00062 int kMaxObjPickTrials;
00063 int kMaxPhases;
00064 double kTargetRatio;
00065
00066
00067 double avg_load;
00068 double max_load;
00069 double load_ratio;
00070
00071
00072 double my_load;
00073 double init_load;
00074 double b_load;
00075 double b_load_per_obj;
00076
00077
00078 bool lb_started;
00079 int phase_number;
00080 int gossip_msg_count;
00081 int objs_count;
00082 int negack_count;
00083 double transfer_threshold;
00084
00085 double start_time;
00086
00087 const DistBaseLB::LDStats* my_stats;
00088
00089 void InitLB(const CkLBOptions &);
00090 void SendLoadInfo();
00091 void LoadBalance();
00092 void LoadBalance(CkVec<int> &obj_no, CkVec<int> &obj_pe_no);
00093 void MapObjsToPe(minHeap *objs, CkVec<int> &obj_no, CkVec<int> &obj_pe_no);
00094 int PickRandReceiverPeIdx() const;
00095 void CalculateCumulateDistribution();
00096 void Strategy(const DistBaseLB::LDStats* const stats);
00097 void Setup();
00098 void Cleanup();
00099 void PackAndSendMigrateMsgs();
00100 void StartNextLBPhase();
00101 void DoneWithLBPhase();
00102
00103
00104 bool QueryBalanceNow(int step) { return true; };
00105 };
00106
00107 #endif