00001 00005 00023 #ifndef _GREEDY_REFINE_LB_H_ 00024 #define _GREEDY_REFINE_LB_H_ 00025 00026 #include "CentralLB.h" 00027 #include "GreedyRefineLB.decl.h" 00028 00029 void CreateGreedyRefineLB(); 00030 BaseLB *AllocateGreedyRefineLB(); 00031 00032 #define __DEBUG_GREEDY_REFINE_ 0 00033 00034 class GreedyRefineLB : public CBase_GreedyRefineLB { 00035 public: 00036 GreedyRefineLB(const CkLBOptions &); 00037 GreedyRefineLB(CkMigrateMessage *m); 00038 void work(LDStats* stats); 00039 void receiveSolutions(CkReductionMsg *msg); 00040 void receiveTotalTime(double time); 00041 void setMigrationTolerance(float tol) { migrationTolerance = tol; } 00042 00043 private: 00044 bool QueryBalanceNow(int step) { return true; } 00045 00046 class GProc { 00047 public: 00048 GProc() : available(true), load(0) {} 00049 int id; 00050 bool available; 00051 int pos; // position in min heap 00052 double load; 00053 double bgload; // background load 00054 float speed; 00055 }; 00056 00057 class GObj { 00058 public: 00059 int id; 00060 double load; 00061 int oldPE; 00062 }; 00063 00064 class ObjLoadGreater { 00065 public: 00066 inline bool operator() (const GObj *o1, const GObj *o2) const { 00067 return (o1->load > o2->load); 00068 } 00069 }; 00070 00071 class PHeap; 00072 class Solution; 00073 00074 double fillData(LDStats *stats, 00075 std::vector<GObj> &objs, 00076 std::vector<GObj*> &pobjs, 00077 std::vector<GProc> &procs, 00078 PHeap &procHeap); 00079 00080 double greedyLB(const std::vector<GObj*> &pobjs, PHeap &procHeap, const BaseLB::LDStats *stats) const; 00081 void sendSolution(double maxLoad, int migrations); 00082 00083 double strategyStartTime; 00084 double totalObjLoad; 00085 int availablePes; 00086 float migrationTolerance; 00087 int totalObjs; 00088 00089 #if __DEBUG_GREEDY_REFINE_ 00090 void dumpObjLoads(std::vector<GObj> &objs); 00091 void dumpProcLoads(std::vector<GProc> &procs); 00092 #endif 00093 }; 00094 00095 #endif 00096