Bug #1062: Fix linking errors by moving definition of userDrivenMode to machine-commo...
[charm.git] / src / ck-ldb / DistributedLB.h
blob66a02d7e040141a0f6d325cafeb048d24cb5564e
1 /**
2 * Author: gplkrsh2@illinois.edu (Harshitha Menon)
4 * A distributed load balancer which consists of two phases.
5 * 1. Information propagation
6 * 2. Probabilistic transfer of load
8 * Information propagation is done using Gossip protocol where the information
9 * about the underloaded processors in the system is spread to the overloaded
10 * processors.
11 * Once the overloaded processors receive the partial information about the
12 * underloaded processors in the system, it does probabilistic load transfer.
13 * The probability of a PE receiving load is inversely proportional to its
14 * current load.
17 #ifndef _DISTLB_H_
18 #define _DISTLB_H_
20 #include "DistBaseLB.h"
21 #include "DistributedLB.decl.h"
23 #include "ckheap.h"
25 #include <vector>
27 void CreateDistributedLB();
29 class DistributedLB : public CBase_DistributedLB {
30 public:
31 DistributedLB(const CkLBOptions &);
32 DistributedLB(CkMigrateMessage *m);
33 void GossipLoadInfo(int, int, int, int[], double[]);
34 void AvgLoadReduction(double x);
35 void DoneGossip();
36 void InformMigration(int obj_id, int from_pe, double obj_load, bool force);
37 void RecvAck(int obj_id, int assigned_pe, bool can_accept);
38 void SendAfterBarrier(CkReductionMsg *msg);
40 private:
41 CProxy_DistributedLB thisProxy;
43 int underloaded_pe_count;
44 std::vector<int> pe_no;
45 std::vector<double> loads;
46 std::vector<double> distribution;
48 int total_migrates_ack;
49 int total_migrates;
50 std::vector<MigrateInfo*> migrateInfo;
51 LBMigrateMsg* msg;
53 bool kUseAck;
54 double kTransferThreshold;
55 int kPartialInfoCount;
56 int kMaxTrials;
57 int kMaxGossipMsgCount;
59 int gossip_msg_count;
60 bool lb_started;
61 int objs_count;
62 double my_load;
63 double avg_load;
64 double b_load;
65 double b_load_per_obj;
66 double thr_avg;
67 int req_hop;
68 int negack_count;
70 const DistBaseLB::LDStats* my_stats;
72 void InitLB(const CkLBOptions &);
73 void SendLoadInfo();
74 void LoadBalance();
75 void LoadBalance(CkVec<int> &obj_no, CkVec<int> &obj_pe_no);
76 void MapObjsToPe(minHeap &objs, CkVec<int> &obj_no, CkVec<int> &obj_pe_no);
77 int PickRandReceiverPeIdx() const;
78 void CalculateCumulateDistribution();
79 void Strategy(const DistBaseLB::LDStats* const stats);
81 bool QueryBalanceNow(int step) { return true; };
84 #endif /* _DistributedLB_H_ */