00001
00005
00006 #ifndef _GREEDYLB_H_
00007 #define _GREEDYLB_H_
00008
00009 #include "CentralLB.h"
00010 #include "TempAwareGreedyLB.decl.h"
00011
00012 void CreateTempAwareGreedyLB();
00013 BaseLB * AllocateTempAwareGreedyLB();
00014
00015 class TempAwareGreedyLB : public CBase_TempAwareGreedyLB {
00016
00017 public:
00018 struct HeapData {
00019 double load;
00020 int pe;
00021 int id;
00022 };
00023
00024 TempAwareGreedyLB(const CkLBOptions &);
00025 TempAwareGreedyLB(CkMigrateMessage *m) : CBase_TempAwareGreedyLB(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