00001 00014 00015 #ifndef _OBJGRAPH_H_ 00016 #define _OBJGRAPH_H_ 00017 00018 #include "lbdb.h" 00019 #include "CentralLB.h" 00020 00021 class ObjGraph { 00022 public: 00023 class Edge { 00024 friend class ObjGraph; 00025 public: 00026 int edge_index; 00027 int index; 00028 int from_node; 00029 int to_node; 00030 Edge* next_from() { return nxt_out; }; 00031 Edge* next_to() { return nxt_in; }; 00032 private: 00033 Edge* nxt_out; 00034 Edge* nxt_in; 00035 }; 00036 00037 class Node { 00038 friend class ObjGraph; 00039 public: 00040 int node_index; 00041 int proc; 00042 int index; 00043 int n_out; 00044 int n_in; 00045 Edge* edges_from() { return outEdge; }; 00046 Edge* edges_to() { return inEdge; }; 00047 00048 private: 00049 Edge* outEdge; 00050 Edge* inEdge; 00051 Node* nxt_hash; 00052 }; 00053 00054 ObjGraph(int count, BaseLB::LDStats* stats); 00055 ~ObjGraph(); 00056 00057 int NodeCount() { return n_objs; }; 00058 int EdgeCount() { return n_edges; }; 00059 Node* Start() { return nodelist; }; 00060 Node GraphNode(int i) { return nodelist[i]; }; 00061 00062 double LoadOf(int i) { 00063 const Node n = GraphNode(i); 00064 const int index = n.index; 00065 return stats->objData[index].wallTime; 00066 }; 00067 00068 double EdgeWeight(Edge* e); 00069 00070 private: 00071 enum { hash_max = 256 }; 00072 00073 int calc_hashval(LDOMid, CmiUInt8); 00074 Node* find_node(const LDObjKey &); 00075 00076 Edge* edgelist; 00077 Node* node_table[hash_max]; 00078 00079 int n_objs; 00080 int n_edges; 00081 Node* nodelist; 00082 BaseLB::LDStats* stats; 00083 }; 00084 00085 #endif 00086