00001
00005
00006 #ifndef _TEMPAWAREFINELB_H_
00007 #define _TEMPAWAREFINELB_H_
00008
00009 #include "CentralLB.h"
00010 #include "RefinerTemp.h"
00011 #include "TempAwareRefineLB.decl.h"
00012
00013 void CreateTempAwareRefineLB();
00014 BaseLB * AllocateTempAwareRefineLB();
00015
00016 class TempAwareRefineLB : public CBase_TempAwareRefineLB {
00017 friend void printCurrentTemperature(void *LB, double curWallTime);
00018 public:
00019 struct HeapData {
00020 double load;
00021 int pe;
00022 int id;
00023 };
00024 void populateEffectiveFreq(int numProcs);
00025 int procsPerNode,*freqsEffect,*procFreq,*procFreqEffect,*procFreqNewEffect,*procFreqNew,numProcs,coresPerChip,*freqs,numAvailFreqs;
00026 int numChips,*procFreqPtr;
00027 float *procTemp,*avgChipTemp;
00028 void changeFreq(int);
00029 TempAwareRefineLB(const CkLBOptions &);
00030 TempAwareRefineLB(CkMigrateMessage *m):CBase_TempAwareRefineLB(m) { lbname = "TempAwareRefineLB"; }
00031 void work(LDStats* stats);
00032 float getTemp(int);
00033 private:
00034 enum HeapCmp {GT = '>', LT = '<'};
00035 void Heapify(HeapData*, int, int, HeapCmp);
00036 void HeapSort(HeapData*, int, HeapCmp);
00037 void BuildHeap(HeapData*, int, HeapCmp);
00038 bool Compare(double, double, HeapCmp);
00039 HeapData* BuildCpuArray(BaseLB::LDStats*, int, int *);
00040 HeapData* BuildObjectArray(BaseLB::LDStats*, int, int *);
00041 bool QueryBalanceNow(int step);
00042 };
00043
00044 #endif
00045