00001
00005
00006 #ifndef _GREEDYLB_H_
00007 #define _GREEDYLB_H_
00008
00009 #include "CentralLB.h"
00010 #include "GreedyLB.decl.h"
00011
00012 void CreateGreedyLB();
00013 BaseLB * AllocateGreedyLB();
00014
00015 class GreedyLB : public CBase_GreedyLB {
00016
00017 public:
00018 struct HeapData {
00019 double load;
00020 int pe;
00021 int id;
00022 };
00023
00024 GreedyLB(const CkLBOptions &);
00025 GreedyLB(CkMigrateMessage *m):CBase_GreedyLB(m) { lbname = "GreedyLB"; }
00026 void work(LDStats* stats);
00027 private:
00028 class ProcLoadGreater;
00029 class ObjLoadGreater;
00030
00031 enum HeapCmp {GT = '>', LT = '<'};
00032 void Heapify(HeapData*, int, int, HeapCmp);
00033 void HeapSort(HeapData*, int, HeapCmp);
00034 void BuildHeap(HeapData*, int, HeapCmp);
00035 bool Compare(double, double, HeapCmp);
00036 HeapData* BuildCpuArray(BaseLB::LDStats*, int, int *);
00037 HeapData* BuildObjectArray(BaseLB::LDStats*, int, int *);
00038 bool QueryBalanceNow(int step);
00039 };
00040
00041 #endif
00042