#define _STATFILE_ #include "inter.h" #include #include #include // calculate execution characteristics for interval CInter::CInter(s_GRPTIMES (*pt)[StatGrpCount],s_SendRecvTimes ps, ident id,unsigned long nint, int iIM,int jIM,short sore) //(*pt)[StatGrpCount] - pointer to time array,it reading from file, // ps - pointer to add info //id - interval identifier, //nint - interval number. { //identifire interval information if (id.pname[0]!='\0') { idint.pname=new char[strlen(id.pname)+1]; if (idint.pname==NULL) throw("Out of memory\n"); } else idint.pname=NULL; if (idint.pname!=NULL) strcpy(idint.pname,id.pname);// name of DVM-programm idint.nline=id.nline; // number of DVM-programm line idint.nline_end=id.nline_end; // number of end of DVM-programm line idint.nenter=id.nenter; // number of enters into the interval idint.expr=id.expr; // conditional expession idint.nlev=id.nlev; // number of interval level idint.t=id.t; // type of interval ninter=nint; idint.proc=id.proc; // number of processors // arrays of collective operation times int i; for ( i=0;i<=ITER;i++) mgen[i]=0.; for (i=0;i<=RED;i++) { mcom[i]=0.; mrcom[i]=0.; msyn[i]=0.; mvar[i]=0.; mcall[i]=0.; moverlap[i]=0.; } for(i=0;iITER) { printf("CInter AddTime incorrect typetime %d\n",t2); return; } #endif mgen[t2]=mgen[t2]+val; } //-------------------------------------------------- //write new execution time characteristics void CInter::WriteTime(typetime t2,double val) //t2 - type of execution characteristics // val - new value { #ifdef _DEBUG if (t2<0 || t2>ITER) { printf("CInter WriteTime incorrect typetime %d\n",t2); return; } #endif mgen[t2]=val; } //------------------------------------------------- // read execution time characteristics void CInter::ReadTime(typetime t2,double &val) //t2 - type of execution characteristics // val - answer { #ifdef _DEBUG if (t2<0 || t2>ITER) { printf("CInter ReadTime incorrect typetime %d\n",t2); return; } #endif val=mgen[t2]; } //-------------------------------------------------- // addition times of collective operations void CInter::AddTime(typegrp t1,typecom t2,double val) //t1 - type of communication operation //t2 - type of collective operation //val - additional value { #ifdef _DEBUG if (t2<0 || t2>RED) { printf("CInter AddTime incorrect typecom %d\n",t2); return; } #endif switch (t1) { case COM: mcom[t2]=mcom[t2]+val; break; case RCOM: mrcom[t2]=mrcom[t2]+val; break; case SYN : msyn[t2]=msyn[t2]+val; break; case VAR: mvar[t2]=mvar[t2]+val; break; case CALL: mcall[t2]=mcall[t2]+val; break; case OVERLAP: moverlap[t2]=moverlap[t2]+val; break; default: printf("CInter WriteCom incorrect typegrp\n"); break; } } //--------------------------------------------------- // read communication collective operations time void CInter::ReadTime(typegrp t1,typecom t2,double &val) //t1 - type of communication operation //t2 - type of collective operation //val - answer { #ifdef _DEBUG if (t2<0 || t2>RED) { printf("CInter ReadTime incorrect typecom %d\n",t2); return; } #endif switch (t1) { case COM: val=mcom[t2]; break; case RCOM: val=mrcom[t2]; break; case SYN : val=msyn[t2]; break; case VAR: val=mvar[t2]; break; case CALL: val=mcall[t2]; break; case OVERLAP: val=moverlap[t2]; break; default: printf("CInter ReadTime incorrect typegrp\n"); break; } } //--------------------------------------------------- // read time from interval matrix void CInter::ReadTime(typetimeim t1,int t2,double &val) //t1 - type of time (lost/number of calls) //t2 - index //val - answer { #ifdef _DEBUG if (t2<0 || t2>=StatGrpCount) { printf("CInter ReadTime incorrect 2 parameter %d\n",t2); return; } #endif switch (t1) { case CALLSMT: val=calls[t2]; break; case LOSTMT: val=lost[t2]; break; case PRODMT: val=prod[t2]; break; default: printf("CInter ReadTime incorrect type of im time\n"); break; } } //----------------------------------------------------- // compare identifier information on other processors int CInter::CompIdent(ident *p) //p - pointer identifire information { if ((idint.pname==NULL || (strcmp(p->pname,idint.pname)==0)) && (p->nline==idint.nline) && (p->nlev==idint.nlev) && (p->expr==idint.expr) && (p->t==idint.t)) { return(1); } return(0); } //------------------------------------------------------ // read identifier information void CInter::ReadIdent(ident **p) { *p=&idint; } //----------------------------------------------------- // sum times characteristics upon levels void CInter::SumInter(CInter *p) { int i; for (i=0;i<=RED;i++) { mgen[SUMSYN]=mgen[SUMSYN]+msyn[i]; mgen[SUMVAR]=mgen[SUMVAR]+mvar[i]; mgen[SUMOVERLAP]=mgen[SUMOVERLAP]+moverlap[i]; } mgen[PROC]=(double)idint.proc; if (idint.proc!=0) { mgen[LOST]=mgen[INSUF]+mgen[INSUFUSR]+mgen[IDLE]+mgen[SUMCOM]; } if (p==NULL) return; for (i=0;i<=ITER;i++) { if (iSUMOVERLAP) p->mgen[i]=p->mgen[i]+mgen[i]; } for (i=0;ilost[i]=p->lost[i]+lost[i]; p->prod[i]=p->prod[i]+prod[i]; p->calls[i]=p->calls[i]+calls[i]; } // add information p->SendCallTime=p->SendCallTime+SendCallTime; p->MinSendCallTime=p->MinSendCallTime+MinSendCallTime; p->MaxSendCallTime=p->MaxSendCallTime+MaxSendCallTime; p->SendCallCount=p->SendCallCount+SendCallCount; p->RecvCallTime=p->RecvCallTime+RecvCallTime; p->MinRecvCallTime=p->MinRecvCallTime+MinRecvCallTime; p->MaxRecvCallTime=p->MaxRecvCallTime+MaxRecvCallTime; p->RecvCallCount=p->RecvCallCount+RecvCallCount; // sum communication information for (i=0;i<=RED;i++) { p->mcom[i]=p->mcom[i]+mcom[i]; p->mrcom[i]=p->mrcom[i]+mrcom[i]; p->msyn[i]=p->msyn[i]+msyn[i]; p->mvar[i]=p->mvar[i]+mvar[i]; p->moverlap[i]=p->moverlap[i]+moverlap[i]; p->mcall[i]=p->mcall[i]+mcall[i]; } } //-----------------------------------------------------