#define _STATFILE_ #include "treeinter.h" #include #include extern short reverse,szsh,szd,szv,szl,torightto,torightfrom; // list of intervals for each processor CTreeInter::CTreeInter(gzFile stream,unsigned long lint,char *pbuff, unsigned int n,unsigned long qint,short maxn, char * ppn,double proct, int iIM,int jIM,short sore, unsigned char *pbuffer) // stream-file descriptor pointer, //lint- information length in bytes, // pbuff - beginning of the buffer at the collection stage, //n - processor number, //qint - number of intervals //maxn - maximal nesting level // ppn - processor name // proct - processor time //iIm- 0/1 sign of summing on index i //jIM-0/1 sign of summing on index j //sore - sign of summing or elements print //pbuffer - file gz+,data have been read { valid=TRUE; nproc=n; qinter=qint; maxnlev=maxn; curninter=1; pt=NULL; pprocname=NULL; sign_buffer=NULL; unsigned char *buffer; if (ppn!=NULL) {// processor name pprocname=new char[strlen(ppn)+1]; if (pprocname==NULL) throw("Out of memory\n"); strcpy(pprocname,ppn); } proctime=proct; // dynamically allocate memory for intervals of struct tinter_ch if (pbuffer==NULL) { //data had not been read buffer=new unsigned char[lint]; if (buffer==NULL) throw("Out of memory\n"); sign_buffer=buffer; long l=gztell(stream); // read interval information from file int s=gzread(stream,buffer,lint); if ((unsigned long)s!=lint) { valid=FALSE; sprintf(texterr,"Can't read intervals from file, addr=%ld, length=%ld\n", l,lint); delete []sign_buffer; sign_buffer=NULL; return; } } else buffer=pbuffer; unsigned char *pch=buffer; pinter *pi=NULL; // allocate memory for intervals of struct ttree pt=new ptree[qinter]; if (pt==NULL) throw("Out of memory\n"); ident id; // calculate size of interval without name of DVM-programm int lintone=QI_SHORT*szsh+QI_LONG*szl+QI_VOID*szv+QI_DOUBLE*szd; s_GRPTIMES times[StatGrpCount][StatGrpCount]; int a=MAKEDOUBLE(pi,times[0],nenter,QI_SHORT,QI_LONG,QI_VOID); a=MAKELONG(pi,nline,nline,QI_SHORT); for (unsigned long ll=0;llReadIdent(id); return; } } return; } //------------------------------------------------ // return pointer to interval with the same identifier information // set current interval CInter *CTreeInter::FindInter(ident *id) //id - identifier information { unsigned long n; ident *idcur; pt[curninter-1].pint->ReadIdent(&idcur); if (id==idcur) return(pt[curninter-1].pint); //the same processor if (id->nlev==idcur->nlev) { // the same level n=pt[curninter-1].up; if (n>0) n=pt[n-1].down; else n=curninter;// first interval while(n>0) { if (pt[n-1].sign==0 && pt[n-1].pint->CompIdent(id)==1) { pt[n-1].sign=1; curninter=n; return(pt[n-1].pint); } n=pt[n-1].next; } return(NULL); } // need level > current level n=curninter; if (id->nlev>idcur->nlev) { // find need down level while (id->nlev>idcur->nlev) { n=pt[n-1].down; if (n==0) return(NULL); pt[n-1].pint->ReadIdent(&idcur); } // find need interval on finded level while(n>0) { if (pt[n-1].sign==0 && pt[n-1].pint->CompIdent(id)==1) { pt[n-1].sign=1; curninter=n; return(pt[n-1].pint); } n=pt[n-1].next; } return(NULL); } else { // find need up level while (id->nlevnlev) { n=pt[n-1].up; if (n==0) return(NULL); pt[n-1].pint->ReadIdent(&idcur); } unsigned long n1=n; n=pt[n-1].up; if (n>0) n=pt[n-1].down;else n=n1; while(n>0) { if (pt[n-1].sign==0 && pt[n-1].pint->CompIdent(id)==1) { pt[n-1].sign=1; curninter=n; return(pt[n-1].pint); } n=pt[n-1].next; } } return(NULL); } //-------------------------------------------------- //sum time characteristics void CTreeInter::SumLevel(void) { for (short i=maxnlev;i>0;i--) { for (unsigned long j=0;jReadIdent(&id); if (id->nlev==i) { // psum - up level unsigned long up=pt[j].up; CInter *psum=pt[up-1].pint; pt[j].pint->SumInter(psum); } } } pt[0].pint->SumInter(NULL); } //--------------------------------------------------- //processor time void CTreeInter::ReadProcTime(double &time) { time=proctime; } //--------------------------------------------------- //processor name void CTreeInter::ReadProcName(char **name) { *name=pprocname; } //-------------------------------------------------- // deallocate memory for tree interval CTreeInter::~CTreeInter() { if (pprocname!=NULL) delete []pprocname; if (sign_buffer!=NULL) delete []sign_buffer; if (pt==NULL) return; for (unsigned long i=0;i~CInter(); pt[i].pint=NULL; } delete []pt; }