libs/ck-libs/pose/stats.C

Go to the documentation of this file.
00001 
00002 #include "charm++.h"
00003 #include "stats.h"
00004 #include "stats.def.h"
00005 
00006 CkChareID theGlobalStats;
00007 CkGroupID theLocalStats;
00008 
00009 extern void POSE_exit();
00010 
00012 void localStat::SendStats()
00013 {
00014   CProxy_globalStat gstat(theGlobalStats);
00015   localStatSummary *m = new localStatSummary;
00016   m->doTime = totalTime;
00017   m->rbTime = rollbackTime;
00018   m->gvtTime = gvtTime;
00019   m->simTime = simTime;
00020   m->cpTime = cpTime;
00021   m->canTime = canTime;
00022   m->lbTime = lbTime;
00023   m->fcTime = fcTime;
00024   m->commTime = commTime;
00025   m->cpBytes = cpBytes;
00026   m->maxDo = maxDo;
00027   m->minDo = minDo;
00028   m->pe = CkMyPe();
00029   m->dos = dos;
00030   m->undos = undos;
00031   m->commits = commits;
00032   m->loops = loops;
00033   m->gvts = gvts;
00034   m->maxChkPts = maxChkPts;
00035   m->maxGVT = maxGVT;
00036   m->maxGRT = maxGRT;
00037   gstat.localStatReport(m);
00038 }
00039 
00040 // Basic Constructor
00041 globalStat::globalStat(void):    doAvg (0.0), doMax (0.0), rbAvg (0.0), rbMax (0.0), gvtAvg (0.0), gvtMax (0.0), simAvg (0.0), simMax (0.0), 
00042     cpAvg (0.0), cpMax (0.0), canAvg (0.0), canMax (0.0), lbAvg (0.0), lbMax (0.0), fcAvg (0.0), fcMax (0.0), 
00043     commAvg (0.0), commMax (0.0),
00044     maxTime (0.0), maxDo (0.0), minDo (0.0), avgDo (0.0), GvtTime (0.0), maxGRT (0.0),
00045   cpBytes (0), reporting (0), totalDos (0), totalUndos (0), totalCommits (0), totalLoops (0), 
00046     totalGvts (0), maxChkPts (0), maxGVT (0)
00047 {
00048 #ifdef VERBOSE_DEBUG
00049   CkPrintf("[%d] constructing globalStat\n",CkMyPe());
00050 #endif
00051 
00052 }
00053 
00054 // Receive, calculate and print statistics
00055 void globalStat::localStatReport(localStatSummary *m)
00056 {
00057   double tmpMax;
00058   // accumulate data from local stats collectors
00059   totalDos += m->dos;
00060   totalUndos += m->undos;
00061   totalCommits += m->commits;
00062   totalLoops += m->loops;
00063   totalGvts += m->gvts;
00064   maxChkPts += m->maxChkPts;
00065   doAvg += m->doTime;
00066   if (maxGRT < m->maxGRT) maxGRT = m->maxGRT;
00067   if (maxGVT < m->maxGVT) maxGVT = m->maxGVT;
00068   if (m->maxDo > maxDo)
00069     maxDo = m->maxDo;
00070   if ((minDo < 0.0) || (m->minDo < minDo))
00071     minDo = m->minDo;
00072   if (m->doTime > doMax)
00073     doMax = m->doTime;
00074   rbAvg += m->rbTime;
00075   if (m->rbTime > rbMax)
00076     rbMax = m->rbTime;
00077   gvtAvg += m->gvtTime;
00078   if (m->gvtTime > gvtMax)
00079     gvtMax = m->gvtTime;
00080   simAvg += m->simTime;
00081   if (m->simTime > simMax)
00082     simMax = m->simTime;
00083   cpAvg += m->cpTime;
00084   if (m->cpTime > cpMax)
00085     cpMax = m->cpTime;
00086   canAvg += m->canTime;
00087   if (m->canTime > canMax)
00088     canMax = m->canTime;
00089   lbAvg += m->lbTime;
00090   if (m->lbTime > lbMax)
00091     lbMax = m->lbTime;
00092   fcAvg += m->fcTime;
00093   if (m->fcTime > fcMax)
00094     fcMax = m->fcTime;
00095   commAvg += m->commTime;
00096   if (m->commTime > commMax)
00097     commMax = m->commTime;
00098   cpBytes += m->cpBytes;
00099   tmpMax = m->doTime + m->rbTime + m->gvtTime + m->simTime + m->cpTime 
00100     + m->canTime + m->lbTime + m->fcTime + m->commTime;
00101   CkFreeMsg(m);
00102   if (tmpMax > maxTime)
00103     maxTime = tmpMax;
00104   reporting++;
00105 
00106 #ifdef SEQUENTIAL_POSE
00107   totalLoops = totalDos;
00108   totalGvts = 1;
00109 #endif
00110   CkAssert(totalGvts > 0);
00111   CkAssert(totalDos > 0);
00112   CkAssert(totalLoops > 0);
00113   GvtTime = gvtAvg/totalGvts;
00114   if (reporting == CkNumPes()) { //all local stats are in; compute final values
00115     avgDo = doAvg / totalDos;
00116     doAvg /= CkNumPes();
00117     rbAvg /= CkNumPes();
00118     gvtAvg /= CkNumPes();
00119     simAvg /= CkNumPes();
00120     cpAvg /= CkNumPes();
00121     canAvg /= CkNumPes();
00122     lbAvg /= CkNumPes();
00123     fcAvg /= CkNumPes();
00124     commAvg /= CkNumPes();
00125     maxChkPts /= CkNumPes();
00126     // print stats table (all one print to avoid breaking up)
00127     CkPrintf("------------------------------------------------------------------------------------\n   | DO     | RB     | GVT    | SIM    | CP     | CAN    | LB     | FC     | COMM   |\n---|--------|--------|--------|--------|--------|--------|--------|--------|--------|\nmax| %7.2f| %7.2f| %7.2f| %7.2f| %7.2f| %7.2f| %7.2f| %7.2f| %7.2f|\navg| %7.2f| %7.2f| %7.2f| %7.2f| %7.2f| %7.2f| %7.2f| %7.2f| %7.2f|\n------------------------------------------------------------------------------------\nMax time on a PE:%7.2f, Speculative Events:%d Actual Events:%d Commits:%d\nGRAINSIZE INFO: Avg: %10.6f Max: %10.6f Min: %10.6f\nGVT iterations=%d  Avg time per iteration=%f\ntotalLoops=%d effectiveGS=%10.6f\n", 
00128              doMax, rbMax, gvtMax, simMax, cpMax, canMax, lbMax, fcMax, commMax, doAvg, rbAvg, gvtAvg, simAvg, cpAvg, canAvg, lbAvg, fcAvg, commAvg, maxTime, totalDos, totalDos-totalUndos, totalCommits, avgDo, maxDo, minDo, totalGvts, GvtTime, totalLoops, (doAvg*CkNumPes())/totalLoops);
00129     //CkPrintf("Avg. Max# Checkpoints=%d Bytes checkpointed=%d\n", maxChkPts, cpBytes);
00130 
00131     if(pose_config.dop){
00132       CkPrintf("Overhead-free maximally parallel runtime=%f  Max GVT=%d\n",
00133              maxGRT, maxGVT);
00134       DOPcalc(maxGVT, maxGRT);
00135     }
00136 
00137     POSE_exit();
00138     /*
00139     reporting = 0;
00140     doAvg = doMax = rbAvg = rbMax = gvtAvg = gvtMax = simAvg = simMax = 
00141       cpAvg = cpMax = canAvg = canMax = lbAvg = lbMax = fcAvg = fcMax = 
00142       commAvg, commMax, maxTime = maxDo = minDo = avgDo = GvtTime = 0.0; 
00143     cpBytes = reporting = totalDos = totalUndos = totalCommits = totalLoops = 
00144       totalGvts = maxChkPts = 0;
00145     */
00146   }
00147 }
00148 
00149 
00150 void globalStat::DOPcalc(int gvt, double grt)
00151 {
00152   int vinStart, vinEnd, gvtp = gvt + 1, i;
00153   double rinStart, rinEnd;
00154   FILE *fp;
00155   char filename[20], line[80];
00156   unsigned short int *gvtDOP, *grtDOP;
00157   unsigned long int grtp = (unsigned long int)(grt*1000000.0) + 1, j, 
00158     usStart, usEnd;
00159   int modelPEs=0, simulationPEs=0;
00160 
00161   CkPrintf("Generating DOP measures...\n");
00162   gvtDOP = (unsigned short int *)malloc(gvtp*sizeof(unsigned short int));
00163   grtDOP = (unsigned short int *)malloc(grtp*sizeof(unsigned short int));
00164   for (i=0; i<gvtp; i++) gvtDOP[i] = 0;
00165   for (i=0; i<grtp; i++) grtDOP[i] = 0;
00166   for (i=0; i<CkNumPes(); i++) { // read each processor's log
00167     sprintf(filename, "dop%d.log\0", i);
00168     fp = fopen(filename, "r");
00169     if (!fp) {
00170       CkPrintf("Cannot open file %s... exiting.\n", filename);
00171       POSE_exit();
00172     }
00173     CkPrintf("Reading file %s...\n", filename);
00174     while (fgets(line, 80, fp)) {
00175       if (sscanf(line, "%lf %lf %d %d\n", &rinStart, &rinEnd, 
00176                  &vinStart, &vinEnd) == 4) {
00177         usStart = (unsigned long int)(rinStart * 1000000.0);
00178         usEnd = (unsigned long int)(rinEnd * 1000000.0);
00179         for (j=usStart; j<usEnd; j++) grtDOP[j]++;
00180         if (usStart == usEnd) grtDOP[usStart]++;
00181         if (vinStart > -1)
00182           for (j=vinStart; j<=vinEnd; j++) gvtDOP[j]++;
00183       }
00184       else CkPrintf("WARNING: DOP post-processing corrupted... likely NFS to blame.\n");
00185     }
00186     fclose(fp);
00187   }
00188   int avgPEs = 0;
00189   int zed = 0;
00190   fp = fopen("dop_mod.out", "w");
00191   for (i=0; i<gvtp; i++) {
00192     if ((gvtDOP[i] != 0) || (zed == 0))
00193       fprintf(fp, "%d %d\n", i, gvtDOP[i]);
00194     if (gvtDOP[i] == 0) zed = 1;
00195     else zed = 0;
00196     avgPEs += gvtDOP[i];
00197     if (gvtDOP[i] > modelPEs) modelPEs = gvtDOP[i];
00198   }
00199   avgPEs /= gvtp;
00200   fclose(fp);
00201   fp = fopen("dop_sim.out", "w");
00202   for (i=0; i<grtp; i++) {
00203     fprintf(fp, "%d %d\n", i, grtDOP[i]);
00204     if (grtDOP[i] > simulationPEs) simulationPEs = grtDOP[i];
00205   } 
00206   fclose(fp);
00207   CkPrintf("Max model PEs: %d  Max simulation PEs: %d  Recommended #PEs: %d\n",
00208            modelPEs, simulationPEs, avgPEs);
00209 }

Generated on Sun Jun 29 13:29:25 2008 for Charm++ by  doxygen 1.5.1