00001
00013
00014 #ifndef _CKGRAPH_H_
00015 #define _CKGRAPH_H_
00016
00017 #include <vector>
00018 #include "BaseLB.h"
00019
00020 class ProcInfo {
00021 friend class ProcArray;
00022
00023 public:
00024 ProcInfo() {}
00025 ProcInfo(int i, double ov, double tl, double sp, bool avail): id(i), _overhead(ov), _totalLoad(tl), _pe_speed(sp), available(avail) {}
00026 inline int getProcId() { return id; }
00027 inline void setProcId(int _id) { id = _id; }
00028 inline double getTotalLoad() const { return _totalLoad; }
00029
00030
00031
00032 inline double &overhead() { return _overhead; }
00033 inline double &totalLoad() { return _totalLoad; }
00034 inline double &pe_speed() { return _pe_speed; }
00035 inline bool isAvailable() { return available; }
00036
00037 protected:
00038 int id;
00039 double _overhead;
00040 double _totalLoad;
00041 double _pe_speed;
00042 bool available;
00043 };
00044
00045 class ProcArray {
00046 public:
00047 ProcArray(BaseLB::LDStats *stats);
00048 ~ProcArray() { }
00049 inline double getAverageLoad() { return avgLoad; }
00050 void resetTotalLoad();
00051
00052
00053 std::vector<ProcInfo> procs;
00054
00055 protected:
00056 double avgLoad;
00057 };
00058
00059 class Edge {
00060 friend class ObjGraph;
00061
00062 public:
00063 Edge(int _id, int _msgs, int _bytes) : id(_id), msgs(_msgs),
00064 bytes(_bytes) {
00065 }
00066 ~Edge() { }
00067 inline int getNeighborId() { return id; }
00068 inline int getNumMsgs() { return msgs; }
00069 inline int getNumBytes() { return bytes; }
00070 inline void setNumBytes(int _bytes) { bytes = _bytes; }
00071
00072 private:
00073 int id;
00074
00075 int msgs;
00076 int bytes;
00077 };
00078
00079 class McastSrc {
00080 friend class ObjGraph;
00081
00082 public:
00083 McastSrc(int _numDest, int _msgs, int _bytes) : numDest(_numDest), msgs(_msgs),
00084 bytes(_bytes) {
00085 }
00086
00087 ~McastSrc() { }
00088
00089 inline int getNumMsgs() { return msgs; }
00090 inline int getNumBytes() { return bytes; }
00091 inline void setNumBytes(int _bytes) { bytes = _bytes; }
00092
00093 std::vector<int> destList;
00094
00095 private:
00096 int numDest;
00097 int msgs;
00098 int bytes;
00099 };
00100
00101 class McastDest {
00102 friend class ObjGraph;
00103
00104 public:
00105 McastDest(int _src, int _offset, int _msgs, int _bytes) : src(_src),
00106 offset(_offset), msgs(_msgs), bytes(_bytes) {
00107 }
00108
00109 ~McastDest() { }
00110
00111 inline int getSrc() { return src; }
00112 inline int getOffset() { return offset; }
00113 inline int getNumMsgs() { return msgs; }
00114 inline int getNumBytes() { return bytes; }
00115 inline void setNumBytes(int _bytes) { bytes = _bytes; }
00116
00117 private:
00118 int src;
00119 int offset;
00120 int msgs;
00121 int bytes;
00122 };
00123
00124 class Vertex {
00125 friend class ObjGraph;
00126
00127 public:
00128 Vertex() {}
00129 Vertex(int i, double cl, bool mig, int curpe, int newpe=-1, size_t pupsize=0):
00130 id(i), compLoad(cl), migratable(mig), currPe(curpe), newPe(newpe),
00131 pupSize(pupsize) {}
00132 inline int getVertexId() { return id; }
00133 inline double getVertexLoad() const { return compLoad; }
00134 inline int getCurrentPe() { return currPe; }
00135 inline int getNewPe() { return newPe; }
00136 inline void setNewPe(int _newpe) { newPe = _newpe; }
00137 inline bool isMigratable() { return migratable; }
00138
00139
00140 std::vector<Edge> sendToList;
00141 std::vector<Edge> recvFromList;
00142 std::vector<McastSrc> mcastToList;
00143 std::vector<McastDest> mcastFromList;
00144 double getCompLoad() {return compLoad;}
00145 void setCompLoad(double s) {compLoad = s;}
00146 int getCurrPe() {return currPe;}
00147 void setCurrPe(int s) {currPe = s;}
00148
00149
00150 private:
00151 int id;
00152 double compLoad;
00153 bool migratable;
00154 int currPe;
00155 int newPe;
00156 size_t pupSize;
00157 };
00158
00159
00160 class ObjGraph {
00161 public:
00162 ObjGraph(BaseLB::LDStats *stats);
00163 ~ObjGraph() { }
00164 void convertDecisions(BaseLB::LDStats *stats);
00165
00166
00167 std::vector<Vertex> vertices;
00168 };
00169
00170 #endif // _CKGRAPH_H_
00171