00001
00013
00014 #include "ckgraph.h"
00015
00016 ProcArray::ProcArray(BaseLB::LDStats *stats) {
00017 int numPes = stats->nprocs();
00018
00019
00020 procs.resize(numPes);
00021
00022
00023
00024 avgLoad = 0.0;
00025 for(int pe = 0; pe < numPes; pe++) {
00026 procs[pe].id = stats->procs[pe].pe;
00027 procs[pe].overhead() = stats->procs[pe].bg_walltime;
00028 procs[pe].totalLoad() = stats->procs[pe].total_walltime - stats->procs[pe].idletime;
00029 procs[pe].available = stats->procs[pe].available;
00030 avgLoad += procs[pe].totalLoad();
00031 }
00032 avgLoad /= numPes;
00033 }
00034
00035 void ProcArray::resetTotalLoad() {
00036 for(int pe = 0; pe < procs.size(); pe++)
00037 procs[pe].totalLoad() = procs[pe].overhead();
00038 }
00039
00040 ObjGraph::ObjGraph(BaseLB::LDStats *stats) {
00041
00042 vertices.resize(stats->n_objs);
00043
00044 for(int vert = 0; vert < stats->n_objs; vert++) {
00045 vertices[vert].id = vert;
00046 vertices[vert].compLoad = stats->objData[vert].wallTime;
00047 vertices[vert].migratable = stats->objData[vert].migratable;
00048 vertices[vert].currPe = stats->from_proc[vert];
00049 vertices[vert].newPe = -1;
00050 }
00051
00052
00053 stats->makeCommHash();
00054
00055 int from, to;
00056
00057 for(int edge = 0; edge < stats->n_comm; edge++) {
00058 LDCommData &commData = stats->commData[edge];
00059
00060
00061
00062 if( (!commData.from_proc()) && (commData.recv_type()==LD_OBJ_MSG) ) {
00063 from = stats->getHash(commData.sender);
00064 to = stats->getHash(commData.receiver.get_destObj());
00065
00066 vertices[from].sendToList.push_back(Edge(to, commData.messages, commData.bytes));
00067 vertices[to].recvFromList.push_back(Edge(from, commData.messages, commData.bytes));
00068 }
00069 else if((!commData.from_proc()) && (commData.recv_type() == LD_OBJLIST_MSG)) {
00070 int nobjs, offset;
00071 LDObjKey *objs = commData.receiver.get_destObjs(nobjs);
00072 McastSrc sender(nobjs, commData.messages, commData.bytes);
00073
00074 from = stats->getHash(commData.sender);
00075 offset = vertices[from].mcastToList.size();
00076
00077 for(int i = 0; i < nobjs; i++) {
00078 int idx = stats->getHash(objs[i]);
00079 CmiAssert(idx != -1);
00080 vertices[idx].mcastFromList.push_back(McastDest(from, offset,
00081 commData.messages, commData.bytes));
00082 sender.destList.push_back(idx);
00083 }
00084 vertices[from].mcastToList.push_back(sender);
00085 }
00086 }
00087 }
00088
00089 void ObjGraph::convertDecisions(BaseLB::LDStats *stats) {
00090 for(int vert = 0; vert < stats->n_objs; vert++) {
00091 if(vertices[vert].newPe != -1) {
00092 stats->to_proc[vertices[vert].id] = vertices[vert].newPe;
00093 }
00094 }
00095 }
00096