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