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