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