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