00001
00005
00006 #ifndef _REFINERCOMM_H_
00007 #define _REFINERCOMM_H_
00008
00009 #include "CentralLB.h"
00010 #include "Refiner.h"
00011
00012 class RefinerComm : public Refiner {
00013 public:
00014 RefinerComm(double _overload): Refiner(_overload) {
00015 overLoad = _overload; computes=0; processors=0;
00016 };
00017 ~RefinerComm() {}
00018
00019 void Refine(int count, BaseLB::LDStats* stats, int* cur_p, int* new_p);
00020
00021 private:
00022 struct Messages {
00023 int byteSent;
00024 int msgSent;
00025 int byteRecv;
00026 int msgRecv;
00027 Messages() { clear(); }
00028 void clear() { byteSent=msgSent=byteRecv=msgRecv=0; }
00029 double cost() {
00030 return msgSent * _lb_args.alpha() +
00031 byteSent * _lb_args.beta() +
00032 msgRecv * PER_MESSAGE_RECV_OVERHEAD +
00033 byteRecv * PER_BYTE_RECV_OVERHEAD;
00034 }
00035 };
00036 struct CommTable {
00037 int* msgSentCount;
00038 int* msgRecvCount;
00039 int* byteSentCount;
00040 int* byteRecvCount;
00041 int count;
00042 CommTable(int p);
00043 ~CommTable();
00044 void clear();
00045 void increase(bool issend, int pe, int msgs, int bytes);
00046 double overheadOnPe(int pe);
00047 };
00048 BaseLB::LDStats* stats;
00049 CommTable *commTable;
00050
00051 void create(int count, BaseLB::LDStats* , int* cur_p);
00052 void processorCommCost();
00053 void assign(computeInfo *c, int p);
00054 void assign(computeInfo *c, processorInfo *p);
00055 void deAssign(computeInfo *c, processorInfo *pRec);
00056 virtual int refine();
00057 virtual void computeAverage();
00058 void objCommCost(int c, int pe, Messages &m);
00059 void commAffinity(int c, int pe, Messages &m);
00060 inline void printLoad() {
00061 for (int i=0; i<P; i++) CmiPrintf("%f ", processors[i].load);
00062 CmiPrintf("\n");
00063 }
00064 };
00065
00066 #endif
00067
00068